Configure apcupsd to turn off UPS?

General support questions
Post Reply
mathog
Posts: 48
Joined: 2008/07/09 23:52:06

Configure apcupsd to turn off UPS?

Post by mathog » 2017/12/22 01:49:55

Centos 6.9, APC smartups 2200, apcupsd 3.14.10

Installed apcupsd like so

Code: Select all

wget  http://springdale.math.ias.edu/data/puias/unsupported/6/x86_64/apcupsd-3.14.10-1.puias6.x86_64.rpm
rpm -Uvh apcupsd-3.14.10-1.puias6.x86_64.rpm
attached USB cable between machine and UPS. Modified /etc/apcupsd.conf to these active lines:

Code: Select all

UPSNAME APCUPS00
UPSCABLE usb
UPSTYPE usb
DEVICE 
POLLTIME 60
LOCKFILE /var/lock
SCRIPTDIR /etc/apcupsd
PWRFAILDIR /var/run/apcupsd
NOLOGINDIR /var/run/apcupsd
ONBATTERYDELAY 6
BATTERYLEVEL 50
MINUTES 3
TIMEOUT 600
ANNOY 60
ANNOYDELAY 60
NOLOGON disable
KILLDELAY 0
NETSERVER on
NISIP 0.0.0.0
NISPORT 3551
EVENTSFILE /var/log/apcupsd.events
EVENTSFILEMAX 10
UPSCLASS standalone
UPSMODE disable
STATTIME 0
STATFILE /var/log/apcupsd.status
LOGSTATS off
DATATIME 0
Then tested that it was working with

Code: Select all

chkconfig apcupsd on
service apcupsd start
apcaccess
Which showed the right things. The server has dual supplies, one of which is plugged into the UPS, one into the wall. The system's BIOS
is configured for "always on". Turned off the breaker for the UPS and after the expected 10 minutes the system shutdown. However, it only went down to "halted". That would have been OK, except the UPS stayed on. I waited an extra 13 minutes for it to go down, since it was possible that the UPS is programmed to wait a certain time before receiving its kill command and when it actually does it. Turned the breaker back on and of course the Server didn't restart. Powerbutton didn't do so from that state, but luckily it has a "reset", which did the trick.

So how do I get it to:

1. shut the UPS off?
2. poweroff the server, instead of halting it?

Thanks.
Last edited by mathog on 2017/12/22 01:59:33, edited 1 time in total.

mathog
Posts: 48
Joined: 2008/07/09 23:52:06

Re: Configured apcupsd to turn off UPS?

Post by mathog » 2017/12/22 01:58:23

Also, these were all the apcupsd messages in the shutdown, restart sequence:

Code: Select all

Dec 21 16:54:54 lyre apcupsd[10619]: Power failure.
Dec 21 16:55:00 lyre apcupsd[10619]: Running on UPS batteries.
Dec 21 17:05:01 lyre apcupsd[10619]: Reached run time limit on batteries.
Dec 21 17:05:01 lyre apcupsd[10619]: Initiating system shutdown!
Dec 21 17:05:01 lyre apcupsd[10619]: User logins prohibited
Dec 21 17:19:23 lyre (reboot starts here)
Dec 21 17:19:43 lyre apcupsd[2547]: Could not open events file /var/log/apcupsd.events: Permission denied
Dec 21 17:19:44 lyre apcupsd[2547]: apcupsd 3.14.10 (13 September 2011) redhat startup succeeded
Dec 21 17:19:44 lyre apcupsd[2547]: NIS server startup succeeded

mathog
Posts: 48
Joined: 2008/07/09 23:52:06

Re: Configure apcupsd to turn off UPS?

Post by mathog » 2018/01/02 21:40:49

Figured it out. In apcupsd.conf there is a line:

Code: Select all

PWRFAILDIR /etc/apcupsd
which I had changed to

Code: Select all

PWRFAILDIR /var/run/apcupsd
That was a bad idea as /etc/init.d/halt is hardwired to use the original address. Restored this to the original value, and also added

Code: Select all

KILLDELAY 30
Then turning off the breaker to the UPS triggered a shutdown (to halt) on the server and a few minutes later the UPS turned itself off. So there does not seem to be a way to fully poweroff the server if one of the redundant power supplies goes to another circuit, and that circuit stays up when the UPS circuit goes down.

Note that /etc/init.d/halt did not come from the apcupsd RPM, instead it came from initscripts. However it already had code to work with apcupsd if and when that was installed. That script also has another section preceding the apc one which seems to be for NUT, it is:

Code: Select all

# Shutdown UPS drivers
if [ "$command" = /sbin/halt -a -f /etc/sysconfig/ups ]; then
        . /etc/sysconfig/ups
        if [ -z $POWERDOWNFLAG ]; then
                POWERDOWNFLAG=/etc/killpower
        fi
        if [ "$SERVER" = "yes" -a -f $POWERDOWNFLAG ]; then
                /sbin/upsdrvctl shutdown
                sleep 120
                /sbin/reboot --force
        fi
fi

Post Reply