Long overdue project, but the "replace battery" alarm of my old acquired from computer surplus store UPS finally spurred me to action. Twenty dollars worth of sealed lead acid batteries from Battery Mart, a $10 APC 940-0024 DB-9 cable from an Amazon.com seller (I mentioned that this was an old UPS right?) and a bit of duct tape later and I have new batteries in the UPS and have the signaling cable connected to my ESXi host.
In an ideal world, I'd have a networked UPS that can signal all of my little home lab that the power is out and things should shutdown. In the real world, I don't have that. Enter APCUPSD, your standard Open Source solution for monitoring an APC UPS.
I shut down my Ubuntu Linux management virtual machine and passed through the ESXi host's serial port to the VM. A VM boot and a few tweaks to the apcupsd.conf later and APCUPSD running on a Linux VM is talking to the APC SmartUPS connected to the host.
APCUPSD has a built in network information server that allows other computers running APCUPSD to check in with the UPS status. And APCUPSD has support for Linux, Mac OS X, and Windows. A quick package policy in my Ubuntu Landscape Dedicated Server (more on that another day) and apcupsd is installed on my Linux virtual machines. A quick install on a couple Windows machines (including my gaming desktop) and APCUPSD is talking over the network to my management VM, ready to shut down VMs as the UPS runs out of batter power.
So if you don't have a fancy network UPS, this kind of setup is the next best thing. If you have clustered hypervisors, a TCP/IP to serial adapter or even a Raspberry Pi setup to run APCUPSD could get the job done.
Shortfall is while my Linux and Windows virtual machines as well as the physical machines on the same UPS will now all cleanly shutdown, my ESXi host won't cleanly shutdown. Looks like some scripting on the machine running APCUPSD that reaches out to ESXi and runs the ESXi shutdown is the preferred solution in this scenario. That's for another day, for now at least the VMs with critical data won't be running.