NUT (Network UPS Tools) can be used to turn off a computer while running on battery. This guide assumes Ubuntu (24), Eaton/HPE UPS connected with USB.
- Install Nut
sudo apt install nut
- Connect UPS and look for it.
lsusb | grep UPS- Bus 003 Device 008: ID 0463:ffff MGE UPS Systems UPS
- Declare UPS to NUT
sudo nano /etc/nut/ups.conf-
[hpe-ups] driver = "usbhid-ups" port = "auto" desc = "HPE T750 G5"
-
- Setup UDEV rules
sudo nano /etc/udev/rules.d/90-nut-ups.rules-
# HPE T750 G5 UPS (Eaton 5P750) ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0463", ATTR{idProduct}=="ffff", MODE="0660", GROUP="nut"
-
- Restart UDEV:
sudo service udev restart - Might need to install libusb:
sudo apt install libusb-1.0-0-dev
- Unplug and reconnect UPS USB
- Test with:
sudo upsdrvctl start-
Network UPS Tools - UPS driver controller 2.8.1 Network UPS Tools - Generic HID driver 0.52 (2.8.1) USB communication driver (libusb 1.0) 0.46 Using subdriver: MGE HID 1.46
-
- Configure NUT mode
sudo nano /etc/nut/nut.conf-
MODE=standalone
-
- There are other options if you want this to act as a server (netserver) that talks to clients (netclient), but this guide only covers standalone.
- Configure NUT daemon
sudo nano /etc/nut/upsd.conf-
LISTEN 127.0.0.1 3493
-
- Add users
sudo nano /etc/nut/upsd.users-
[upsmonitor] password = YOU_PLAINTEXT_PASSWORD_HERE upsmon master
-
- Configure behavior
sudo nano /etc/nut/upsmon.conf-
MONITOR hpe-ups@localhost 1 upsmonitor YOU_PLAINTEXT_PASSWORD_HERE master - The other defaults should be fine, but if you have a blank file, you also need:
-
POWERDOWNFLAG /etc/killpower SHUTDOWNCMD "/sbin/shutdown -h +0"
-
-
- Add security to config
sudo chown root:nut /etc/nut/*chmod 640 /etc/nut/*
- Check the status of services
sudo systemctl status upsd(If not started, start it; if not enabled, enable it)
- Restart and check the state of the ups.
sudo upsc hpe-ups@localhost-
Init SSL without certificate database battery.capacity: 7.20 battery.charge: 94 battery.charge.low: 20 ... ups.timer.start: -1 ups.type: offline / line interactive ups.vendorid: 0463
-
- If you want to change at what percent the poweroff is started make an override variable in
ups.conffor your UPS.override.battery.charge.low = 50- restart after edit:
sudo systemctl restart nut-server nut-monitor
- The true test
- Unplug the UPS, wait for the percent to drop below the value
battery.charge.lowas seen in step #12 output and see if your system shuts down.