Ubuntu uses a service, Network UPS Tools (NUT), to monitor UPSes and take given actions when they send signals.
The Eaton 5e is not a network UPS, its USB. This is what I needed to do to set it up.
$ sudo apt install nut nut-client
For whatever reason, I didn't have USB libraries on my install of 24.04. So:
$ sudo apt install libusb-1.0-0-dev
Now you have the prereqs in place, four things need to be configured.
/etc/nut/nut.conf
- set MODE
to standalone
- "1 UPS protecting the local system"
/etc/nut/ups.conf
- this is where you let NUT know what device you are working with. In my case, I added the below:
[eaton5e]
driver = usbhid-ups
port = auto
desc = "Eaton 5E UPS"
/etc/nut/upsd.users
- "Users" that can access the UPS to monitor or control it. Possibly makes more sense for a network attached UPS.
[upsmon]
password = yourpassword
upsmon master
/etc/nut//upsmon.conf
- Actions taken in response to monitoring. First, add this to the bottom of the file:
MONITOR eaton5e@localhost 1 upsmon yourpassword master
Now to a sanity check to make sure all those configs line up:
$ upsc eaton5e
You should see a bunch of config keys which tell you the status of the UPS.
If that is all good, add a shutdown command to upsmon.conf
:
SHUTDOWNCMD "echo \"Shutting down due to UPS detecting loss of power...\" && /sbin/shutdown -h now"
Now enable some systemd services:
sudo systemctl enable --now nut-driver-enumerator.service
sudo systemctl enable --now nut-server.service
sudo systemctl enable --now nut-monitor.service
Now you should be good. Dance all night