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
If you are connecting your 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 your machine is connected to the UPS directly and you want to run NUT on this machine.

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

/etc/nut/upsd.users
You need to 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 your UPS.

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

/etc/nut/upssched.conf
You need to configure operations on that upsmon will check on the status of your UPS.

OpenRC
To add the services to start on system boot:

To start now run:

Check the status of your ups manually. Note that you might have to adjust your UPS name for this work.

OL means that your UPS is "online" and not drawing from the battery. It also means that you configured the above files correctly.

If you want nut to power off your UPS when it shuts down your system in a power failure, you must add nut.powerfail to your shutdown runlevel:

Server configuration
Starting from standalone configuration, change:

/etc/nut/ups.conf
This file is not needed for slave monitor, so you can leave blank or full of comments.

/etc/nut/upsd.conf
This file is not needed for slave monitor, so you can leave blank or full of comments.

/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, you need only upsmon service. To add the services to start on system boot:

To start now run:

Check the status of your ups manually. Note that you might have to adjust your UPS name for this work.

External resources

 * Official user manual
 * Detailed NUT Configuration