Network UPS Tools#
NUT is a software which is able to monitor UPSs and take action when needed, such as shutting down a computer when the battery level is low.
Example for Eaton 650i USB#
create the jobs directories
mkdir -p /home/jobs/scripts/by-user/nut
Install NUT
apt-get install nut
add the following to the
UPS definitions file
1MODE=standalone
add the following to the
UPS configuration file
1[my_ups] 2 pollonly 3 driver = usbhid-ups 4 port = auto 5 vendorid = "0463" 6 productid = "FFFF" 7 pollfreq = 30 8 desc = "Eaton UPS on my pc"
add the following to the
administrative user definitions file
1[user] 2 password = password 3 upsmon master 4 actions = SET 5 instcmds = ALL
add the following to the
configuration file for the monitoring daemon
1MONITOR my_ups@127.0.0.1 1 user password master 2 3NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC 4NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC 5NOTIFYFLAG FSD SYSLOG+WALL+EXEC 6NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC 7NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC 8NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC 9NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC 10NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC 11NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC 12NOTIFYFLAG NOPARENT SYSLOG+WALL+EXEC 13 14NOTIFYCMD "/home/jobs/scripts/by-user/nut/ups_notify.sh"
You can comment
NOTIFYCMD
or change it with a custom command. You can, for example, create a script like thisscript
1#!/usr/bin/env bash 2 3echo "$*" | gotify
restart all NUT services
systemctl restart nut-driver.service systemctl restart nut-server.service systemctl restart nut-monitor.service
fix the permissions
chmod 700 -R /home/jobs/scripts/by-user/nut chown -R nut:nut /home/jobs/scripts/by-user/nut
remove the plug from the UPS and check if the
NOTIFYCMD
command is executed and if you get broadcast messages on the terminal, such asBroadcast message from ... UPS my_ups@127.0.0.1 on battery
put the plug back in the UPS
Footnotes