Apcupsd UPS Monitoring Daemon

Introduction

CSE runs apcupsd to monitor the status of our APC UPS systems. The software monitors the UPS, and takes action when events occur (power failure, low battery, etc). Typically, these actions are to notify the staff via email. If the battery levels fall below a defined threshold, the apcupsd daemon attempts to shut down the server.

Since our UPSs generally are in cabinets and support multiple systems, the server that is monitoring the UPS needs to communicate to the other systems in the cabinet and tell them about UPS events. In this case, the monitoring system is called the master, and the other servers are slaves. We can call a master and its slaves a "UPS group". It is important that when equipment is moved from one UPS to another that the appropriate UPS group changes are made as well.

Installation

FreeBSD

  1. Install the /usr/ports/sysutils/apcupsd port.
  2. Edit /etc/hosts.allow and add "apcupsd: 128.205.32.0/255.255.255.0 : allow".
  3. Follow the configuration steps to set up your base configuration files. The FreeBSD config files should be placed in /usr/local/etc/apcupsd.
  4. If this is a master server, make sure that the UPS is connected to the correct serial port, and then run sudo apctest. It should successfully connect to the UPS and display a menu. If not, check your serial port settings. Then display all of the UPS settings, and make sure you are getting back meaningful information. If all looks well, we're ready to bring up the daemon.
  5. When configured, edit /etc/rc.conf and add the line apcupsd_enable=YES to bring up the daemons at boot time.
  6. Run /usr/local/etc/rc.d/apcupsd start, and make sure the daemon comes up.
  7. Run apcaccess status. It should display similar information as when you ran apctest, but this time your talking to the daemon.

Solaris

  1. Run sudo make install from /src/local/apcupsd-3.10.13.
  2. Follow the configuration steps to set up your base configuration files. The Solaris config files should be placed in /etc/opt/apcupsd. I didn't want them there, but it REALLY did.
  3. If this is a master server, make sure that the UPS is connected to the correct serial port, and then run sudo apctest. It should successfully connect to the UPS, and display a menu. If not, check your serial port settings. Then display all of the UPS settings, and make sure you are getting back meaningful information. If all looks well, we're ready to bring up the daemon.
  4. Look at /src/local/apcupsd-3.10.13/README.solaris for special tweaks. In particular, see the modifications to /sbin/rc0. The install process adds an init.d script as well as K & S scripts to bring the daemon up during boot.
  5. Run /etc/init.d/apcupsd start, and make sure the daemon comes up.
  6. Run apcaccess status. It should display similar information as when you ran apctest, but this time your talking to the daemon.

Windows

Normally, you will install the Windows version of apcupsd from the binaries. This install is somewhat Unix like since you do many parts of the installation by hand. To install the binaries, you need WinZip.

  1. Download the latest stable winapcupsd-X.X.X.exe binary and double-click it.
  2. When Zip says that it has one file and asks if it should unpack it into a temporary file, respond with Yes.
  3. Ensure that you extract all files and that the extraction will go into C:\
  4. If you wish to install the package elsewhere, please note that you will need to proceed with a manual installation, which is not particularly easy as you must rebuild the source and change the configuration file as well.

    This installation assumes that you do not have CYGWIN installed on your computer. If you do, and you use mount points, you may need to do a special manual installation.

  5. Once you have unzipped the binaries, open a window pointing to the binary installation folder (normally c:\apcupsd). This folder should contain folders with the name bin, etc, examples, and manual. If and when you no longer need them, the examples and manual sub-folders of the c:\apcupsd directory may be removed.
  6. Open the directory c:\apcupsd\etc\apcupsd in the Windows Explorer by Clicking on the apcupsd folder then on the etc folder, then on the apcupsd folder. Finally double click on the file apcupsd.conf and edit it to contain the values appropriate for your site. In most cases, no changes will be needed, but if you are not using COM1 for your serial port, you will need to set the DEVICE configuration directive to the correct serial port. (See the CSE master and slave apcupsd config files, attached below)
  7. Then return to c:\apcupsd and open on the bin folder so that you see its contents.
  8. To do the final step of installation, double click on the setup.bat program. This script will setup the appropriate mount points for the directories that apcupsd uses, it will install apcupsd in the system registry.

    If everything went well, you will get something similar to the following output in a DOS shell window:

    What is important to verify in the DOS window is that the root directory \ is mounted on device c:\.

    The DOS window will be followed immediately by a Windows dialogue box as follows:

  1. On Windows 2000/2003 server, to start the service, either reboot the machine, which is not necessary, or go to the Control Panel, open Administrative Tools folder, double click on 'Services', and start the apcupsd daemon program by selecting the apcupsd UPS Server and then clicking on the Start button.

Installation Directory

The Win32 version of apcupsd must reside in the c:\apcupsd\ directory, and there must be a c:\tmp directory on your machine. The installation will do this automatically, and we recommend that you do not attempt to place apcupsd in another directory. If you do so, you are on your own, and you will need to do a rebuild of the source.

Testing

It would be hard to overemphasize the need to do a full testing of your installation of apcupsd as there are a number of reasons why it may not behave properly in a real power failure situation.

See http://www.apcupsd.org/manual/Testing_Apcupsd.html for general instructions on testing the Win32 version. However, on Win32 systems, there is no Unix system log file, so if something goes wrong, look in the file c:\apcupsd\etc\apcupsd\apcupsd.events where apcupsd normally logs its events, and you will generally find more detailed information on why the program is not working. The most common cause of problems is either improper configuration of the cable type, or an incorrect address for the serial port.

Post Installation

After installing apcupsd and before running it, check the contents of two files to ensure that it is configured properly for your system. The first is c:\apcupsd\etc\apcupsd\apcupsd.conf. You will probably need to change your UPSCABLE directive, your UPSTYPE and possibly your DEVICE directives. Please refer to the configuration section of this manual for more details.

The second file that you should examine is c:\apcupsd\etc\apcupsd\apccontrol. This file is called by apcupsd when events (power loss, etc) are generated. It permits the user to program handling the event. In particular, it permits the user to be notified of the events. For the Win32 version, each event is programmed to display a Windows popup dialogue box. If your machine is mostly unattended, you may want to comment out some of these popup dialogue boxes by putting a pound sign (#) in column one of the appropriate line.

Upgrading

On Win2000/2003 systems, you may stop apcupsd by using the Services item in the Control Panel/Administrative Tools folder. In addition, at least on my system, there seems to be a Win2000 bug that causes the system to prevent apcupsd.exe from being overwritten even though the file is no longer being used. This is manifested by an error message when attempting load a new version and overwrite the old apcupsd.exe (the extract part of WinZip as described above). To circumvent this problem (if it happens to you), after shutting down the running version of apcupsd, through the Services dialogue in the Control Panel/Administrative Tools folder, first click on the Stop button, then click on the Startup ... button, and in the Startup dialogue select the Disabled button to disable apcupsd.  After closing the dialogues, reboot the system, typical of Microsoft :-(. When the system comes back up, apcupsd will not be automatically launched as a service, and you can install the new version. To reinstate apcupsd as an automatic service, using the Control Panel/Administrative Tools folder: reset apcupsd to Automatic startup in the Startup dialogue, then restart apcupsd in the Services dialogue as shown above in the installation instructions. Frequently after an upgrade, you will click on the Start button and after a few seconds, the system reports that it failed to start. The cause of this problem is unknown, but the solution is simply to click again on the Start button.

Configuration

To configure apcupsd, you need to edit the apcupsd.conf file as well as set up the "event" files. Here's how to get started:

  1. Copy the base configuration files from /src/local/apcupsd into your system-specific config directory (listed in the install instructions). Use the source directory that matches the type of install that you are doing (master, slave, standalone). For example, if I were setting up a slave FreeBSD server, I would copy the files from /src/local/apcupsd/slave/freebsd/* to /usr/local/etc/apcupsd.
  2. Modify the DEVICE line to reflect the correct... ?

References

  1. http://www.apcupsd.com/
  2. http://www.apcupsd.org/manual/Contents.html
AttachmentSize
apcupsd_master.conf10.96 KB
apcupsd_slave.conf10.79 KB