Andrew Mercer
on this page

NUT monitors a UPS and can shut machines down before the battery runs out.

Install and find your driver

sudo apt-get install nut          # Debian/Ubuntu;  sudo dnf install nut  on RHEL family

If apcupsd is installed, it conflicts with NUT. Check the hardware compatibility list for your model's driver (USB UPSes usually use usbhid-ups). Connect the UPS to the server (USB or serial) first.

Configure (standalone mode)

Standalone mode means one UPS protecting the local host.

/etc/ups/nut.conf:

MODE=standalone

/etc/ups/ups.conf, defining the UPS:

[myups]
    driver = usbhid-ups
    port = auto
    desc = "Rack UPS"

/etc/ups/upsd.users, with a user for upsmon:

[monuser]
    password = <a-long-random-password>
    upsmon master

/etc/ups/upsmon.conf:

MONITOR myups@localhost 1 monuser <a-long-random-password> master

Keep these files readable only by root and the nut group (chmod 640, chown root:nut).

Start and test

sudo systemctl enable --now nut-driver.service nut-server.service nut-monitor.service
upsc myups                          # dump all variables (battery.charge, ups.status, ...)
upsc myups ups.status               # OL = on line, OB = on battery, LB = low battery
sudo upsdrvctl start                # start the driver by hand when debugging

On older systems the units are nut-driver, nut-server, and nut-monitor, or a single nut service. Unit names vary by distribution.

Troubleshooting

  • "Driver not connected" or USB access errors: install libusb runtime libraries and check udev permissions for the USB device (the nut package normally installs the rules; replug the UPS after installing).
  • "No UPS type set - see help text / man page!": the driver line is missing or the section name in ups.conf does not match what upsmon.conf monitors.