NUT

Do you have a UPS? Do you want to have you system gracefully shutdown in case of a power outage? This guide will show how you can make the most out of your UPS by using NUT from the Network UPS Tools project

USE flag
To connect a UPS via USB, make sure to set the  USE flag:

Configuration standalone
Search a UPS with nut-scanner:

Take note of driver name and port type for configuration file.

If UPS is connected via USB port, add user nut to group usb.

/etc/nut/nut.conf
Set mode to standalone if the machine is connected to the UPS directly and to run NUT on this machine.

/etc/nut/ups.conf
The main UPS configuration file. Make sure that the UPS name (the text in the brackets) doesn't have any spaces. For configuration specific to the UPS you need to look it up here: NUT Hardware Compatibility Lookup

/etc/nut/upsd.users
Configure at least one user so that upsmon can be launched later. will create a TCP connection that upsmon will use to check on the status of the UPS.

/etc/nut/upsmon.conf
Create a MONITOR configuration in :

/etc/nut/upssched.conf
Configure operations on that upsmon will check on the status of the UPS:

OpenRC
To add the services to start on system boot:

To start now run:

To check the status of the UPS manually (adjust the UPS name as needed):

OL means that the UPS is "online" and not drawing from the battery and is configured correctly.

In the event of a shutdown due to a power failure, nut can additionally turn off the UPS by adding nut.powerfail to the shutdown runlevel:

Server configuration
Starting from standalone configuration, change:

/etc/nut/ups.conf
This file is not needed for slave monitor.

/etc/nut/upsd.conf
This file is not needed for slave monitor.

/etc/nut/upsmon.conf
Copy the standalone configuration, but create a different MONITOR configuration in :

/etc/nut/upssched.conf
This file can be the same of standalone configuration.

/usr/bin/upssched-cmd
This file can be the same of standalone configuration.

Client services
On client machine, only the upsmon service is needed. To add the services to start on system boot:

To start now run:

To check the status of the UPS manually (adjust the UPS name as needed):

External resources

 * Official user manual
 * Detailed NUT Configuration