Experiences in the community

Just another WordPress.com weblog

Configuring APCUPS

Hi all,

First up one resource which I left out in the last entry was GNUWIN . The only problem with this resource its quite old. The only good thing about that one is you get to know of tools and applications which could help. Apart from that the project is quite dead :( Please be aware that this one is going to be a long long long one. Apologies for the same.

I was actually for a UPS as my old one didn’t give a good time anymore. This time though was looking for something which gave me some info. about battery power and stuff , preferably had a USB interface (easier) and GNU/Linux compatibility. Luckily came across APCUPS package in the repositories. A quick look-see at popcon made it clear that people are and were using it. Although having the graphs would have made it nicer.

Hence bought the unit. While reading the manual even this bit made lot of sense

Q: Why all the craziness with custom serial cables?
A: It was nothing more nor less than a form of customer control. For a long time APC wanted to keep other people from talking to its UPSes so it could lock out potential competition for its PowerChute software. Scrambling the leads on its serial cables was a cheap way to accomplish this – in fact, they tended to be wired so that if you tried a straight-through cable, opening a serial link to the UPS would be interpreted as a shutdown command!
(Hardware companies often think like this – they lock up interfaces by instinct, cornering a small market rather than growing a bigger one. It’s fundamentally stupid and self-defeating, but it’s the kind of stupid that tends to sound good at an executive meeting.)
Fortunately, APC has lost a lot of this attitude since about 2000; nowa-days they even release technical information to the apcupsd maintainers.
A much more interesting and active project is the APCUPSD (APCUPS Daemon) project on GNU/Linux.

From the homepage it says :-

Apcupsd is a program for monitoring UPSes and performing a graceful computer shutdown in the event of a power failure. It runs on Linux, Tru64, Mac OS/X, Win32, Solaris as well as other OSes.

Athough it took lot of time for me to understand the same (because of my stupidity) but here’s what I was able to do to get some information about the UPS I had bought. An APC BR800-IN BackUPS .  Although the GNOME Power-Manager is cool I found using APCUPSD to be much better atleast in finding more about my UPS . I forget many a times so putting the how-to just in case somebody also finds the same useful while doing the same. This how-to uses lot of guidance from the APCUPSD mailing list

Note :- GPM or the GNOME-Power-Manager is also able to accurately tell remaining battery power and stuff, its only incorrect in telling how much time for the battery to be fully charged but that’s a different thing.

The first step is obviously installing the apcupsd package .  Just a quick note, all the stuff has been done with APCUPSD version 3.14.4 on Ubuntu 8.10 (pre-release)

$ sudo apt-get install apcupsd

Now took me a long long time to understand the next step . I need to put the usb filesystem statement in /etc/fstab which is mentioned in the manual as well .

$ gksudo gedit /etc/fstab

add the line somewhere, if possible do some commenting so you know why or where you got the code from (this is what I usually do )

none /proc/bus/usb usbfs defaults 0 0

After that is done, one needs to check the contents of /proc/bus/usb/devices and the output should be something similar to what I got on one of the usb ports.

~$ cat /proc/bus/usb/devices

Output

T: Bus=02 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=1.5 MxCh= 0
D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=051d ProdID=0002 Rev= 1.06
S: Manufacturer=American Power Conversion
S: Product=Back-UPS BR 800 FW:9.o4 .I USB FW:o4
S: SerialNumber=some serial number
C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr= 24mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=usbhid

The only change I have done is serial number thing, which obviously I don’t feel like sharing ;)

Just to make sure that I am getting proper output also did

$ tail /var/log/messages

which gave me the following result

Oct 15 16:29:40 Mugglewille-desktop kernel: [ 3638.485058] usb 2-2:
configuration #1 chosen from 1 choice
Oct 15 16:29:40 Mugglewille-desktop kernel: [ 3639.112833]
hiddev96hidraw0: USB HID v1.10 Device [American Power Conversion
Back-UPS BR 800 FW:9.o4 .I USB FW:o4 ] on usb-0000:00:1d.1-2

Also did a ps grep to find the same

$ ps aux | grep usb

which got me the following result as well :-

root 1105 0.0 0.0 0 0 ? S< 00:15 0:00 [ksuspend_usbd]
root 5161 0.0 0.0 2964 776 ? S 00:16 0:03 hald-addon-hid-ups: listening on /dev/usb/hiddev0
shirish 23717 0.0 0.0 3240 800 pts/0 S+ 12:06 0:00 grep usb

The line we are looking for is the middle one :-

root 5161 0.0 0.0 2964 776 ? S 00:16 0:03 hald-addon-hid-ups: listening on /dev/usb/hiddev0

An alternative to the same would be also querying dmesg

$ dmesg | grep American

which should give you an output like :-

[ 6.402241] hiddev96hidraw0: USB HID v1.10 Device [American Power Conversion Back-UPS BR 800 FW:9.o4 .I USB FW:o4 ] on usb-0000:00:1d.1-2

This above just tells that the usb bus is able to see the UPS which is needed to be able to know more about the UPS in question.

The next thing to tackle is the configuration file which is installed at /etc/apcupsd/apcupsd.conf . The first basic thing which I follow is to make a backup of the file before doing any changes to the file.

$ sudo cp /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf.orig

Now we edit the the /etc/apcupsd/apcupsd.conf file and make the following value changes to :-


## apcupsd.conf v1.1 ##
UPSNAME Back-800
UPSCABLE usb
UPSTYPE usb
DEVICE
POLLTIME 60
LOCKFILE /var/lock

There are much more changes one can do but I just wanted to get the basic thing running.

Then one needs to reload the apcups daemon to make sure it is reading the new configuration and changes that have been made.

$ /etc/init.d/apcupsd restart

Then I tried to run

$ sudo /sbin/apcupsd

If there are no errors it means things are cool as well :)

Then I tried

sudo /sbin/apcaccess status

I ran into this error

Error contacting apcupsd @ localhost:3551: Connection refused

It took me sometime to realize I had to add some info. of the same at /etc/hosts.allow for this to function . So again first take a backup of the hosts.allow file.

$ sudo cp /etc/hosts.allow /etc/hosts.allow.orig

Then do the change therein by doing :-

$ gksudo gedit /etc/hosts.allow

and adding just this line :-

apcupsd: 127.0.0.0/255.0.0.0

Now when I ran the above command again it worked :-

sudo /sbin/apcaccess status

the result :-


APC : 001,044,1095
DATE : Sun Oct 26 12:47:32 IST 2008
HOSTNAME : Mugglewille-desktop
RELEASE : 3.14.4
VERSION : 3.14.4 (18 May 2008) debian
UPSNAME : Back-800
CABLE : USB Cable
MODEL : Back-UPS BR 800
UPSMODE : Stand Alone
STARTTIME: Sun Oct 26 01:15:03 IST 2008
STATUS : ONLINE
LINEV : 236.0 Volts
LOADPCT : 29.0 Percent Load Capacity
BCHARGE : 100.0 Percent
TIMELEFT : 28.1 Minutes
MBATTCHG : 3 Percent
MINTIMEL : 1 Minutes
MAXTIME : 120 Seconds
OUTPUTV : 230.0 Volts
SENSE : Medium
DWAKE : 000 Seconds
DSHUTD : 000 Seconds
LOTRANS : 194.0 Volts
HITRANS : 264.0 Volts
RETPCT : 000.0 Percent
ITEMP : 29.2 C Internal
ALARMDEL : Always
BATTV : 26.8 Volts
LINEFREQ : 49.0 Hz
LASTXFER : Automatic or explicit self test
NUMXFERS : 0
TONBATT : 0 seconds
CUMONBATT: 0 seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x07000008 Status Flag
SERIALNO : Some serial number
BATTDATE : 2001-09-25
NOMOUTV : 230 Volts
NOMINV : 230 Volts
NOMBATTV : 24.0 Volts
NOMPOWER : 540 Watts
FIRMWARE : 9.o4 .I USB FW:o4
APCMODEL : Back-UPS BR 800
END APC : Sun Oct 26 12:47:52 IST 2008

One can go much more further on, but this is the basics. One should also have a look at the e-book given for reference.

Huge huge thank you to the apcupsd folks for the program and the support given so far :)

Add to FacebookAdd to NewsvineAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Furl

About these ads

Single Post Navigation

7 thoughts on “Configuring APCUPS

Comment navigation

  1. Pingback: APC under Linux | API

  2. Pingback: Instalando un SAI de Back UPS de APC « Mi Raspberry Pi

  3. Pingback: Keopx » Instalacion y configurecion de SAI-UPS APC

Comment navigation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: