I have a Cyberpower CP1000PFCLCD UPS that is linked to my OMV box. I would like to have my system run a script when shutting down due to a power outage or UPS low battery. The main purpose of the script would be to execute a few additional commands to turn off other machines that are also powered by the UPS but not connected directly to it.
I initially tried setting this up by installing a CyberPower provided UPS linux utility (pwrstat) which does allow you to configure a set of commands that can automatically run when the system is shutting down due while on battery backup. However the utility is unable to communicate with the UPS.
The NUT client on the other hand works perfect. So assuming I stick with NUT, how do I configure the system to run some logic on power failure. Do I put a little script in rc0.d that tests certain parameters from the output of 'upsc ups' or is there a simpler / more elegant way to do things?