Skip to content

Instantly share code, notes, and snippets.

@tylerebowers
Last active January 1, 2026 00:54
Show Gist options
  • Select an option

  • Save tylerebowers/56fb5208e6e2aacbc38159c4a8e3e1e1 to your computer and use it in GitHub Desktop.

Select an option

Save tylerebowers/56fb5208e6e2aacbc38159c4a8e3e1e1 to your computer and use it in GitHub Desktop.
Using NUT in Ubuntu with Eaton or HPE UPS via USB

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.

  1. Install Nut
  • sudo apt install nut
  1. Connect UPS and look for it.
  • lsusb | grep UPS
    • Bus 003 Device 008: ID 0463:ffff MGE UPS Systems UPS
  1. Declare UPS to NUT
  • sudo nano /etc/nut/ups.conf
    • [hpe-ups]
        driver = "usbhid-ups"
        port = "auto"
        desc = "HPE T750 G5"
      
  1. 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
  1. 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
      
  1. 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.
  1. Configure NUT daemon
  • sudo nano /etc/nut/upsd.conf
    • LISTEN 127.0.0.1 3493
      
  1. Add users
  • sudo nano /etc/nut/upsd.users
    • [upsmonitor] password = YOU_PLAINTEXT_PASSWORD_HERE
      upsmon master
      
  1. 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"
        
  1. Add security to config
  • sudo chown root:nut /etc/nut/*
  • chmod 640 /etc/nut/*
  1. Check the status of services
  • sudo systemctl status upsd (If not started, start it; if not enabled, enable it)
  1. 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 inups.conf for your UPS.
    • override.battery.charge.low = 50
    • restart after edit: sudo systemctl restart nut-server nut-monitor
  1. The true test
  • Unplug the UPS, wait for the percent to drop below the value battery.charge.low as seen in step #12 output and see if your system shuts down.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment