1. Installation
First step is to install Network UPS Tools package :

# apt-get install nut
2. Connect your UPS
Once your UPS is powered and connected to a USB port of your server, it should be detected :

# lsusb | grep UPS
Bus 004 Device 010: ID 0463:ffff MGE UPS Systems UPS
We can notice that UPS is from MGE, former name of Eaton.

This command has given us the Vendor ID and Device ID of your USB connected UPS.

Vendor ID : 0463
Device ID : ffff
These important values will be used later in the installation procedure.

3. Configuration
Its now time to declare the Eaton UPS to nut daemon.

As the UPS is connected via USB, we wil use the USB driver.

This is done by adding a new section to /etc/nut/ups.conf to declare your UPS.

driver = usbhid-ups
port = auto
desc = "Eaton 3S 550"

4. Start USB driver
Now that your UPS is declared to nut, it’s time to start the USB UPS driver upsdrvctl :

# upsdrvctl start
Network UPS Tools – UPS driver controller 2.6.4
Network UPS Tools – Generic HID driver 0.37 (2.6.4)
USB communication driver 0.32
Can’t claim USB device [0463:ffff]: could not detach kernel driver from interface 0: Operation not permitted
Driver failed to start (exit status=1)
This doesn’t look good.

Error comes from the fact that nut daemon is running as nut user, which is not allowed to access USB interface (accessible only by root).

The best way to allow nut user to access the UPS USB device, is to declare a new udev rules.

The udev rule will use the Vendor ID and Device ID of your USB UPS.

Il will allow accounts from nut group to access the USB device with 660 permission rather than 666, since that should be sufficient and more secure.

To declare the rule, you just have to create /etc/udev/rules.d/90-nut-ups.rules :

# Eaton 3S 550
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0463", ATTR{idProduct}=="ffff", MODE="0660", GROUP="nut"
You now need to restart udev for the rule to become operational :

# service udev restart
You need to disconnect and reconnect the USB cable to remount it with the new udev rule.

You should now be able to start upsdrvctl UPS driver without error.

# upsdrvctl start
Network UPS Tools – UPS driver controller 2.6.4
Network UPS Tools – Generic HID driver 0.37 (2.6.4)
USB communication driver 0.32
Using subdriver: MGE HID 1.31
5. Configure NUT mode
nut can run in different mode according to your configuration :

none (default)

We must configure nut in standalone mode as it will address a local only configuration, with 1 UPS protecting the local system. This will start the 3 nut layers (driver, upsd and upsmon).

This standalone mode is declared in /etc/nut/nut.conf :


Next step is to configure upsd and upsmon :

upsd communicates with the UPS driver that we just started
upsmon communicates with upsd and actually shuts down the machine in the event of a power failure.
Why this extra level of indirection ?

Just because multiple instances of upsmon can be started on different machines and communicate with a single uspd in charge of the physical UPS device.

6. Configure UPS daemon
As upsd will be used locally on the server, we will configure it to listen on localhost and default port 3493. Configuration will be done for IPv4 and IPv6.

Edit or create configuration file /etc/nut/upsd.conf :


LISTEN ::1 3493

Next, we should create a local upsmonitor user for upsd.It will be used by upsmon to interact with upsd.

This local user is declared in /etc/nut/upsd.users :

password = YOUR_PASSWORD
upsmon master

Replace YOUR_PASSWORD with a real password.

7. Configure UPS monitor
Once user has been declared in upsd, it should be declared to upsmon.

This declaration is done thru /etc/nut/upsmon.conf :

# Commands for shutdown on power loss
MONITOR eaton@localhost 1 upsmonitor YOUR_PASSWORD master
POWERDOWNFLAG /etc/killpower
SHUTDOWNCMD "/sbin/shutdown -h now"

eaton is the name you’ve given to your UPS in /etc/nut/ups.conf and YOUR_PASSWORD with the password you set in /etc/nut/upsd.users.

If you want, you can also change the shutdown command that will be used when the UPS battery will go below a minimum level.

8. Secure configuration
Since these UPS configuration files contain sensitive data (you can shutdown the server …), we should fix the permissions to allow only root user and nut group to access them.

# chown root:nut /etc/nut/*
# chmod 640 /etc/nut/*

9. Test connection
Everything should now be in place to test your UPS connectivity.

To test it, you just need to start upsd daemon and to inquire your UPS status with upsc client.

# upsd

Network UPS Tools upsd 2.6.4
fopen /var/run/nut/ No such file or directory
listening on ::1 port 3493
listening on port 3493
Connected to UPS [eaton]: usbhid-ups-eaton
# upsc eaton@localhost
battery.charge: 89
battery.charge.low: 20

Now that service is running, you can reboot your debian computer.

After next reboot, service nut-server should have been started.

You should be able to access your UPS data.

# upsc eaton@localhost

battery.charge: 89
battery.charge.low: 10

As soon as your UPS charge will go under 10%, a shutdown signal will be issued to your server.