Using apcupsd to Trigger Ubuntu Shutdown from UPS

At work they just gave everyone a UPS for their office: APC BK650-AS. It comes with a cable that plugs into a USB port on your computer allowing the status of the UPS to be used to trigger a shutdown (or other actions) of your computer. Also included was a free version of the APCs PowerChute software for Windows and MAC. Supposedely there is a Linux version of PowerChute, but a quick search reveals apcupsd provides all necessary features for Linux.

Heres what I did to configure apcupsd after plugging in the cable.

  1. Install the software:
    $ sudo apt-get install apcupsd
    
  2. Configure the daemon by editing /etc/apcupsd/apcupsd.conf:
    UPSNAME SteveUPS
    UPSCABLE usb
    UPSTYPE usb
    # DEVICE
    
  3. Allow access on localhost by editing /etc/hosts.allow:
    apcupsd: 127.0.0.0/255.0.0.0
    
  4. You can check that the UPS is detected by looking at system messages:
    $ tail /var/log/messages
    Aug 26 12:49:24 ginger kernel: [ 3456.772911] generic-usb 0003:051D:0002.0005: 
    hiddev96,hidraw0: USB HID v1.10 Device [American Power Conversion Back-UPS CS 650 
    FW:817.v6.I USB FW:v6] on usb-0000:00:1d.0-1/input0
    
  5. Restart the daemon:
    $ sudo /etc/init.d/apcupsd restart
    
  6. Check the status:
    $ apcaccess status