个人工具

UbuntuHelp:Apcupsd

来自Ubuntu中文

跳转至: 导航, 搜索


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.

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). 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 no of the ISCONFIGURED with a yes. 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. 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

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/apcuspd. 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