On a Debian server I've successfully installed the nut
package so that my Ellipse PRO 1200 UPS's status can be fetched via USB (upsc my-ups
returns battery level).
Note: I haven't tested what will happens when a power outage occurs yet.
This UPS serves power to other devices than this Debian server: some routers/switches and a NAS.
In this case, considering how I think NUT works, I should install NUT on the NAS and declare it as a NUT slave, this way the Debian server (NUT master) would order the NAS to shutdown when battery are low and then shut itself down.
The problem is that I cannot install NUT on the NAS (OS is not supported), but I can SSH to it an tell it to shutdown.
How/where can I place my own script(s) alongside with what NUT would normally run to order it's slave to shutdown?
The only place I could find is SHUTDOWNCMD
in /etc/nut/upsmon.conf file:
SHUTDOWNCMD "/sbin/shutdown -h +0"
I'm guessing I could replace this command with a hand-made script that would run that SSH-shutdown-command and ends by shutdowning the Debian server too.
Problem is SHUTDOWNCMD
seems to be meant for last-time actions: when battery is very low. Contacting all the other devices in my own script could take more time than I have before running out of battery.
Thanks
Best Answer
You could try using
upssched.conf(5)
to run your own script on a timer after an event has fired.A basic
upssched.conf
would be something like this:With this, NUT will:
/bin/your-script.sh emailonbatt
./bin/your-script.sh upsonbatt
./bin/your-script.sh emailonline
.upsonbatt
timer if it is still active. Otherwise, run/bin/your-script.sh upsonline
.The script could be something like:
The syntax for the AT statement can be found in the man page for
upssched.conf(5)
, and the notify event types available can be found in the man page forupsmon(8)
.