Today a client had a power outage. Although the PBX in a Flash (PiaF) server was on an Uninterruptible Power Supply (UPS), the outage lasted long enough that the PiaF server crashed. Twice. Time to brave the waters of installing UPS monitoring software under Linux.
The version of PiaF that I’m using is based on CentOS 5.2, which is derived from Red Hat Enterprise Linux 5.2. APC PowerChute Business Edition supports Linux if you are using their higher-end SmartUPS line, but there is no support for BackUPS-type UPSs.
Google and open source to the rescue! It didn’t take long to find the APC UPS Daemon, also called apcupsd. What did take a while was figuring out which version I needed and how to get it installed and working. Fortunately there is an extensive and well-written manual. Here is a summary of the steps I took to get it running:
Update October 8, 2012 See below for an easier install method!
- Although I won’t be using SNMP, the pre-built “rpm” binary for apcupd requires that SNMP be installed. Log on to the PiaF box (I use Putty) and run this command to install it:
yum install net-snmp
- Download the appropriate installation binary from SourceForge. I decided that I needed
apcupsd-3.14.5-1.el5.i386.rpm, the version for x86 processors and Enterprise Linux 5. I used WinSCP to copy that to a new folder on my PiaF machine called
- On the PiaF box, run the following commands to install the apcupsd software:
rpm -ivh apcupsd-3.14.5-1.el5.i386.rpm
- Now edit the file
/etc/apcupsd/apcupsd.confand test your configuration. There are some instructions in the conf file itself, but you’ll probably want to refer to the manual, starting with the “After Installation” section. My local PBX is actually connected as a “dumb” slave to a SmartUPS, a fairly unusual arrangement. For that, I found the following configuration options seem to work (only showing the non-default entries):
UPSCABLE 940-0020B# Cable number from the end of the gray, dumb signaling cable
DEVICE /dev/ttyS1# ttyS0 = COM1; ttyS1 = COM2
TIMEOUT 900# Needed for dumb signaling. I allow a fixed 15 minutes before shutdown.
UPSCLASS shareslave# Because we are connected on the “dumb” side of a ShareUPS card.
UPSMODE disable# The default. I think this would only be “share” if we were a “sharemaster”
While testing this, I saw that apcupsd tried to shut down my UPS, which would have been bad since my Small Business Server is connected to the same UPS. The dumb signaling apparently prevented this level of control, so no UPS shutdown occurred, but to be safe, I followed the advice in the manual and commented out the lines added by apcupsd to
/etc/rc.d/init.d/halt. They’re easy to spot–they all end in #
Update September 16, 2011 Added to another PiaF box today. Current version is
apcupsd-3.14.8-1.el5.i386.rpm. This time I’m using a USB cable on a BackUPS unit, so I was able to keep most of defaults in the
apcupsd.conf file. The manual has helpful instructions for post-installation testing. Useful status/testing commands:
apcaccess – show current UPS status, battery percent remaining, etc.
service apcupsd stop – stop the daemon, required before
apctest – menu of commands e.g. self-test, alarm mode, etc.
service apcupsd start – (re)start the daemon
Update October 8, 2012 Setting up a new PiaF box running CentOS 6.2. Decided to try the suggestion in Derek’s 12/9/2011 comment here, but adapted for CentOS 6:
rpm -ihv http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-7.noarch.rpm
yum install apcupsd
(The first line wraps in text but type it all on one line.) Basically that sets up the Fedora Extra Packages for Enterprise Linux (EPEL) repository and lets you install from that using yum.
Update October 18, 2012 For some reason, perhaps due to the yum install method, apcupsd was not starting with the system:
chkconfig | grep apcupsd
=>apcupsd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
So I ran this to make it auto-start:
chkconfig apcupsd on
chkconfig | grep apcupsd
=>apcupsd 0:off 1:off 2:on 3:on 4:on 5:on 6:off