This page describes the process of configuring an APC BackUPS Uninterrupted Power Supply (UPS) on FreeBSD.
Hardware/Software
- APC Back-UPS BX1000G
- FreeBSD port: apcupsd 3.14.8_2
- FreeBSD 8.2
- USB connection cable to the UPS
Installation
cd /usr/ports/sysutils/apcupsd
make config
┌────────────────────────────────────────────────────────────────────┐
│ Options for apcupsd 3.14.8_2 │
│ ┌────────────────────────────────────────────────────────────────┐ │
│ │[ ] APCSMART_DRV Compile APC SmartUPS serial driver │ │
│ │[X] APCDUMB_DRV Compile dumb UPS driver │ │
│ │[ ] CLIENT_ONLY Only NIS client (no network server or drivers)│ │
│ │[ ] CGI Compile with CGI programms to show status │ │
│ │[X] PCNET_DRV Compile PowerChute Network Shutdown driver │ │
│ │[X] USB Compile with USB Support driver │ │
│ │[ ] SNMP_DRV Compile with SNMP driver │ │
│ │[ ] SNMP_DRV_OLD Compile with old SNMP driver │ │
│ │[ ] TCP_WRAPPERS Compile with TCP_WRAPPERS support │ │
│ │[ ] TEST_DRV Compile TEST driver │ │
│ │[ ] GAPCMON Build GTK GUI front-end │ │
│ │ │ │
│ │ │ │
│ │ │ │
│ │ │ │
├─└────────────────────────────────────────────────────────────────┘─┤
│ [ OK ] Cancel │
└────────────────────────────────────────────────────────────────────┘
make install clean
Configuration
The following are the changes to my configuration file in diff format.
diff -u /usr/local/etc/apcupsd/apcupsd.conf.sample /usr/local/etc/apcupsd/apcupsd.conf
--- /usr/local/etc/apcupsd/apcupsd.conf.sample 2012-01-16 00:47:17.000000000 -0500
+++ /usr/local/etc/apcupsd/apcupsd.conf 2012-01-16 00:52:10.000000000 -0500
@@ -26,7 +26,7 @@
# 940-1524C, 940-0024G, 940-0095A, 940-0095B,
# 940-0095C, M-04-02-2000
#
-UPSCABLE smart
+UPSCABLE usb
# To get apcupsd to work, in addition to defining the cable
# above, you must also define a UPSTYPE, which corresponds to
@@ -73,8 +73,8 @@
# passphrase are the credentials for which the card
# has been configured.
#
-UPSTYPE apcsmart
-DEVICE /dev/usv
+UPSTYPE usb
+#DEVICE /dev/usv
# POLLTIME <int>
# Interval (in seconds) at which apcupsd polls the UPS for status. This
Start-up Configuration
vi /etc/rc.conf
apcupsd_enable="YES"
Start services
Manually start all services (or reboot):
/usr/local/etc/rc.d/apcupsd start
Check UPS Status
apcaccess status
The output should look something like this…
APC : 001,037,0944
DATE : 2012-01-16 00:56:22 -0500
HOSTNAME : prod.xxxx.com
VERSION : 3.14.8 (16 January 2010) freebsd
UPSNAME : prod.xxxx.com
CABLE : USB Cable
MODEL : Back-UPS BX1000G
UPSMODE : Stand Alone
STARTTIME: 2012-01-16 00:54:18 -0500
STATUS : ONLINE
LINEV : 123.0 Volts
LOADPCT : 31.0 Percent Load Capacity
BCHARGE : 100.0 Percent
TIMELEFT : 26.9 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME : 0 Seconds
SENSE : Medium
LOTRANS : 088.0 Volts
HITRANS : 139.0 Volts
ALARMDEL : Always
BATTV : 27.2 Volts
LASTXFER : No transfers since turnon
NUMXFERS : 0
TONBATT : 0 seconds
CUMONBATT: 0 seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x07000008 Status Flag
MANDATE : 2011-10-02
SERIALNO : 3B1140X37672
BATTDATE : 2011-10-02
NOMINV : 120 Volts
NOMBATTV : 24.0 Volts
NOMPOWER : 600 Watts
FIRMWARE : 869.L2 .D USB FW:L2
APCMODEL : Back-UPS BX1000G
END APC : 2012-01-16 00:56:24 -0500
Testing the UPS
Testing the UPS involves actually pulling the cord and observing the system gracefully shut down.
Procedure
- Edit the /usr/local/etc/apcupsd/apcupsd.conf and set TIMEOUT 60. This will allow the system to shut down 60 seconds after the power is cut. Testing it this way prevents wear on the battery life.
- restart the daemon (/usr/local/etc/rc.d/apcupsd restart)
- pull the plug and 60 seconds later the system should initiate the shut-down.
- restore the power to the system. After the system comes back, Look for clues of a successful shut-down. On my server after the system comes back I observe the /var/messages and the MySQL logs since they indicate when they have been shut-down successfully. Compare the outputs with outputs of previous shut-downs.
Here is the output of my test:
After pulling the cord I got the following message on the console.
Broadcast Message from xxx@prod.xxxx.com
(no tty) at 11:29 EST...
Power failure. Running on UPS batteries.
A minute later:
Broadcast Message from xxxx@prod.xxxx.com
(no tty) at 11:30 EST...
UPS battery runtime limit exceeded. Doing shutdown.
Broadcast Message from xxxx@prod.xxxx.com
(no tty) at 11:30 EST...
Beginning Shutdown Sequence
*** FINAL System shutdown message from xxxx@prod.xxxx.com ***
System going down IMMEDIATELY
apcupsd initiated shutdown
After the system came back I got the following in the
/var/messages
Jan 16 11:29:09 prod apcupsd[3062]: Power failure.
Jan 16 11:29:15 prod apcupsd[3062]: Running on UPS batteries.
Jan 16 11:30:16 prod apcupsd[3062]: Reached run time limit on batteries.
Jan 16 11:30:16 prod apcupsd[3062]: Initiating system shutdown!
Jan 16 11:30:16 prod apcupsd[3062]: User logins prohibited
Jan 16 11:30:16 prod apcupsd[3062]: Attempting to kill the UPS power!
Jan 16 11:30:16 prod shutdown: halt by xxxx: apcupsd initiated shutdown
Jan 16 11:30:25 prod squid[1375]: Squid Parent: child process 1377 exited with status 0
Jan 16 11:30:32 prod apcupsd[3062]: apcupsd exiting, signal 15
Jan 16 11:30:32 prod apcupsd[3062]: apcupsd shutdown succeeded
Jan 16 11:30:33 prod syslogd: exiting on signal 15
Looks like everything is in order… After your test is complete, don’t forget to restore the TIMEOUT value to the original.
Leave a small note below with the make and model of your UPS and version of FreeBSD to let me know it worked for you!
Thanks.
References:
This page is a variation of a page originally written by Julien Gabel back in 2006: http://blog.thilelli.net/post/2006/07/09/Configuring-an-APC-Back-UPS-RS-800VA