This documents everything I needed to get my Proxmox instance to listen to my Network UPS Tools (NUT) Server and initiate a shutdown script that would shutdown my UDM Pro upon power loss. This is needed as the UDM Pro does not have the ability to listen to a NUT server on it's own (what the hell ubiquiti).
I'm using a Synology NAS as a NUT server, but you can point your NUT client to any supported UPS. It's set to alert any clients subscribed to it when the UPS connected to it is in low battery. This all applies regardless of what machine you have a NUT server on, it does not have to be Synology.
Additionally these install steps were on my Proxmox machine, but these steps will probably work on any Debian GNU/Linux OS with little to no modification. YMMV
High level summary of the steps:
- Install the NUT client on Proxmox
- Enable SSH on the UDM Pro
- Call shutdown script when NUT Server (i.e. Synology) broadcasts low UPS battery, which will SSH into UDMP and initiate shutdown
With small tweaks I believe most of these steps would work on most linux systems
apt-get install nut sshpass
- Edit
/etc/nut/nut.conf
:
MODE=netclient
- Edit
/etc/nut/upsmon.conf
:MONITOR <system> <powervalue> <username> <password> ("master"|"slave")
:
MONITOR [email protected] 1 monuser secret slave
Replace:
192.168.30.60 → Your NUT Server IP (i.e. Synology)
monuser → Your NUT username, default is 'monuser' for Synology
secret → Your NUT password, default is 'secret' for Synology
- Start monitoring:
upsmon start
- To check UPS status:
upsc <name>
for direct attached units orupsc <name>@<address>
for remote
upsc [email protected]
This applies to my Synology NAS, I'm not sure if other NUT Servers will require this.
In synology go to Power>UPS Settings, add the IPs of all devices that will be accessing the NUT server. In my case I need to add the IP of my Proxmox instance. Ensure that you're using a static IP.
Go to your UniFi OS page select Console Settings. Enable SSH and set a strong and secure password
On proxmox, update SHUTDOWNCMD
in /etc/nut/upsmon.conf
SHUTDOWNCMD "/bin/bash -c 'sshpass -p \"yourpassword\" ssh -o StrictHostKeyChecking=no [email protected] \"ubnt-systool poweroff\" & sleep 3 && /sbin/shutdown -h +0'"
Replace:
yourpassword → Your UDMP root password, which you set earlier above.
192.168.50.1 → Your UniFi Dream Machine Pro's IP.
That's it. Make sure you test and ensure this works on your system. Please feel free to add comments or suggestions.
PS. This is a fork. All credits go to KidA001