[Nut-upsuser] Possible to trigger commands based on slave disconnection?

Kevin P. Fleming kevin at km6g.us
Sun Nov 22 18:56:28 GMT 2020


Here's my situation:

APC Smart-UPS 750 powering a rack of equipment. Rack includes a NAS
(Debian-based) which is connected to the USB port of the UPS and is
happily running NUT. Rack also includes a router, switch, and various
other devices, including some Raspberry Pi computers which use the NAS
as their storage (via NFS) and are powered via PoE (from the switch).

When NUT tells the UPS to shut down, that of course will remove power
from everything in the rack. When mains power returns, the UPS will
apply power to everything in the rack. However, I *don't* want power
applied to the RPis, because the NAS takes quite some time (60-90
seconds) to fully boot, and they won't come up properly if they try
too early.

In addition, there is another RPi in another location, not connected
to this UPS, but which also uses the NAS as its file storage and thus
must be shut down if the NAS goes down.

At this point I have NUT running on all the systems, and they all
cleanly shut down when the UPS is heading into 'low battery' mode.
What I would like to additionally do is send commands to my network
switches to 'turn off the outlets' for the RPis (disable PoE on the
ports) as each one disconnects from the NUT master. I can do this over
SSH quite easily, if I can figure out a way to trigger the SSH command
to be executed.

I can also add commands to enable these ports in the NAS startup
sequence, at a point late enough for it to be safe.

So, the question is: is it possible on the NUT master to trigger a
command to be run when a slave disconnects? If so, I'd check the "FSD"
flag at that moment, and if the FSD flag is set then that means the
power is being shut down, so I should disable the PoE port for that
slave.

I'll also need some way to turn the port back on if NUT entered FSD
mode but then didn't actually shut down (due to mains power returning
before the shutdown sequence was completed), so that I don't leave the
RPis shut down.



More information about the Nut-upsuser mailing list