Monitor the UPS in Ubuntu with Network UPS Tools

I just found this great project called Network UPS Tools or nut . It comes with fully loaded with tools for monitoring local UPS, remote UPS and displaying the status via a weg page. My installation is using an Must PowerAgent 1060, connected via USB.

Installing the software is easy, just use the magic words:

sudo apt-get install nut nut-cgi

To configure nut on Ubuntu I start by reading this guide by a mysterious person named Shady Pixel.

First I checked my driver suitable for my model in the Hardware Compatibility List. The model I use is not in the list, but Must is related to Mustek and all Mustek models were using blazer_usb driver. So I went for blazer_usb.

I added the following section in /etc/nut/ups.conf (you can replace must-pa-1060 with your preferred name for the UPS):

# /etc/nut/ups.conf
    driver = blazer_usb
    port = auto

I looked for the Bus and Device number together with Vendor and Product in lsusb.

I changed the permission to 666 for /dev/bus/usb/BID/DID (replace BID with your USB bus ID, and DID with device ID). To automatically set the permission for future connections I added the following udev rule:

SYSFS{idVendor}=='0665', SYSFS{idProduct}=='5161', MODE='0666'

Then I started the UPS driver via:

$ sudo upsdrvctl start

If you get some errors like the one below, check the USB device permissions:

Can't claim USB device [0665:5161]: could not detach kernel driver from
interface 0: Operation not permitted
Driver failed to start (exit status=1)

Now that the UPS driver is started, lets monitor it and export the status via the CGI script.

You will have to configure the mode in which nut will run. Edit /etc/nut/nut.conf and add your preferred mode:

# /etc/nut/nut.conf

Add an UPS daemon user via /etc/nut/upsd.users:

# /etc/nut/upsd.users
password = a password here
upsmon master

Configure the monitor to connect to this daemon via /etc/nut/upsmon.conf:

# /etc/nut/upsmon.conf
MONITOR must-pa-1060@localhost 1 ups_admin the_password_here master

Now you can start the nut daemon and ups monitor via nut service:

sudo service nut start

To monitor the UPS via the web CGI script I added the following line to /etc/nut/hosts.conf:

# /etc/nut/hosts.conf
MONITOR must-pa-1060@localhost 'Must PowerAgent 1060'

Now you can access the CGI script via:



This should be a good start, and from here you can take it to the next level. For example, if you have 2 computers connected to the same UPS, the second one will have to monitor the UPS daemon from the one connected via the usb to the UPS make sure that the switch is allow connected to the UPS :)

blog comments powered by Disqus