Last modified: Jun. 10, 2010
Contents
1 - Summary
2 - Dependencies
3 - Apcupsd installation
4 - Service configuration
5 - Apcaccess example
6 - Service check
1 - Summary
This guide will show you how to install apcupsd in Red Hat Enterprise Linux.
Apcupsd is used for power management and controlling of APC UPS's. This has
been tested in Red Hat Enterprise Linux 4 and 5.
2 - Dependencies
Install the following dependencies. Type the following in Red Hat Enterprise
Linux 4.
# sudo /usr/sbin/up2date net-snmp-libs
Password:
# sudo /usr/sbin/up2date lm_sensors
Password:
# sudo /usr/sbin/up2date net-snmp
Password:
Type the following in Red Hat Enterprise Linux 5.
# sudo yum install net-snmp-libs
Password:
# sudo yum install lm_sensors
Password:
# sudo yum install net-snmp
Password:
Download the msmtp RPM package from the ScopServer mirror and then install it.
Msmtp is an SMTP client used to sent email. We will use it to send email
notifications.
# wget http://mirrors.scopserv.com/dist/packages/msmtp/msmtp-$ver.$dist.scopserv.$arch.rpm
# sudo rpm -ivh msmtp-*
Password:
# rm -f msmtp-*
You will also need some information about the UPS and the UPS cable.
Model number
UPS cable type
The serial port or USB ports will need to be enabled in the BIOS of the
computer. You can find out the serial port or USB port information by typing
out the following.
# dmesg | grep -iE "(tty|American Power Conversion)"
serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
00:09: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
In this case we are using the serial port.
3 - Apcupsd installation
Apcupsd can be downloaded at http://www.apcupsd.org/. Download and install
the Red Hat RPM package.
# cd ~
# wget http://$mirror.sourceforge.net/sourceforge/apcupsd/apcupsd-*.$rel.$arch.rpm
# sudo rpm -ivh apcupsd-*.$rel.$arch.rpm
Password:
4 - Service configuration
Find where the apcupsd daemon was installed to.
# rpm -ql apcupsd-* | grep sbin
/sbin/apcaccess
/sbin/apctest
/sbin/apcupsd
/sbin/smtp
# rpm -ql apcupsd-* | grep rc.d
/etc/rc.d/init.d/apcupsd
Enable the apcupsd service so that it will start when the system starts up.
# sudo /sbin/chkconfig apcupsd on
Password:
# sudo /sbin/chkconfig --list apcupsd
Password:
apcupsd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
Find where the configuration file should be put.
# grep apcupsd.conf /etc/rc.d/init.d/apcupsd
daemon /sbin/apcupsd -f /etc/apcupsd/apcupsd.conf
# sudo strings /sbin/apcupsd | grep apcupsd.conf
Password:
Cannot perform killpower without authentication data. Please set ip:user:pass for DEVICE in apcupsd.conf.
## apcupsd.conf v1.1 ##
/etc/apcupsd/apcupsd.conf
You can modify the apccontrol script to send email notifications for different
UPS events.
# rpm -ql apcupsd-* | grep apccontrol
/etc/apcupsd/apccontrol
/usr/share/man/man8/apccontrol.8.gz
# sudo cp /etc/apcupsd/apccontrol /etc/apcupsd/apccontrol.example
Password:
# sudo vi /etc/apcupsd/apccontrol
Password:
You can create your own configuration file. Here is a simple example. This
uses an APC UPS 940-0095A serial cable.
## apcupsd.conf v1.1 ##
UPSCABLE 940-0095A
UPSTYPE apcsmart
DEVICE /dev/ttyS0
LOCKFILE /var/lock
UPSCLASS standalone
UPSMODE disable
# rpm -ql apcupsd-* | grep apcupsd.conf
/etc/apcupsd/apcupsd.conf
/usr/share/man/man5/apcupsd.conf.5.gz
# sudo cp /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf.example
Password:
# sudo vi /etc/apcupsd/apcupsd.conf
Password:
You will need to configure SELinux appropriately. SELinux status can be
found by running sestatus. Also, make sure that if you have firewall software
on the server to allow tcp port 3551 traffic in.
# sudo /usr/sbin/sestatus | grep status:
Password:
SELinux status: enabled
Start the apcupsd service.
# sudo /sbin/service apcupsd start
Password:
Starting UPS monitoring:[ OK ]
# sudo /sbin/service apcupsd status | head -n 1
Password:
apcupsd (pid 14749) is running...
5 - Apcaccess example
This command prints the UPS model number, software version, status, load
percentage, battery charge and other information.
# /sbin/apcaccess status localhost
APC : 001,050,1206
DATE : 2010-06-08 12:52:08 -0500
HOSTNAME : server.test.com
VERSION : 3.14.8 (16 January 2010) redhat
UPSNAME : UPS_IDEN
CABLE : APC Cable 940-0095A
MODEL : Smart-UPS 750
UPSMODE : Stand Alone
STARTTIME: 2010-06-08 12:51:52 -0500
STATUS : ONLINE
LINEV : 120.2 Volts
LOADPCT : 6.5 Percent Load Capacity
BCHARGE : 100.0 Percent
TIMELEFT : 121.0 Minutes
MBATTCHG : 10 Percent
MINTIMEL : 5 Minutes
MAXTIME : 0 Seconds
MAXLINEV : 120.2 Volts
MINLINEV : 119.5 Volts
OUTPUTV : 120.2 Volts
SENSE : High
DWAKE : 000 Seconds
DSHUTD : 090 Seconds
DLOWBATT : 02 Minutes
LOTRANS : 106.0 Volts
HITRANS : 127.0 Volts
RETPCT : 000.0 Percent
ITEMP : 22.5 C Internal
ALARMDEL : 5 seconds
BATTV : 27.1 Volts
LINEFREQ : 60.0 Hz
LASTXFER : Line voltage notch or spike
NUMXFERS : 0
TONBATT : 0 seconds
CUMONBATT: 0 seconds
XOFFBATT : N/A
SELFTEST : NO
STESTI : 336
STATFLAG : 0x07000008 Status Flag
REG1 : 0x00 Register 1
REG2 : 0x00 Register 2
REG3 : 0x00 Register 3
MANDATE : 09/15/05
SERIALNO : QS0538143065
BATTDATE : 09/15/05
NOMOUTV : 120 Volts
NOMBATTV : 24.0 Volts
EXTBATTS : 0
FIRMWARE : 651.12.D
APCMODEL : FWD
END APC : 2010-06-08 12:52:13 -0500
6 - Service check
Reboot your computer. Log in like normal and check to see that the apcupsd
service is running. That's it, now you have apcupsd running in Red Hat
Enterprise Linux.
# sudo /sbin/shutdown -r now
Password:
# sudo /sbin/service apcupsd status | head -n 1
Password:
apcupsd (pid 1964) is running...
|