Skip to content

Instantly share code, notes, and snippets.

@jakeapp
Forked from InQuize/Proxomox - NUT Client.md
Last active September 4, 2021 06:20
Show Gist options
  • Save jakeapp/804aba24386a8ddbfe903c04a6003552 to your computer and use it in GitHub Desktop.
Save jakeapp/804aba24386a8ddbfe903c04a6003552 to your computer and use it in GitHub Desktop.
Proxomox - NUT Client.md

Configuring Proxmox VE node as client for remote NUT server


apt-get install nut
  • Edit /etc/nut/nut.conf:
MODE=netclient
  • Edit /etc/nut/upsmon.conf: MONITOR <system> <powervalue> <username> <password> ("master"|"slave"):
MONITOR ups@10.2.0.2 1 upsmon password slave
  • Start monitoring:
upsmon start
  • To check UPS status: upsc <name> for direct attached units or upsc <name>@<address> for remote
upsc ups@10.2.0.2

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
@jakeapp
Copy link
Author

jakeapp commented Feb 20, 2021

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