Monitoring UPS on SLE 10 SP1
This tip explains how to set up APC Back-UPS CS 500 on SLED 10 SP1. I am running critical services/applications on my desktop hence I wanted to be informed about every event related to power such as failure, recovery, battery status, etc.
I have to admit that I haven’t tested this solution on SLES however it’s supposed to work considering that they are more less the same (except package support).
The device doesn’t need any special treatment apart the USB cable being connected to one my USB ports.
I couldn’t get (default SuSE) “powerd” talking to my APC UPS so I first searched then I installed a specific product designed for APC systems. Note this package is in the SDK iso only:
geeko:~ # rpm -q apcupsd || yast -i apcupsd
We need to make some changes to the configuration located under /etc/apcupsd due to USB connection:
geeko:~ # grep . /etc/apcupsd/apcupsd.conf | grep -v ^# UPSCABLE usb UPSTYPE usb -snip-
The rest should be fine. The installer didn’t activate the service for auto start at boot which is good, the daemon has to be stopped for configuration testing. Now we can run “apctest” to check it out:
geeko:~ # apctest
2008-01-18 08:43:13 apctest 3.12.1 (06 January 2006) suse Checking configuration ... Attached to driver: usb sharenet.type = DISABLE cable.type = USB_CABLE You are using a USB cable type, so I'm entering USB test mode mode.type = USB_UPS Setting up the port ... Hello, this is the apcupsd Cable Test program. This part of apctest is for testing USB UPSes. Getting UPS capabilities...SUCCESS Please select the function you want to perform. 1) Test kill UPS power 2) Perform self-test 3) Read last self-test result 4) Change battery date 5) View battery date 6) View manufacturing date 7) Set alarm behavior 8) Quit Select function number: 8 2008-01-18 08:46:16 End apctest.
You can make minor changes, run various tests here. If you are happy with the results quit.
Set up the service for auto start at boot:
geeko:~ # insserv apcupsd && chkconfig -l apcupsd apcupsd 0:off 1:on 2:on 3:on 4:on 5:on 6:off
At last but not least start the service:
geeko:~ # rcapcupsd start Starting apcupsd power management done
What happens in case of a power failure?
- You get a console message on every console you logged in
- You get the event logged by syslog
- And you get an email as well for the event although it requires you to forward the “root” messages to your email.
Syslog entry looks like this after all:
Jan 18 07:21:32 geeko apcupsd[3322]: Power failure. Jan 18 07:21:38 geeko apcupsd[3322]: Running on UPS batteries. Jan 18 07:21:40 geeko apcupsd[3322]: Mains returned. No longer on UPS batteries. Jan 18 07:21:40 geeko apcupsd[3322]: Power is back. UPS running on mains.
Email forwarding: It can be your full email address, local account, etc:
geeko:~ # grep ^root /etc/aliases root: user@domain.co.nz
Build the alias table:
geeko:~ # newaliases /etc/aliases: 42 aliases, longest 17 bytes, 496 bytes total
Now you should be set. Sample email message:
Subject: geeko Power Failure !!! geeko Power Failure !!! APC : 001,041,1017 DATE : Fri Jan 18 07:21:37 NZDT 2008 HOSTNAME : geeko RELEASE : 3.12.1 VERSION : 3.12.1 (06 January 2006) suse UPSNAME : geeko CABLE : USB Cable MODEL : Back-UPS CS 500 UPSMODE : Stand Alone STARTTIME: Mon Jan 14 10:14:30 NZDT 2008 STATUS : ONBATT LINEV : 000.0 Volts LOADPCT : 12.0 Percent Load Capacity BCHARGE : 100.0 Percent TIMELEFT : 38.9 Minutes MBATTCHG : 5 Percent MINTIMEL : 3 Minutes MAXTIME : 0 Seconds OUTPUTV : 230.0 Volts DWAKE : 000 Seconds DSHUTD : 000 Seconds LOTRANS : 180.0 Volts HITRANS : 266.0 Volts RETPCT : 000.0 Percent ITEMP : 29.2 C Internal ALARMDEL : Always BATTV : 12.2 Volts LINEFREQ : 49.0 Hz LASTXFER : Low line voltage NUMXFERS : 1 XONBATT : Fri Jan 18 07:21:32 NZDT 2008 TONBATT : 7 seconds CUMONBATT: 7 seconds XOFFBATT : N/A SELFTEST : NO STATFLAG : 0x07060010 Status Flag SERIALNO : 4B0723P20525 BATTDATE : 2007-09-06 NOMBATTV : 12.0 FIRMWARE : 08.q8.I USB FW:q8 APCMODEL : Back-UPS CS 500 END APC : Fri Jan 18 07:21:39 NZDT 2008
Certainly you will receive message when the power is returned.
No comments yet