Skip to content

Instantly share code, notes, and snippets.

@twaddington
Last active April 22, 2024 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twaddington/4b06a55aabc5ef431919b976176a551b to your computer and use it in GitHub Desktop.
Save twaddington/4b06a55aabc5ef431919b976176a551b to your computer and use it in GitHub Desktop.
Network UPS Tools (NUT) on Debian
MODE=standalone
# Allow nut group to execute shutdown command
%nut ALL=NOPASSWD: /sbin/shutdown
# Set maxretry to 3 by default, this should mitigate race with slow devices:
maxretry = 3
[eaton]
driver = usbhid-ups
port = auto
vendorid = 0463
[upsmon]
password = 1234
upsmon master
MONITOR eaton@localhost 1 upsmon 1234 master
NOTIFYCMD /sbin/upssched
NOTIFYFLAG ONLINE SYSLOG+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5
#! /bin/sh
#
# This script should be called by upssched via the CMDSCRIPT directive.
#
# Here is a quick example to show how to handle a bunch of possible
# timer names with the help of the case structure.
#
# This script may be replaced with another program without harm.
#
# The first argument passed to your CMDSCRIPT is the name of the timer
# from your AT lines.
case $1 in
onbattwarn)
sudo /sbin/shutdown -h +5
logger -t upssched-cmd "The UPS is on battery power"
;;
ups-back-on-power)
sudo /sbin/shutdown -c
logger -t upssched-cmd "The UPS is back on wall power"
;;
*)
logger -t upssched-cmd "Unrecognized command: $1"
;;
esac
CMDSCRIPT /usr/local/bin/upssched-cmd
PIPEFN /var/run/nut/upssched.pipe
LOCKFN /var/run/nut/upssched.lock
AT ONBATT * EXECUTE onbattwarn
AT ONLINE * EXECUTE ups-back-on-power
@twaddington
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment