Skip to main content

UPS Monitoring tool

Project description

NUT UPS monitoring and notifications via Telegram notification or email or both.

Use case

Connect your primary internet router to UPS (e.g., CyberPower) to protect your network internet connectivity (and internal WiFi, ZigBee) from power outage (e.g., accident or sabotage). You may have backup LTE modem installed should power outage disable the primary link.

With UPS backup your internal network keeps running. Commodity models of UPSs do not provide notification on status change so if you are not physically present on premise, you won’t get notified of such event.

This package helps with that. It is supposed to be running on a PC (e.g., RPi) connected via USB to the UPS, powered by the UPS as well. On the PC, NUT should be configured to monitor UPS state (setup tutorial).

This package then collects events from NUT and continuously monitors UPSs state. For example, when UPS state changes, you get an email and Telegram notification about such event. Also, if UPS is running on battery, you get periodic heartbeat status message on Telegram so you know expected battery running time and to see that system is still operating.

                              ┌──────────┐
                    USB link  │    RPi   │
                  ┌───────────┤          │
                  │           └───┬────┬─┘
           ┌──────┴───────┐       │    │
┌──────┐   │              │       │
│Power ├───┤     UPS      ├───────┤    │
└──────┘   │              │       │     Eth
           └──────────────┘       │    │
                              ┌───┴────┴─┐
                              │   WiFi   │
                              │  router  │
                              └──────────┘

Setup

  • pip-install this package pip install -U ph4-upsmonit

  • Configure config.json according to assets/config-example.json

  • Configure notification channels, either

  • Run assets/install.sh to install ph4upsmon.service systemd service

  • Configure NUT to send events to ph4upsmon as install script instructs you

  • Run systemctl start ph4upsmon.service

Notification examples

System startup:

UPS state report [OL, age=0.00]: {
  "battery.charge": 100.0,
  "battery.runtime": 13370.0,
  "battery.voltage": 26.8,
  "input.voltage": 242.0,
  "output.voltage": 242.0,
  "ups.load": 0.0,
  "ups.status": "OL",
  "ups.test.result": "No test initiated",
  "meta.battery.runtime.m": 222.6,
  "meta.time_check": 1674067083.7017221,
  "meta.dt_check": "01/18/2023, 18:38:04"
}

System is running on battery

UPS state report [OB DISCHRG, age=0.00]: {
  "battery.charge": 100.0,
  "battery.runtime": 13370.0,
  "battery.voltage": 26.8,
  "input.voltage": 242.0,
  "output.voltage": 242.0,
  "ups.load": 0.0,
  "ups.status": "OB DISCHRG",
  "ups.test.result": "No test initiated",
  "meta.battery.runtime.m": 222.6,
  "meta.time_check": 1674067076.121453,
  "meta.dt_check": "01/18/2023, 18:37:56"
}

Telegram channel gets updated regularly until state of the UPS returns back to normal. Note that meta.battery.runtime.m field shows remaining battery time estimation in minutes.

Telegram bot supports also several commands, e.g., /status and /full_status, to which it responds with current state. You can manually request status information and to check that system is responsive.

Note that Email notifier sends only state changes, while Telegram notifier sends also regular state updates when UPS is running on the battery. If email user is empty, email notifier is not use. Likewise, if bot API key is empty, telegram is not used.

Dependencies

This project uses monitoring tool library https://github.com/ph4r05/ph4-monitlib

Similar project for monitoring network connections (SSH tunnels): https://github.com/ph4r05/ph4-connmon

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ph4-upsmonit-0.0.2.tar.gz (9.4 kB view details)

Uploaded Source

File details

Details for the file ph4-upsmonit-0.0.2.tar.gz.

File metadata

  • Download URL: ph4-upsmonit-0.0.2.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for ph4-upsmonit-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e427d4bee2d347796d6826daec1638e3b2675aac1e7a882533537ea3b0698d3f
MD5 2486a75a0948a3095a5e26b854e57cf9
BLAKE2b-256 7d27f5757bd1e28b0aa66ae3b8bc1b3332641879c7c3e47ddf76c21b11b40040

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page