Packetwatch.net

Apcupsd in FreeBSD



Last modified: Mar. 13, 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 FreeBSD. Apcupsd is used
for power management and controlling of APC UPS's. This has been tested in
FreeBSD 7.2 and 8.0.


2 - Dependencies

Install the msmtp packge. Msmtp is an SMTP client used to send email. We will
use it to send email notifications.
# sudo pkg_add -r msmtp
Password:

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. In FreeBSD 8.0 uart is used instead of sio.
# dmesg | grep -E "(sio[0-9]|uart[0-9]|American Power Conversion)"
uart0: <16550 or compatible> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
uart0: [FILTER]

In this case we are using the serial port.


3 - Apcupsd installation

Install the apcupsd package.
# sudo pkg_add -r apcupsd
Password:


4 - Service configuration

Find where the apcupsd daemon was installed to.
# pkg_info -L apcupsd-* | grep sbin
/usr/local/sbin/apcupsd
/usr/local/sbin/apcaccess
/usr/local/sbin/apctest
/usr/local/sbin/smtp

Edit /etc/rc.conf.local so that the apcupsd service will start when the
system starts up. Somewhere in the file add the following.
  apcupsd_enable="YES"
# sudo vi /etc/rc.conf.local
Password:

Find where the configuration file should be put.
# grep apcupsd.conf /usr/local/etc/rc.d/apcupsd 
required_files="/usr/local/etc/apcupsd/apcupsd.conf"
# sudo strings /usr/local/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 ##
/usr/local/etc/apcupsd/apcupsd.conf

You can modify the apccontrol script to send email notifications for different
UPS events.
# pkg_info -L apcupsd-* | grep apccontrol
/usr/local/etc/apcupsd/apccontrol
# sudo cp /usr/local/etc/apcupsd/apccontrol /usr/local/etc/apcupsd/apccontrol.example
Password:
# sudo vi /usr/local/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. In FreeBSD /dev/cuau0 is used instead
of /dev/cuad0.
  ## apcupsd.conf v1.1 ##
  UPSCABLE 940-0095A
  UPSTYPE apcsmart
  DEVICE /dev/cuau0
  LOCKFILE /var/spool/lock
  UPSCLASS standalone
  UPSMODE disable
# pkg_info -L apcupsd-* | grep apcupsd.conf
/usr/local/etc/apcupsd/apcupsd.conf.sample
# sudo cp /usr/local/etc/apcupsd/apcupsd.conf.sample /usr/local/etc/apcupsd/apcupsd.conf
Password:
# sudo cp /usr/local/etc/apcupsd/apcupsd.conf /usr/local/etc/apcupsd/apcupsd.conf.example
Password:
# sudo vi /usr/local/etc/apcupsd/apcupsd.conf
Password:

Start the apcupsd service.
# sudo /usr/local/etc/rc.d/apcupsd start
Password:
Starting apcupsd.
# sudo /usr/local/etc/rc.d/apcupsd status
Password:
apcupsd is running as pid 994.


5 - Apcaccess example

This command prints the UPS model number, software version, status, load
percentage, battery charge and other information.
# /usr/local/sbin/apcaccess status localhost
APC      : 001,051,1236
DATE     : Sat Mar 13 09:00:16 CST 2010
HOSTNAME : server.test.com
RELEASE  : 3.14.5
VERSION  : 3.14.5 (10 January 2009) freebsd
UPSNAME  : UPS_IDEN
CABLE    : APC Cable 940-0095A
MODEL    : Smart-UPS 750
UPSMODE  : Stand Alone
STARTTIME: Sat Mar 13 08:57:58 CST 2010
STATUS   : ONLINE 
LINEV    : 119.5 Volts
LOADPCT  :  21.4 Percent Load Capacity
BCHARGE  : 100.0 Percent
TIMELEFT :  52.0 Minutes
MBATTCHG : 10 Percent
MINTIMEL : 5 Minutes
MAXTIME  : 0 Seconds
MAXLINEV : 119.5 Volts
MINLINEV : 118.8 Volts
OUTPUTV  : 119.5 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    : 28.3 C Internal
ALARMDEL : 5 seconds
BATTV    : 27.1 Volts
LINEFREQ : 60.0 Hz
LASTXFER : Automatic or explicit self test
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  : Sat Mar 13 09:00:48 CST 2010


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 FreeBSD.
# sudo shutdown -r now
Password:
# sudo /usr/local/etc/rc.d/apcupsd status
Password:
apcupsd is running as pid 619.


Last modified: Thu Jan 1 00:00:00 1970 UTC
Packetwatch Research 2002-2024.