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-cgiTo 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 [must-pa-1060] driver = blazer_usb port = autoI 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:
#/etc/udev/rules.d/10-must-pa-1060.rules SYSFS{idVendor}=='0665', SYSFS{idProduct}=='5161', MODE='0666'Then I started the UPS driver via:
$ sudo upsdrvctl startIf 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 MODE=standaloneAdd an UPS daemon user via /etc/nut/upsd.users:
# /etc/nut/upsd.users [ups_admin] password = a password here upsmon masterConfigure 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 masterNow you can start the nut daemon and ups monitor via nut service:
sudo service nut startTo 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:
http://HOSTNAME/cgi-bin/nut/upsstats.cgiEnjoy!
Source: Adi Roiban – Monitor the UPS in Ubuntu with Network UPS Tools