How to have NUT automatically power off a UPS before the monitoring system shuts down

networkingnutups

I've got NUT configured on a few systems in the following way: One host is connected to four UPSes via USB. That host is plugged into two of the four UPSes. Two other hosts are on the same rack, each plugged into one of the remaining UPSes. upsmon on the master only monitors the two UPSes relevant to powering that host, even though upsd is configured to communicate with all of them. upsmon on each of the slaves monitors the appropriate UPS attached to the master. I cannot have each slave directly attached to its UPS. (Those two hosts are VMware ESXis and the only NUT package I've found for them only contains upsmon.) (I also have another rack whose UPS configuration is sufficiently complicated that while I could have a setup where each UPS was directly attached to a host it powered, it makes for simpler cabling to have them all connected to a single host even if it doesn't draw power from all of them.)

My question is this: if the power goes out and one of the slaves' UPSes goes into low battery state, what is the best way to have the master power off the UPS as soon as the slave attached to it has shut down? I don't want to just wait for the master to shut down, because that leaves a window of time where the power might return but, because the slave's UPS never powered off, the slave's system will not see a power cycle and, thus, will not turn itself back on.

Best Answer

In my opinion the easiest way to handle this is to connect each UPS to its own host, then pass the USB through to a VM on that host which is a NUT master, and which has access to shut down the ESXi host through the VM APIs. That way there's no need to shut down the slaves from the master.