APC SmartUPS daemon for Linux

Posted on August 30, 2006

advertisement

Recently we bought a new APC UPS SmartUPS 2200. Originally [tag]APC[/tag] [tag]UPS[/tag] came together with PowerChute Business Edition Basic software.

Basically you have to install “The PowerChute Business Edition Agent” on the [tag]Linux[/tag] machine which is compatible with Red Hat 7.3, Red Hat 8.0, Red Hat 9.0, SuSE 8.0, SuSE 8.1, SuSE 8.2, Turbolinux 7.0, and Turbolinux 8.0 according to the readme file in the CD.

Launch the PowerChute Business Edition for Linux installer by entering the absolute path to the pbe_agent_redhat_jvm.bin file.

/media/cdrom/Linux/pbe_agent_linux_jvm.bin

An RPM package of the [tag]PowerChute[/tag] Business Edition Agent for Linux is also available.


rpm ivh /media/cdrom/Linux/pbeagent-xxx.i386.rpm

Once the powerchute business edition agent has been installed, you must configure the Agent for login information and the UPS type. This is handled by running the config.sh script located within the PowerChute Business Edition installation directory.

This utility allows you to create an account name and password, and to configure the UPS by entering the communication type and communication port. After completing the configuration, you may start the PowerChute Business Edition Agent.

But I found this ’solution’ is not good in Linux environment because you have to install PowerChute Business Edition Server & Console for allow connect to any Linux Server installed with PowerChute Business Edition agent.

APC UPS

Check here for more screen shot.

Anyway, there is an open source of APC UPS daemon for Linux release under GPL license.

Apcupsd can be used for power mangement and controlling most of APC’s UPS models on Unix and Windows machines. [tag]Apcupsd[/tag] works with most of APC’s Smart-UPS models as well as most simple signalling models such a Back-UPS, and BackUPS-Office. During a power failure, apcupsd will inform the users about the power failure and that a shutdown may occur. If power is not restored, a system shutdown will follow when the battery is exhausted, a timeout (seconds) expires, or runtime expires based on internal APC calculations determined by power consumption rates.

There are 3 types of configuration:
1)Standalone Configuration
2)Typical Master/Slave Configuration
3)Multi-UPS Configuration

The configuration here is for Typical Master/Slave Configuration ( few servers connect to 1 physical UPS & only master server connect with serial cable)

Download latest apcupsd from SourceForge

Installation from Source:

Run ./configure --enable-master-slave --enable-cgi
make
make install

A Simple Master Configuration


vi /etc/apcupsd/apcupsd.conf
UPSCABLE smart
UPSTYPE apcsmart
DEVICE /dev/ttyS0
LOCKFILE /var/lock
UPSCLASS netmaster
UPSMODE net
NETTIME 10
NETPORT 6666
SLAVE slave1.yournetwork.com
SLAVE slave2.yournetwork.com

A Simple Slave Configuration


vi /etc/apcupsd/apcupsd.conf
UPSCABLE ether
UPSTYPE apcsmart
LOCKFILE /var/lock
UPSCLASS netslave
UPSMODE net
NETPORT 6666
MASTER master.mynetwork.com

Start the apcupsd service

/etc/init.d/apcupsd start OR service apcupsd start

The main difference from the master configuration is that you have specified UPSCABLE ether and UPSCLASS netslave.
In this configuration, the shutdown will be initiated by the master. It is also possible to specify BATTERYLEVEL, MINUTES, and TIMEOUT configuration directives in the Slave machine that will cause the slave to shutdown before the master. This can often be useful if the slave is less important than the master and you wish to reduce battery power consumption so that the master can remain up longer during a power outage.

Testing Apcupsd


MASTER:
[root@planetmy apcupsd]# tail -f /var/log/apcupsd.events
Mon Aug 27 14:48:23 MYT 2006  Power failure.
Mon Aug 27 14:48:30 MYT 2006  Running on UPS batteries.
Mon Aug 27 14:48:38 MYT 2006  Mains returned.
No longer on UPS batteries.
Mon Aug 27 14:48:38 MYT 2006  Power is back.
UPS running on mains.
Mon Aug 27 14:48:43 MYT 2006  Power failure.
Mon Aug 27 14:48:50 MYT 2006  Running on UPS batteries.
Mon Aug 27 14:49:11 MYT 2006  Mains returned.
No longer on UPS batteries.
Mon Aug 27 14:49:11 MYT 2006  Power is back.
UPS running on mains.
Mon Aug 27 14::51 MYT 2006  Connect to slave
slave1.yournetwork.com succeeded

Apcupsd status from Master
[root@planetmy apcupsd]# /etc/init.d/apcupsd status
APC      : 001,053,1314
DATE     : Tue Aug 27 15:26:09 MYT 2006
HOSTNAME : master.yournetwork.com
RELEASE  : 3.12.4
VERSION  : 3.12.4 (19 August 2006) redhat
UPSNAME  : SmartUPS
CABLE    : Custom Cable Smart
MODEL    : Smart-UPS 2200 RM
UPSMODE  : Net Master
STARTTIME: Mon Aug 27 15:26:16 MYT 2006
SHARE    : NetworkUPS
STATUS   : ONLINE
LINEV    : 244.8 Volts
LOADPCT  :   7.8 Percent Load Capacity
BCHARGE  : 100.0 Percent
TIMELEFT : 102.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 30 Minutes
MAXTIME  : 0 Seconds
MAXLINEV : 244.8 Volts
MINLINEV : 243.3 Volts
OUTPUTV  : 244.8 Volts
SENSE    : High
DWAKE    : 000 Seconds
DSHUTD   : 180 Seconds
DLOWBATT : 02 Minutes
LOTRANS  : 208.0 Volts
HITRANS  : 253.0 Volts
RETPCT   : 000.0 Percent
ITEMP    : 31.0 C Internal
ALARMDEL : 5 seconds
BATTV    : 54.8 Volts
LINEFREQ : 50.0 Hz
LASTXFER : Line voltage notch or spike
NUMXFERS : 2
XONBATT  : Mon Aug 27 15:48:43 MYT 2006
TONBATT  : 0 seconds
CUMONBATT: 43 seconds
XOFFBATT : Mon Aug 27 15:49:11 MYT 2006
SELFTEST : NO
STESTI   : 336
STATFLAG : 0x07000008 Status Flag
REG1     : 0x00 Register 1
REG2     : 0x00 Register 2
REG3     : 0x00 Register 3
MANDATE  : 01/28/06
SERIALNO : JS0605026196
BATTDATE : 01/28/06
NOMOUTV  : 230
NOMBATTV :  48.0
EXTBATTS : 0
FIRMWARE : 665.6.I
APCMODEL : FWI
END APC  : Tue Aug 28 15:36:35 MYT 2006

SLAVE:
[root@slave1 apcupsd]$ tail -f /var/log/apcupsd.events
Mon Aug 27 14:48:50 MYT 2006  Mains returned.
No longer on UPS batteries.
Mon Aug 27 14:48:50 MYT 2006  Power is back.
UPS running on mains.
Mon Aug 27 14:49:02 MYT 2006  Power failure.
Mon Aug 27 14:49:08 MYT 2006  Running on UPS batteries.
Mon Aug 27 14:49:24 MYT 2006  Mains returned.
No longer on UPS batteries.
Mon Aug 27 14:49:24 MYT 2006  Power is back.
UPS running on mains.
Mon Aug 27 14:49:31 MYT 2006  apcupsd exiting, signal 15
Tue Aug 29 14:49:31 MYT 2006  apcupsd shutdown succeeded
Tue Aug 29 14:49:46 MYT 2006  apcupsd 3.12.4 (19 August 2006)
redhat startup succeeded
Tue Aug 29 14:49:51 MYT 2006  Connect from master
master.yournetwork.com succeeded

Apcupsd status from Slave
[root@slave1 apcupsd]#/etc/init.d/apcupsd status
APC      : 001,023,0613
DATE     : Tue Aug 27 08:36:05 MYT 2006
HOSTNAME : slave1.yournetwork.com
RELEASE  : 3.12.4
VERSION  : 3.12.4 (19 August 2006) redhat
CABLE    : Ethernet Link
MODEL    : Network Slave
UPSMODE  : Net Slave
STARTTIME: Tue Aug 27 08:35:46 MYT 2006
SHARE    : NetworkUPS
MASTERUPD: Tue Aug 27 10:25:07 MYT 2006
MASTER   : master.yournetwork.com
STATUS   : ONLINE SLAVE
BCHARGE  : 100.0 Percent
TIMELEFT : 102.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 45 Minutes
MAXTIME  : 0 Seconds
NUMXFERS : 0
TONBATT  : 0 seconds
CUMONBATT: 0 seconds
XOFFBATT : N/A
STATFLAG : 0x07000408 Status Flag
END APC  : Tue Aug 27 10:25:26 MYT 2006

Setting up and Testing the CGI Programs

Before using multimon and the other CGI programs, first ensure that apcupsd is configured to run the Network Information Server. This is done by setting NETSERVER on in /etc/apcupsd/apcupsd.conf.

Edit the hosts file /etc/apcupsd/hosts.conf & add the name of the hosts you want to monitor and a label string for them.

MONITOR 127.0.0.1 “master.yournetwork.com”
MONITOR 192.168.1.2 “slave1.yournetwork.com”
MONITOR 192.168.1.3 “slave2.yournetwork.com”

Copy “multimon.cgi “, “upsimage.cgi”, “upsfstats.cgi”, “upsstats.cgi” from /etc/apcupsd to /var/www/cgi-bin/

Restart Apache.

Open your favorite browser:
http:///cgi-bin/multimon.cgi

Note: Remember check your firewall for open TCP port 6666

Gongratulation! You’re done!

Please refer to online documentation for more features :)

Possibly Related Posts:


Comments

One Response to “APC SmartUPS daemon for Linux”

  1. APC SmartUPS daemon for Linux « Bloggitation on August 30th, 2006 3:59 pm

    [...] read more | digg story [...]

Leave a Reply




Planet Malaysia

  • Follow us on Twitter


  • web www.planetmy.com