This is an old revision of the document!
Tested with XCP-ng 8.2 and a CyberPower CPS1500AVR UPS.
Connect the included USB or serial cable to UPS.
We use the Local version for single servers with USB or serial cable connected UPSs.
wget https://dl4jz3rbrsfum.cloudfront.net/software/ppb470-linux-x86_x64.sh chmod +x ppb470-linux-x86_x64.sh ./ppb470-linux-x86_x64.sh
Check that services started:
systemctl status ppbed.service systemctl status ppbwd.service
Use a web browser:
http:<ip.of.linux.server>:3052
==== Configuration ====
We don't want the server to shut down immediately upon power failure…we want to wait until the battery gets low before we actually run the shutdown command.
Edit the PowerPanel configuration file:
<file>
vi /etc/pwrstatd.conf
</file>
And change:
<file>
powerfail-shutdown = no #we want to shut down the UPS when the battery gets low, not when the power fails
shutdown-sustain = 200 #set this to a little longer than it takes to shut your server down
lowbatt-threshold = 15 #don't run the battery completely dead
</file>
Restart the service:
<file>
/etc/init.d/pwrstatd restart
</file>
or
<file>
service pwrstatd restart
</file>
Commands that run upon power-fail and low-battery events are also specified in the /etc/pwrstatd.conf configuration file. By default, it specifies:
<file>
/etc/pwrstatd-powerfail.sh
</file>
and
<file>
/etc/pwrstatd-lowbatt.sh
</file>
===== Testing =====
You may want to change the lowbatt-threshold to 90
so the box shuts down in the shortest time, then change it back when finished testing.
<file>
lowbatt-threshold = 90
service pwrstatd restart
tail -f /var/log/pwrstatd.log
</file>
===== XenServer =====
These settings are probably not ideal, but are a good start. I think the goal would be to confirm that all VMs are shut nown properly before issuing the shutdown command.
Modifications to above for XenServer:
<file>
vi /etc/pwrstatd.conf
</file>
And change:
<file>
powerfail-shutdown = no #we want to shut down the UPS when the battery gets low, not when the power fails
shutdown-sustain = 600 #set this to a little longer than it takes to shut down all VMs and your server
lowbatt-threshold = 35 #don't run the battery completely dead and give time to shut down
lowbatt-duration = 60 #allow the script to run for 60 seconds before the shutdown
</file>
<file>
vi /etc/pwrstatd-lowbatt.sh
</file>
and append:
<file>
xe vm-shutdown power-state=running –multiple
</file>