Apcupsd with Ubuntu Server 10.04

Ubuntu Linux Specific Guides
Post Reply
User avatar
dedwards
Site Admin
Posts: 69
Joined: Wed Mar 15, 2006 8:28 pm
Contact:

Apcupsd with Ubuntu Server 10.04

Post by dedwards » Wed Sep 29, 2010 9:09 pm

Apcupsd with Ubuntu Server 10.04

Ensure apcupsd is installed by issuing the following command:

Code: Select all

sudo apt-get install apcupsd


If it's installed the system will give you the following message:

Code: Select all

Reading package lists... Done
Building dependency tree
Reading state information... Done
apcupsd is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded.


If it's not installed, it will be installed automatically.

Next, ensure that your APC UPS is detected by your system:

Code: Select all

sudo lsusb -v


You should get an output similar to the one below:

Code: Select all

Bus 004 Device 002: ID 051d:0002 American Power Conversion Uninterruptible Power
 Supply
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0         8
  idVendor           0x051d American Power Conversion
  idProduct          0x0002 Uninterruptible Power Supply
  bcdDevice            0.06
  iManufacturer           3 American Power Conversion
  iProduct                1 Smart-UPS 2200 RM XL FW:690.18.D USB FW:7.4
  iSerial                 2 AS1003298418
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
 bDescriptorType         2
    wTotalLength           34
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration         11 1
    bmAttributes         0xe0
      Self Powered
      Remote Wakeup
    MaxPower               30mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      0 No Subclass
      bInterfaceProtocol      0 None
      iInterface              0
        HID Device Descriptor:
 bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength    1064
         Report Descriptors:
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0006  1x 6 bytes
        bInterval             100
Device Status:     0x0001
 Self Powered


The important lines are the following:

Code: Select all

iManufacturer           3 American Power Conversion
iProduct                1 Smart-UPS 2200 RM XL FW:690.18.D USB FW:7.4


The lines above should match the manufacturer and model number of your UPS. Lastly the following line should have content similar to the content below indicating that there is an HID device driver loaded for your UPS:

Code: Select all

HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode           33 US
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength    1064


If you don't get output similar to the output above, ensure you unplug/plug the USB cable of your UPS in the back of your computer and/or try rebooting your PC.

Next, edit the /etc/default/apcupsd file:

Code: Select all

sudo vi /etc/default/apcupsd


Change the "ISCONFIGURED=no" to "ISCONFIGURED=yes" without the quotes of course.

Next, edit the /etc/apcupsd/apcupsd.conf file:

Code: Select all

sudo vi /etc/apcupsd/apcupsd.conf


Ensure the following settings are set exactly as shown below:

Code: Select all

UPSCABLE usb
UPSTYPE usb
DEVICE
NETSERVER on
NISPORT 3551


Ensure there is nothing in front of the "DEVICE" parameter and ensure you do NOT comment it out.

Save the file and start apcupsd:

Code: Select all

sudo service apcupsd start


Ensure the apcupsd daemon is running:

Code: Select all

sudo ps -A|grep apc


You should get an output similar to the one below:

Code: Select all

5145 ?        00:00:00 apcupsd


Ensure apcupsd can communicate with the UPS:

Code: Select all

sudo apcaccess status


You should get an output similar to below:

Code: Select all

APC      : 001,041,1011
DATE     : Wed Sep 29 22:00:58 EDT 2010
HOSTNAME : nas2
VERSION  : 3.14.6 (16 May 2009) debian
UPSNAME  : nas2
CABLE    : USB Cable
MODEL    : Smart-UPS 2200 RM XL
UPSMODE  : Stand Alone
STARTTIME: Wed Sep 29 21:14:50 EDT 2010
STATUS   : ONLINE
LINEV    : 120.9 Volts
LOADPCT  :  25.3 Percent Load Capacity
BCHARGE  : 100.0 Percent
TIMELEFT :  53.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME  : 0 Seconds
OUTPUTV  : 120.9 Volts
SENSE    : High
DWAKE    : -01 Seconds
DSHUTD   : 090 Seconds
LOTRANS  : 106.0 Volts
HITRANS  : 127.0 Volts
RETPCT   : 000.0 Percent
ITEMP    : 18.9 C Internal
ALARMDEL : Always
BATTV    : 54.5 Volts
LINEFREQ : 60.0 Hz
LASTXFER : No transfers since turnon
NUMXFERS : 0
TONBATT  : 0 seconds
CUMONBATT: 0 seconds
XOFFBATT : N/A
SELFTEST : NO
STATFLAG : 0x07000008 Status Flag
SERIALNO : AS1003298418
BATTDATE : 2010-01-16
NOMOUTV  : 120 Volts
NOMBATTV :  48.0 Volts
FIRMWARE : 690.18.D USB FW:7.4
APCMODEL : Smart-UPS 2200 RM X
END APC  : Wed Sep 29 22:01:22 EDT 2010


You can adjust your power settings as you see fit. Most of the time, the default settings are sufficient.

Settings up email notifications

Settings up email notifications for apcupsd is pretty simple and straight forward. You must edit the following scripts in the /etc/apcupsd directory: changeme, commfailure, commok, offbattery and onbattery. You change the SYSADMIN and APCUPSD_MAIL parameters in every file to reflect your email address and the sendmail executable for your server:

Code: Select all

SYSADMIN=youremail@yourdomain.com
APCUPSD_MAIL="/usr/sbin/sendmail"
Post Reply