FAQ
Author: Kern Sibbald

## Apcupsd Frequently Asked Questions

See the bugs section of this document for a list of known bugs and solutions.

What UPS brands does apcupsd support?

  Currently apcupsd supports only APC UPSes. However, some companies such as Hewlett Packard put their own brand name on APC manufactured UPSes. Thus even if you do not have an APC branded UPS, it may work with apcupsd. You will need to know the corresponding APC model number. apcupsd supports all the popular APC models. See the installation and configurations sections of this document for more details.

Does apcupsd support Windows?

  With release 3.8.0, apcupsd now runs on Win95/98, WinMe, WinNT, and Win2000 machines. All features of the Unix versions of apcupsd are implemented. The UPS EEPROM programming features of apcupsd have not been tested under Windows. Version 3.8.0 does not support simple signaling UPSes (BackUPS, etc). Version 3.8.1 does support most simple signaling UPSes, but not all cables (due to deficiencies in the Windows serial port API). Please note that we have had reports that apcupsd does not work properly on the WinXP system. If you have any information on this, please email us.

I don't have a cable, which one should I build?

  First you must know if you have a Smart UPS or a simple signaling UPS -- See the table of supported UPSes in the Configuration Chapter of this manual. If you have a Smart UPS (or a SubSmart), we recommend building a Smart-Custom Cable. If you have a Simple Signaling UPS, we recommend that you build a Simple-Custom Cable.
How much CPU resources does apcupsd use?

  Depending on your CPU speed, you may see more or less of the CPU consumed by apcupsd. On a 400MHz Unix system, the CPU usage should fall well below 0.1%. On slower systems, the percentage will increase proportionally to the decrease in the CPU speed. On a 400Mhz Win98 machine, the CPU usage will be on the order of 0.5-1.0%. This is higher than for Unix systems. However, compared to the 30% CPU usage by APC's PowerChute (the version on the CDROM shipped with my UPS), apcupsd's 0.5-1.0% is very modest.

  If you configure apcupsd to run with pthreads (--with-pthreads on the ./configure line), apcupsd will run considerably faster, otherwise said, it will consume less of your CPU, and it will use approximately one third of the memory. For example, Carl Erhorn reports that on his Solaris system, "With the old 3-process version, we averaged about 4.8MB of total memory used. With the new single process, we use only about 1.7MB! That's also a very good improvement."

What language is apcupsd written in?

  It is written entirely in C.

We are using apcupsd-3.8.1-1 in RedHat 6.2. The slave, when shutting down, is reporting an error at line 436 of apcupsd.c. The error is initiated by apcupsd --killpower ! What can we do to fix this, and is it critical?

  No, the error is not serious. Unfortunately, the documentation in the area of master/slaves is not very detailed, and for that reason, your slave setup is not totally correct as explained below.

  On master machines, we modify /etc/rc.d/init.d/halt to re-invoke apcupsd with the --killpower option (actually the script apccontrol is called). This causes the UPS to send the codes to the UPS to make it power off.

  On slave machines, these modifications should not be made to the /etc/rc.d/init.d/halt script since the slave has no connection to the UPS.

  To eliminate the problem, on all your slave machines, either restore the original halt file, or simply delete all the lines containing ***apcupsd***, which were inserted by the apcupsd installation process.

To test apcupsd, I unplugged the UPS to simulate a power outage. After the machine went into the shutdown process I plugged the UPS back into the commercial power source. This caused the shutdown process to hang after the daemon tried to shut-off the ups. Have you run into this problem, and if so do you have a remedy?

  Normally, once the shutdown process has begun, we cannot stop it, though there IS some code that tries to do so, we don't consider it a very good idea - how do you stop a shutdown that has killed off half of the daemons running on your system? Most likely you will be left with an unusable system. In addition, when apcupsd is re-executed in the halt script after the disks are synced, it tries to shut off the UPS power, but the UPS will generally refuse to do so if the AC power is on. Since we cannot be 100% sure whether or not the UPS will shut off the power, we don't attempt to reboot the system if we detect that the power is back as it might then get caught by a delayed power off (at least for Smart UPSes).
After running apcupsd for a while, I get the following error:
"Serial communications with UPS lost." What is the problem?

  We use standard Unix serial port read() and write() calls so once a connection is made, we generally have few problems. However, there have been reports that APC's SNMP Management Card can cause serial port problems. If you have such a card, we suggest that you remove it and see if the problem goes away. It is also possible that some other process such as a getty is reading the serial port.
When apcupsd starts, I get the following error: "attach_shmarea: cannot get shm area: Identifier removed." What is the problem?

  This problem and the problem of cannot create shm area are due to the fact that the shared memory key that apcupsd wants to use is already in use. This happens most frequently when there is an old zombie apcupsd process still in the system.
  The solution is to remove the old process.
  You can often see what is going on by doing a: ipcs command as root when apcupsd is not running. If you see a segment with the key 0x10feed01, you can be sure there is some old apcupsd process still using it. If you cannot kill the old process, you can try using ipcrm (see the man pages).
  Recent versions of apcupsd starting with apcupsd-3.8.2Beta6 should no longer have this problem as they will automatically try using a different key.
I get the following error: "Starting apcupsd power management. Mar 20 21:19:40 box apcupsd[297]: apcupsd FATAL ERROR in apcserial.c at line 83. Cannot open UPS tty /dev/cua01: No such file or directory." What is the problem?

  The two most likely causes of your problem are:

  1. You have the wrong serial port device name in the apcupsd.conf file.

  2. The device name is not defined on your system.

  Suggestions for proceeding:

  For the first item, check what your serial port device should be named. You might be able to find the name with an:

  ls /dev

  normally there will be hundreds or even thousands of names that print.

  If that doesn't produce anything useful, you can try step 2. Perhaps your device is not defined.

  To get more information on your devices try:

  man MAKEDEV

  or

  find / -name MAKEDEV

  it is often located in /dev/MAKEDEV
  Looking at the documentation may tell you what the correct name is, or at least allow you to create the device.
How do I ensure that the slaves shutdown before the master?

  There are several strategies for getting the slaves properly shutdown before shutting down the master. The first is to make the master wait a period of time for the slaves to shutdown before doing its own shutdown. Currently, the master always waits 30 seconds before starting its own shutdown. If this is insufficient, you can add additional time by putting appropriate sleep() statements in the /etc/apcupsd/apccontrol file just before the actual system shutdown command is executed (there are something like 3 places).

  The second strategy is to put a TIMEOUT value in the apcupsd.conf file on the slave that is sufficiently short that you are sure that the slave will shutdown before the master. If the shutdown is done with a poweroff, this will also save power so that the master can stay up longer.
How do I ensure that my database server is correctly shutdown?

  You simply add whatever commands are necessary in the appropriate case statements in /etc/apcupsd/apccontrol, which is a standard script file that is called to actually do the shutdown. Alternatively, you can add your own script file that will be called before doing the commands in apccontrol. Your script file must have the same name as the appropriate case statement in apccontrol; it must be executable; and it must be in the same directory as apccontrol.