apt-get install nut
- Edit
/etc/nut/nut.conf
:
MODE=netclient
- Edit
/etc/nut/upsmon.conf
:MONITOR <system> <powervalue> <username> <password> ("master"|"slave")
:
MONITOR [email protected] 1 upsmon password slave
- Start monitoring:
upsmon start
- To check UPS status:
upsc <name>
for direct attached units orupsc <name>@<address>
for remote
upsc [email protected]
add AT commands for shutdown based on events
- Edit
/etc/nut/upssched.conf
:
AT COMMBAD * EXECUTE commbad
AT COMMOK * EXECUTE commok
AT NOCOMM * EXECUTE nocomm
AT ONBATT * EXECUTE powerout
AT ONBATT * START-TIMER shutdownnow 240
AT LOWBATT * EXECUTE shutdowncritical
AT ONLINE * CANCEL-TIMER shutdownnow
AT ONLINE * EXECUTE powerup
- Edit
/bin/upssched-cmd
:
case $1 in
commbad)
/bin/echo "UPS communications failure on `date`."
/usr/bin/wall "UPS communications failure."
;;
commok)
/bin/echo "UPS communications restored on `date`."
/usr/bin/wall "UPS communications restored."
;;
nocomm)
/bin/echo "UPS communications cannot be established on `date`."
/usr/bin/wall "UPS communications cannot be established."
;;
powerout)
/bin/echo "Power failure on `date`."
/usr/bin/wall "UPS on battery. Shutdown in 240 seconds...."
;;
shutdownnow)
/bin/echo "UPS has been on battery for 240 seconds. Starting orderly shutdown on `date`."
/usr/bin/wall "UPS has been on battery for 240 seconds. Shutting down NOW!!!!"
/sbin/shutdown -p +0
;;
shutdowncritical)
/bin/echo "UPS battery level CRITICAL. Starting EMERGENCY shutdown on `date`."
/usr/bin/wall "UPS battery level CRITICAL. Shutting down NOW!!!!"
/sbin/shutdown -h +0
;;
powerup)
/bin/echo "Power restored on `date`."
/usr/bin/wall "UPS on line. Shutdown aborted."
;;
upsgone)
logger -t upssched-cmd "The UPS has been gone for awhile"
;;
*)
logger -t upssched-cmd "Unrecognized command: $1"
;;
esac
- Reload upsmon:
# upsmon -c reload
credit to Arnie https://forums.contribs.org/index.php?topic=44443.0