Skip to main content

UPS monitoring

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.

Usage

Send /help message to the Telegram bot

Help:
/start - register
/stop - deregister
/status - brief status
/full_status - full status
/log - log of latest events
/noemail - disable email reporting
/doemail - enable email reporting
/doedit <time> - edit last status message instead of sending a new one. Time to edit the old message in seconds.

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

Metadata

Release files for ph4-upsmonit 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ph4-upsmonit 0.0.8
File Size Uploaded
ph4-upsmonit-0.0.8.tar.gz 13.0 kB Details

Release files / ph4-upsmonit-0.0.8.tar.gz

Download URL ph4-upsmonit-0.0.8.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5350af909372fd6d515face9ac99aa78ced3cfa2add347ceeee4b2d8a47e945e
BLAKE2b-256 checksum
How to use checksums
1253d2e14098f18ff91bd6329a2868edbf03b1efcf64226f6908ca4348fa6368
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.0.8 This release

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page