Have you tried using NUT?I have a rackmount UPS in mys server setup. But getting it to shutdown my VM's in ESXi over the network connection is making me want to bang my head against a wall because the new software version seems to require a always online management server in running under windows to make it work. But as for using it for outside of ESXi thier software seems to work pretty great from what ive heard. My UPS has saved me alot of trouble with my server by allowing to to handle brownouts and it regulates the voltage full time so I always know my stuff is getting clean power.
Have a VM / container run the NUT server, then all the VMs/containers run a nut client. The server sends the shutdown commands to all the clients.