Configuration of apcupsd with KILLDELAY?

obsigna

Profile disabled
My home server is attached to a APC Back-UPS ES 600G. This one got a fixed grace time of 20 seconds, i.e., after it received the power down command from sysutils/apcupsd, the server has less than 20 seconds left for regularly shutting down. For 8.x and 9.x this has always been sufficient.

Since upgrading to FreeBSD RELEASE-10.1, the shutdown sequence occasionally takes much longer than 20 s. This happens also when I do a manual shutdown -r now. In case of a shutdown initiated by the UPS, this means that the server is turned off before the disks are synched. Today, I experienced another power loss, and it happened again that the server was turned off before the regular shutdown sequence was finished. The postgresql databases were left in a dirty state, and the disks were not synched.

The time it takes for shutting down the machine seems to be related to the power-on time. If the server is running more than a week, then shutting it down may take a minute. Unfortunately, I cannot change the grace time of the UPS.

Presently, apcupsd is configured in standard mode: --kill-on-powerfail. That means, shutting down of all the running daemons and then synching the disks must be finished within 20 seconds. I guess, I am looking for a way of telling apcupsd to send the --killpower command only after shutting down of the daemons has been finished, just before synching the disks.

I read the apcupsd manual and the respective man pages, and it seems that this could be achieved somehow -- from: apcupsd.conf(5):
KILLDELAY <seconds>

Specifies the number of seconds for which apcupsd will continue
running after a shutdown has been requested. After the specified
time, apcupsd will attempt to put the UPS into hibernate mode
and kill the power to the computer. This is for use on operating
systems where apcupsd cannot regain control after a shutdown (eg
FreeBSD) to issue an apcupsd --killpower command. Setting the
delay to 0 disables it.

However, I set the KILLDELAY to 120 s, ran the full power down test, and KILLDELAY didn't make any difference. I must be missing something, and the question is, what am I missing?
 
What are TIMEOUT, BATTERYLEVEL, and MINUTES set to? apcupsd will initiate a shutdown when the first of these conditions becomes valid.
 
What are TIMEOUT, BATTERYLEVEL, and MINUTES set to? apcupsd will initiate a shutdown when the first of these conditions becomes valid.

From my /usr/local/etc/apcupsd/apcupsd.conf:
Code:
...
BATTERYLEVEL 5
MINUTES 3
TIMEOUT 120
...
According to the experiments that I carried out, this part (TIMEOUT 120) works as expected. The problem is, that apcupsd obviously at the same time initiates the shutdown sequence of FreeBSD and sends the shutdown command to the UPS. I want that apcupsd first initiates the shutdown sequence of FreeBSD and 120 s later shuts down the UPS.
 
FWIW, I don't use sysutils/apcupsd, but when considering purchasing a UPS last year and researching a bit, I think I remember reading somewhere running apcupsd with --kill-on-powerfail overrides KILLDELAY. Memory is cloudy at the moment.
 
A possible solution. Remove --kill-on-powerfail from the command line and edit the doshutdown script by adding a:

sleep 120

before

/usr/local/sbin/apcupsd --killpower
 
A possible solution. Remove --kill-on-powerfail from the command line and edit the doshutdown script by adding a:

sleep 120

before

/usr/local/sbin/apcupsd --killpower

Sounds like a very promising approach. In the moment I am on a tight schedule of a bigger project. For sure I will try this, and I will report the findings. I will come back to this in about 3 weeks.

Best regards

Rolf
 
Back
Top