There has been an old APC Back-UPS on the floor under the rack since before the mini PCs. It came from my parents' house, it beeps once a year during a storm, and I had never tested it. Last Sunday I pulled the plug on purpose.
It reported 100% charge and an estimated runtime of a bit over 30 minutes at about 80 W. It switched everything off after three minutes and ten seconds. The sticker on the battery says 2019. The lead-acid batteries in these things are good for three to five years, so this one is on me.
A new battery was 27 euros and took five minutes to swap. Same test afterwards: 24 minutes before I lost my nerve and plugged it back in, with 40% still showing.
Telling the cluster
The bigger problem was that nothing would have noticed anyway, because nothing was watching the UPS. Now its USB cable goes to m720q-1, which runs NUT as the server, and the other two nodes watch it over the network.
# /etc/nut/ups.conf on m720q-1
[apc]
driver = usbhid-ups
port = auto
# /etc/nut/nut.conf
MODE=netserver # netclient on the other two
# /etc/nut/upsmon.conf on m720q-1
MONITOR apc@localhost 1 upsmon-user xxxxxxxx primary
# ... and on m720q-2 / m720q-3
MONITOR apc@192.168.1.11 1 upsmon-user xxxxxxxx secondary
upsd also needs a LISTEN line in upsd.conf and the user in upsd.users with
upsmon primary. The example files in the Debian package have every option commented, which is better
documentation than most blog posts, this one included.
upsc apc@localhost ups.status # OL = on line, OB = on battery, LB = low battery
upsc apc@localhost battery.runtime # seconds, take it with salt
upscmd -l apc@localhost # what the UPS lets you do
The nodes shut down when the UPS reports low battery. With the new battery that still leaves a few minutes. I did one more pull-the-plug test with everything configured, and the boxes went down cleanly in the right order: the two secondaries first, then the one with the cable.
The Raspberry Pi doing DNS sits in the hallway on its own phone charger, not on the UPS. I know.