2.1 KiB
2.1 KiB
nut — Network UPS Tools
Monitors a UPS over USB (or serial/network), notifies via ntfy on power events and gracefully shuts the host down on low battery.
Supported distributions
- Arch Linux
- Debian/Ubuntu
What it does
- Installs
nutand configures it in standalone mode (single host, no network slaves). - Configures the
usbhid-upsdriver against the UPS defined innut_ups_name(default: EATON Ellipse 1600, vendorid0463). - Binds
upsdto127.0.0.1:3493only — no LAN exposure. - Runs
upsmonas master, which:- calls
SHUTDOWNCMD(systemctl poweroff) onLOWBATT, - dispatches every event to a
NOTIFYCMDwrapper that POSTs to ntfy with severity, tags and a host-aware title.
- calls
Configuration
Variables — see defaults/main.yml.
Required (role asserts at start):
nut_monitor_password: "<min 12 chars>" # local upsd user used by upsmon + exporter
nut_ntfy_topic: "ups-<host>"
Optional but commonly tweaked:
nut_ups_name: eaton
nut_ups_description: "EATON Ellipse 1600"
nut_ups_vendorid: "0463"
nut_ntfy_server: https://ntfy.jokester.fr
nut_ntfy_token: "tk_..." # publish token for nut_ntfy_topic
Operations
Check UPS status
upsc {{ nut_ups_name }}@localhost
List configured UPSes
upsc -l
Test the NOTIFYCMD pipeline without unplugging
sudo -u nut NOTIFYTYPE=ONBATT /usr/local/bin/ups-notify "Simulated ONBATT for ntfy plumbing test"
Simulate a full power loss (DANGEROUS — actually powers off)
sudo upsmon -c fsd
Logs
journalctl -u nut-monitor -u nut-server -u 'nut-driver@*' -f
Security
upsdbinds to127.0.0.1only.upsd.usersmode0640owned byroot:nut.- No anonymous read access — exporter and upsmon both authenticate as
nut_monitor_user. - udev rules shipped by the
nutpackage grant USB device access to thenutgroup only.
Companion role
See nut_exporter to expose Prometheus metrics
based on the same upsd instance.