Apcupsd is the daemon which will monitor your UPS to shutdown the system when the UPS' power is going to fail. The homepage for apcupsd, http://www.apcupsd.com/, has very helpful documentation for doing complicated setups.

Quick Install for USB-based APC units

  • install the daemon: apt-get install apcupsd
  • edit /etc/apcupsd/apcupsd.conf and change these lines
    • UPSNAME myownups
    • UPSCABLE usb
    • UPSTYPE usb
    • comment out DEVICE (it contains a TTY link, which will prevent it from working)
  • edit /etc/default/apcupsd
    • change ISCONFIGURED from no to yes
  • /etc/init.d/apcupsd start
  • apcaccess status

Prerequsites

  • An APC UPS. Apcupsd works with most of APC's Smart-UPS models as well as most simple signalling models such a Back-UPS, and BackUPS-Office.

Installation

First of all, we have to install apcupsd package. Install the apcupsd package in the Synaptic Package Manager. See SynapticHowto. If you want to see the stat of the UPS through the browser, you can also install apcupsd-cgi package.

Edit the file /etc/apcupsd/apcupsd.conf which by default includes good comments on usage:

  • For UPSCABLE you have to specify the type of cable connecting the UPS to your computer. Read the comments in the file to see which possibilities you have. For example, if the UPS used is the APC Back-UPS ES 700V, you have to write usb.

  • You must also look for and modify the UPSTYPE. The comments in the file describes the different possibilities available. You may choose the appropriate one. Again, from our example of an APC Back-UPS ES 700V, you would write usb.

  • The final setting you must fix is DEVICE. As the comments note, with a usb type UPS apcupsd can autodetect the device, so you should comment out the DEVICE setting (by putting a '#' in front of it or leave it blank). Otherwise, you will need to know which /dev node your device is connected to. If your UPS cable is a serial type then your device may be something like /dev/ttyS0.

Then you must edit the file /etc/default/apcupsd and change the ISCONFIGURED no to ISCONFIGURED yes.

Then start apcupsd with the follwoing command:

#sudo /etc/init.d/apcupsd start

Once you have apcupsd configured, running and the device connected to your computer you will be able to check on the status of the device using the apcaccess command.

#apcaccess status

# Output from the command will vary based on the type of UPS you have. Most likely, the better the UPS the more detailed the information you will get.

Optionally, if you want your computer to reboot after a power fail, you must edit the /etc/init.d/halt due a bug that it has. You must change the poweroff="-p" with poweroff=""

The following applies to Drapper Drake (LTS 6.06), but does not apply to most Ubuntu default setups, where /usr is simply part of the root filesystem. You only need to do this if the /usr filesystem has a separate entry in /etc/fstab:

  • You need to uncomment the line 10 in file "/etc/apcupsd/killpower" which means changing "mount -n -o ro /usr" to "mount -n -o ro /usr"
  • This will ensure that the shared libraries libcrypto.so.0.9.8, libnetsnmp.so.9, libstdc++.so.6 and libz.so.1 are visible to apcupsd after shutdown when it runs "/etc/apcupsd/apccontrol killpower" to shut off the ups power otherwise the UPS will stay on and your system will not automatically reboot when utility power returns.

apcupsd-cgi via Apache

The following changes to a Ubuntu system should allow APCUPSD-CGI web interface to be accessible. Note that for this to work you MUST have Apache2 installed and configured properly for your Ubuntu system.

Start by installing the apcupsd-cgi package with:

sudo apt-get install apcupsd-cgi

This will drop several files into /usr/lib/cgi-bin/apcupsd.

For this to work you MUST have CGI enabled in your Apache configuration and the CGI directory should be pointed at /usr/lib/cgi-bin/

The only thing left is to go to the web address:

http://localhost/cgi-bin/apcupsd/multimon.cgi


apcupsd-cgi via Webmin

The following changes to a Ubuntu system will allow APCUPSD-CGI web interface to be accessible as a module using webmin. Note that for this to work you MUST have webmin installed and configured properly for your Ubuntu system. Note: To install webmin in under 2 minutes (the best 2 min investment you will ever make) click http://www.webmin.com/deb.html and follow the instructions under Using the Webmin APT repository

Start by installing the apcupsd-cgi package with:

#sudo apt-get install apcupsd-cgi

This will drop several files into /usr/lib/cgi-bin/apcupsd.

Then copy the contents of /usr/lib/cgi-bin/apcuspd/ to /etc/apcupsd/

#sudo cp /usr/lib/cgi-bin/apcupsd/*.cgi /etc/apcupsd/

Now log into webmin from your browser, usually https://localhost:10000

Go to "Webmin->Webmin Configuration" from the left hand menu and click on "Webmin Modules"

Click "Third party module from" and enter http://diego.caravana.to/wp-content/apcupsd0.812.wbm.gz into the address box to the right and then click on the install module button

The only thing left is to click on "APC UPS Daemon" under "Other" from the left menu in Webmin.

All the above tested on Ubuntu 12.04 using an APC BACKUP ES700

Enjoy! - Spart


apcupsd (last edited 2013-11-19 15:51:07 by adriankoooo)