Cheap VPS & Xen Server

Residential Proxy Network - Hourly & Monthly Packages

Network UPS Tools (NUT) For USB UPSs On CentOS 5.5


This tutorial shows how to configure and use Network UPS Tools (NUT) software with an USB (Uninterruptible Power Supply) on CentOS 5.5. NUT is a software which supports several thousand models. To check if your UPS is supported, this is the link to the HCL: http://www.networkupstools.org/stable-hcl.html

Install NUT dependencies:

yum install net-snmp-libs gd httpd

Download the latest CentOS NUT rpm release for your architecture from: http://geekery.blog.com/category/linux/nut-ups-rpms/

NOTE: you can also download NUT from EPEL repository or the tarball directly from the NUT official site (http://www.networkupstools.org/)

Install downloaded rpms:

rpm -Uvh nut-2.6.0-2geekery.$(uname -i).rpm nut-cgi-2.6.0-2geekery.$(uname -i).rpm nut-client-2.6.0-2geekery.$(uname -i).rpm powerman-2.3.5-2geekery.$(uname -i).rpm

 

Common Configuration

This is the configuration for my Eaton Powerware 5115 USB UPS. Edit the driver controller configuration file, choosing the correct driver for your UPS. You can read on the HCL which is the right driver to use. My UPS it isn’t officially supported, but I found that the bcmxcp_usb driver works well, so I defined a new UPS section that begins with the name of the UPS in brackets (in my case: 5115), followed by the driver (bcmxcp_usb) and the port device (with USB UPSs choose automatic port detection).

vi /etc/ups/ups.conf

[5115]
        driver = bcmxcp_usb
        port = auto

Now choose your NUT running mode: I chose standalone mode because the UPS is power supplying only one server, but you can also use NUT in network client/server mode.

vi /etc/ups/nut.conf

MODE = standalone

Configure the IP address and port where upsd daemon listens for. The upsd.conf file control access to the server and some other parameters. In a standalone installation you can leave it at default configuration, listening to localhost.

vi /etc/ups/upsd.conf

LISTEN 127.0.0.1 3493

Now define a upsmon user/password in upsd.users file. The user I define is “local_mon” with password “PASSWORD” and upsmon role “master”. We will use this user with the upsmon component of NUT.

vi /etc/ups/upsd.users

[local_mon]
    password = PASSWORD
    upsmon master

Upsmon is the UPS monitor and shutdown controller that will monitor and tell how to shut down the system when necessary. Edit the MONITOR directive inserting the UPS name defined in ups.conf, followed by the IP address or hostname configured in upsd.conf and by the credentials and upsmon role defined in upsd.users. Leave the other directives to the default values specified.

vi /etc/ups/upsmon.conf

MONITOR 5115@localhost 1 local_mon PASSWORD master
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5

 

USB Configuration

If you you installed a NUT rpm release from http://geekery.blog.com/category/linux/nut-ups-rpms/ you can find a nut udev rule file for CentOS at this path: /lib/udev/rules.d/62-nut-usbups.rules

If you are installing a USB UPS, softlink this file in udev rules directory:

ln -s /lib/udev/rules.d/62-nut-usbups.rules /etc/udev/rules.d/62-nut-usbups.rules

and reload udev rules and trigger device detection with these commands:

udevcontrol reload_rules

udevtrigger

UPS Web Monitoring (nut-cgi)

Configure this file to let CGI programs access the UPS info:

vi /etc/ups/hosts.conf

MONITOR 5115@localhost 1 local_mon PASSWORD master

Create a Apache config file for the cgi installed with the nut-cgi package:

vi /etc/httpd/conf.d/ups-cgi.conf

ScriptAlias /nut-cgi-bin/ "/var/www/nut-cgi-bin/"
<Directory "/var/www/nut-cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

 

Start UPS Daemon

Now you can try to start your NUT installation with this command:

/etc/init.d/ups start

If the start process is OK, check ups info with this command (use your ups.conf ups name instead of 5115):

upsc 5115

You can also check which instant command are supported by your UPS with this command:

upscmd -l 5115@localhost

Instant commands supported on UPS [5115]:
shutdown.return - Turn off the load and return when power is back
shutdown.stayoff - Turn off the load and remain off
test.battery.start - Start a battery test

You can start a battery test (if supported) with this command:

upscmd -u local_mon -p PASSWORD 5115 test.battery.start

You can also check the web monitoring page with a web browser: http://<upshost>/nut-cgi-bin/upsstats.cgi

 

Troubleshooting For Common USB Problems

If nut has problems to start check logs:

cat /var/log/messages

Many problems with USB UPSs are related to udev and device rights permission.

1) If you see these messages in /var/log/messages

udevd[513]: add_to_rules: unknown key 'ATTR{idProduct}'
udevd[513]: add_to_rules: unknown key 'ATTR{idVendor}'
udevd[513]: add_to_rules: unknown key 'ATTR{idProduct}'
udevd[513]: add_to_rules: unknown key 'SUBSYSTEMS'

You have a udev rule file that uses directives newer than the udev program version you have.

On CentOS 5.5 try to substitute “ATTR” with “SYSFS” and “SUBSYSTEMS” with “BUS”.

In the “ACTION” directive use only “add” not “change”:

	OK:	ACTION!="add", GOTO="nut-usbups_rules_end"
	ERROR:	ACTION!="add|change", GOTO="nut-usbups_rules_end"

2) Check usb device right permissions: Run the lsusb command:

lsusb

Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000
Bus 003 Device 005: ID 06da:0002 Phoenixtec Power Co., Ltd UPS
Bus 003 Device 001: ID 0000:0000
Bus 004 Device 001: ID 0000:0000
Bus 005 Device 001: ID 0000:0000
Bus 006 Device 001: ID 0000:0000
Bus 007 Device 001: ID 0000:0000

You can see from the preceding output that my usb ups is connected to the usb bus 3 device 5 and has this VendorID=06da and ProductID=0002

Grep VendorID and ProductID from nut udev rule file to see if your ups has already a rule to manage it:

grep “06da” /etc/udev/rules.d/62-nut-usbups.rules | grep 0002

SYSFS{idVendor}=="06da", SYSFS{idProduct}=="0002", MODE="664", GROUP="uucp"

I found that a rule is already present in the udev rule file: it sets file mode 664 and group ownership to uucp group to the usb device linked to the ups.

If a rule is not present for your device, copy the one above and changing VendorID and ProductID with those you found with lsusb command.

Check that device permissions are set like udev rule specify:

ls -l /dev/bus/usb/003/005

crw-rw-r– 1 root uucp 189, 260 Mar 23 23:06 /dev/bus/usb/003/005

Comments

comments