Skip to content

Instantly share code, notes, and snippets.

@cam8001
Last active October 29, 2024 08:53
Show Gist options
  • Save cam8001/56e265173baab66c5e17ab24fdbc7cdc to your computer and use it in GitHub Desktop.
Save cam8001/56e265173baab66c5e17ab24fdbc7cdc to your computer and use it in GitHub Desktop.
Set up Eaton 5e UPS on Ubuntu Noble 24.04

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment