Meet NUT Server, or Network UPS Tools. It’s an open UPS networking monitoring tool that runs on many different operating systems and processors. This means you can run the server on Linux, MacOS, or BSD and run the client on Windows, MacOS, Linux, and more. It’ perfect for your Pi, server, or desktop. It works with hundreds of UPS devices, PDUs, and many other power management systems.
This is the ultimate guide to configuring Network UPS Tools (NUT). We cover everything from installing and configuring the server on as Raspberry Pi, configuring the client on Windows and Linux, configure a charting and graphing website to visualize NUT data, spin up an additional web site use Docker, and finally set up monitoring and alerting to automate shutdowns of your machine.
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 019: ID 09ae:2012 Tripp Lite
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
RUN_AS_USERrootMONITORapc-modem@ip.address.of.nut.server1adminsecretslaveMINSUPPLIES1SHUTDOWNCMD"/sbin/shutdown -h"NOTIFYCMD /usr/sbin/upsschedPOLLFREQ2POLLFREQALERT1HOSTSYNC15DEADTIME15POWERDOWNFLAG /etc/killpowerNOTIFYMSGONLINE"UPS %s on line power"NOTIFYMSGONBATT"UPS %s on battery"NOTIFYMSGLOWBATT"UPS %s battery is low"NOTIFYMSGFSD"UPS %s: forced shutdown in progress"NOTIFYMSGCOMMOK"Communications with UPS %s established"NOTIFYMSGCOMMBAD"Communications with UPS %s lost"NOTIFYMSGSHUTDOWN"Auto logout and shutdown proceeding"NOTIFYMSGREPLBATT"UPS %s battery needs to be replaced"NOTIFYMSGNOCOMM"UPS %s is unavailable"NOTIFYMSGNOPARENT"upsmon parent process died - shutdown impossible"NOTIFYFLAGONLINESYSLOG+WALL+EXECNOTIFYFLAGONBATTSYSLOG+WALL+EXECNOTIFYFLAGLOWBATTSYSLOG+WALLNOTIFYFLAGFSDSYSLOG+WALL+EXECNOTIFYFLAGCOMMOKSYSLOG+WALL+EXECNOTIFYFLAGCOMMBADSYSLOG+WALL+EXECNOTIFYFLAGSHUTDOWNSYSLOG+WALL+EXECNOTIFYFLAGREPLBATTSYSLOG+WALLNOTIFYFLAGNOCOMMSYSLOG+WALL+EXECNOTIFYFLAGNOPARENTSYSLOG+WALLRBWARNTIME43200NOCOMMWARNTIME600FINALDELAY5
sudo nano /etc/nut/upssched-cmd
`````bash
#!/bin/shcase$1in
onbatt)
logger -t upssched-cmd "UPS running on battery";;
earlyshutdown)
logger -t upssched-cmd "UPS on battery too long, early shutdown"
/usr/sbin/upsmon -c fsd
;;
shutdowncritical)
logger -t upssched-cmd "UPS on battery critical, forced shutdown"
/usr/sbin/upsmon -c fsd
;;
upsgone)
logger -t upssched-cmd "UPS has been gone too long, can't reach";;*)
logger -t upssched-cmd "Unrecognized command: $1";;esac
make it executable (should already be)
1
chmod +x /etc/nut/upssched-cmd
Be sure PIPEFN and LOCKFN point to a folder that esists, I’ve seen it point to /etc/nut/upssched/ instead of /etc/nut If it does, create the folder or update these variables.
1
mkdir /etc/nut/upssched/
test
1
systemctl restart nut-client
then pull the plug on the ups connected to the master, check syslogs