Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
APC UPS - PC won't power on after AC outage
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Robert S
Guru
Guru


Joined: 15 Aug 2004
Posts: 443
Location: Canberra Australia

PostPosted: Wed Mar 01, 2017 8:50 pm    Post subject: APC UPS - PC won't power on after AC outage Reply with quote

I recently purchased an APC UPS (UPSPRO 550VA/330W). I've installed apcupsd and set the appropriate DEVICE parameter in /etc/apcupsd/apcupsd.conf. I have not changed any other settings. I'm using gentoo 64 bit with the latest "stable" updates.

If I power off the UPS at the wall, it appropriately shuts down my computer after about 30min, but when I restore power to the UPS, my computer does not power on. I have set the BIOS so that the computer will power on after a loss of power, and this has worked when I'm not using the UPS.

I assume that the problem is that my computer has done a "graceful" shutdown, and the power-on is not triggering a restart. I need to do this manually by pressing the soft-on button on my computer. Looking at some comments on the net, this is the desired behaviour, because another power failure can occur and result in data corruption.

Because my computer is a "headless" machine, it is often not possible to switch the power on manually. As I keep regular backups I could accept the small risk of data loss in the event of multiple power failures.

Is it possible to change the shutdown scripts so that my computer will recognise that AC power has been lost, and power on again? What is the "safest" way of doing this? I assume that one of the commands in the config directory can be changed. Alternatively, can I change settings in apcupsd.conf to allow my desired behaviour?

Here is my /etc/apcupsd/apcupsd.conf file:
Quote:
UPSCABLE usb
UPSTYPE usb
DEVICE /dev/usb/hiddev0
POLLTIME 30
LOCKFILE /run/apcupsd
SCRIPTDIR /etc/apcupsd
PWRFAILDIR /etc/apcupsd
NOLOGINDIR /etc
ONBATTERYDELAY 10
BATTERYLEVEL 0
MINUTES 0
TIMEOUT 0
ANNOY 45
ANNOYDELAY 90
NOLOGON disable
KILLDELAY 0
NETSERVER on
NISIP 127.0.0.1
NISPORT 3551
EVENTSFILE /var/log/apcupsd.events
EVENTSFILEMAX 25
UPSCLASS standalone
UPSMODE disable
STATTIME 0
STATFILE /var/log/apcupsd.status
LOGSTATS off
DATATIME 0
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1655
Location: United Kingdom

PostPosted: Wed Mar 01, 2017 11:11 pm    Post subject: Reply with quote

Have you seen the instructions for doing this in the APCUPSD User Manual?: http://apcupsd.org/manual/manual.html#arranging-for-reboot-on-power-up
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog


Last edited by Fitzcarraldo on Wed Mar 01, 2017 11:12 pm; edited 1 time in total
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7130
Location: almost Mile High in the USA

PostPosted: Wed Mar 01, 2017 11:11 pm    Post subject: Reply with quote

I've not tried using apcupsd, but perhaps this will work:

I don't know if all UPS support this, but my old BestPower does support "delayed shutdown" - basically you can tell the UPS to shut off power a set number of minutes from the command. You issue that command to the UPS, and then do a normal shutdown - but without powerdown. The computer will "hang" after shutdown and the UPS will cut power to the computer. The computer will now remember its state as "powered up."

Then the computer should come back up when power is restored.

Will this work, or is this what you've already tried?
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Robert S
Guru
Guru


Joined: 15 Aug 2004
Posts: 443
Location: Canberra Australia

PostPosted: Wed Mar 01, 2017 11:35 pm    Post subject: Reply with quote

In response to both replies: I have already set the BIOS to "Power On". Maybe I should try "Last state".

I'm looking at the option of changing the shutdown script in /etc/apcupsd

The apcupsd manual suggests examining the halt script - there isn't one in gentoo (it is a binary) - Can someone can advise what the equivalent is?

Most of the time the default is probably best - having to manually turn the machine on after a prolonged outage would guarantee that there's no loss of data, and we get warning about most prolonged outages. I would however like to know how to change this.

I don't think that I can set a delay into the UPS
Back to top
View user's profile Send private message
cboldt
l33t
l33t


Joined: 24 Aug 2005
Posts: 833

PostPosted: Thu Mar 02, 2017 12:07 am    Post subject: Reply with quote

I think the equivalent under openrc is /etc/init.d/bootmisc, which calls `halt -w`

The manpages for halt and shutdown might help too.

I'm somewhat interested in the resolution to your problem, but for a different reason at the moment. I have one machine that is not on UPS, and it goes down hard on power outage. That machine responds to wakeonlan, but only "if conditions are right," which I think is related to how it was shutdown - if I do a `shutdown -h now`, no wakeonlan. I do not want it to restart automatically on restoration of power, but I would like for it to restart if power is on and it gets a wakeonlan. It is normally on 24/7, so I do not want to set BIOS to "last state" or "on."
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7130
Location: almost Mile High in the USA

PostPosted: Thu Mar 02, 2017 1:50 am    Post subject: Reply with quote

I think that these are different issues, might be better to use different topics.

For the OP, I doubt that keeping BIOS at former-status will help. Worth a shot? why not.
After the computer shuts down, does the UPS stay up or does it shut down with the computer? You might need to connect a lamp or something to see if it's still powering the outputs.

How does the UPS wake up the PC normally? Just the power status? Some can wake through USB if it's connected that way, and you'll need to set up wake on USB.
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
cboldt
l33t
l33t


Joined: 24 Aug 2005
Posts: 833

PostPosted: Thu Mar 02, 2017 2:04 am    Post subject: Reply with quote

From the apcupsd page linked, the PC is expected to restart itself on power restore, with no additional input.

"The final consideration for a automatic reboot after a full power down is to ensure that your computer will automatically reboot when the power is restored."

From the remarks on that page, I take it that a `shutdown -h now` -- or any similar command -- results in LOSS of the necessary start on restoration of power.
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1655
Location: United Kingdom

PostPosted: Thu Mar 02, 2017 10:13 am    Post subject: Reply with quote

man shutdown wrote:

-h
Requests that the system be either halted or powered off after it has been brought down, with the choice as to which left up to the system.

-H
Requests that the system be halted after it has been brought down.

Try the following from a console to check if the OS shuts down (halts) but the PC stays powered up:

Code:
shutdown -H now

If that works, you could alter the power-loss script for apcupsd so that it issues that command when the UPS tells apcupsd to shutdown. The OS would then shutdown correctly but the PC would remain powered up until the UPS has drained, at which point the PC would of course power-off. Startup of the PC on resumption of power supply from the UPS would still be contingent on the PC's BIOS having been configured so that it starts automatically upon supply of power:

APCUPSD User Manual wrote:
Normally, this is located under the BOOT menu item, and will be called something such as Restore on AC/Power Loss or Full-On. The exact words will vary according to the ROM BIOS provider. Generally you will have three options: Last State, Power On, and Power Off. Although Last State should normally work, we recommend setting your computers to Power On. This means that whenever the power is applied they are on.


P.S. I also have a headless server which uses apcupsd, and I also have an APC UPS connected to it (an APC Back-UPS ES 700 in my case). I chose not to configure the server BIOS and apcupsd to boot automatically upon resumption of power supply to the server. If I happen to be at home, I would press the Power On button on the server; if I happen to be away on a work trip (the most likely scenario), I would telephone home and ask someone to press the Power On button. This has only happened once in my case.
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Robert S
Guru
Guru


Joined: 15 Aug 2004
Posts: 443
Location: Canberra Australia

PostPosted: Thu Mar 02, 2017 12:00 pm    Post subject: Reply with quote

I've had a chance to look at this.

If I unplug my PC and plug it in again after a "graceful" shutdown, it powers on automatically. The BIOS is therefore doing the right thing.

If I power off the UPS at the wall and wait for it to halt my PC, the monitor remains on - therefore the UPS is still supplying battery power to my monitor and PC.

Code:
# /sbin/apcupsd --killpower
causes the UPS to power down after a delay. I had AC power on, so the PC powered off then on again - presumably as expected.

I therefore conclude that my shutdown scripts aren't causing my UPS to stop supplying power to my PC. Therefore it won't boot up when the power comes back on again.

I have added /etc/init.d/apcupsd.powerfail to my shutdown runlevel - as recommended. Looking at the code this should cause the UPS to switch power off after a delay, but it doesn't seem to be doing this. Here is my shutdown runlevel:
Quote:
# rc-update show |grep shutdown
apcupsd.powerfail | shutdown
killprocs | shutdown
mount-ro | shutdown
savecache | shutdown

I therefore conclude that my UPS is continuing to supply battery power after my PC shuts down. Can anyone tell me how to remedy this?
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1655
Location: United Kingdom

PostPosted: Thu Mar 02, 2017 1:35 pm    Post subject: Reply with quote

An excerpt from /etc/apcupsd.conf on my server is as follows:

Quote:
# PWRFAILDIR <path to powerfail directory>
# Directory in which to write the powerfail flag file. This file
# is created when apcupsd initiates a system shutdown and is
# checked in the OS halt scripts to determine if a killpower
# (turning off UPS output power) is required.
PWRFAILDIR /etc/apcupsd

and my server has a script named killpower in $PWRFAILDIR, which I modified for my purposes, having left the commented-out lines in the original script installed by apcupsd:

Code:
#!/bin/sh
#
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/apccontrol before
# apcupsd kills the power in the UPS. You probably
# need to edit this to mount read-only /usr and /var,
# otherwise apcupsd will not run.

# Choose one of this solution
#mount -n -o ro /usr
#mount -n -o ro /var
#
#mount | awk '/ext2/ { print $3 }' | while read line; do
#       mount -n -o ro,remount $line
#done
#mount | awk '/ext3/ { print $3 }' | while read line; do
#       mount -n -o ro,remount $line
#done
#mount | awk '/reiserfs/ { print $3 }' | while read line; do
#       mount -n -o ro,remount $line
#done
#exit 0

# 2016-06-25: Fitzcarraldo commented out everything above and added the lines below:
cat /home/fitzcarraldo/apcups/ups-email-killpower.txt | /usr/sbin/sendmail -4 -t
sudo -u fitzcarraldo ssh vmachine1 sudo shutdown -h now
sudo -u fitzcarraldo ssh vmachine2 sudo shutdown -h now
sleep 30
shutdown -h now
exit 0


To achieve what you want, my guess is that you need to modify $PWRFAILDIR/killpower as per the commented-out lines quoted above, viz.:

Quote:
# This shell script if placed in /etc/apcupsd
# will be called by /etc/apcupsd/apccontrol before
# apcupsd kills the power in the UPS. You probably
# need to edit this to mount read-only /usr and /var,
# otherwise apcupsd will not run
.

_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1655
Location: United Kingdom

PostPosted: Thu Mar 02, 2017 2:03 pm    Post subject: Reply with quote

Further to my previous post, I also noticed the following in the APCUPSD User Manual:

http://apcupsd.org/manual/manual.html#verifying-a-source-installation

Quote:
Modification of the halt script is important so that at the end of the shutdown procedure, apcupsd will be called again to command the UPS to turn off the power. This should only be done in a power failure situation as indicated by the presence of the /etc/powerfail file, and is necessary if you want your machine to automatically be restarted when the power returns. On a Red Hat system, the lines containing the # ***apcupsd*** should be inserted just before the final halt command:

Code:
# Remount read only anything that's left mounted.
#echo "Remounting remaining filesystems (if any) readonly"
mount | awk '/ext2/ { print $3 }' | while read line; do
    mount -n -o ro,remount $line
done

# See if this is a powerfail situation.                               # ***apcupsd***
if [ -f /etc/apcupsd/powerfail ]; then                                # ***apcupsd***
   echo                                                               # ***apcupsd***
   echo "APCUPSD will now power off the UPS"                          # ***apcupsd***
   echo                                                               # ***apcupsd***
   /etc/apcupsd/apccontrol killpower                                  # ***apcupsd***
   echo                                                               # ***apcupsd***
   echo "Please ensure that the UPS has powered off before rebooting" # ***apcupsd***
   echo "Otherwise, the UPS may cut the power during the reboot!!!"   # ***apcupsd***
   echo                                                               # ***apcupsd***
fi                                                                    # ***apcupsd***

# Now halt or reboot.
echo "$message"
if [ -f /fastboot ]; then
 echo "On the next boot fsck will be skipped."
elif [ -f /forcefsck ]; then
 echo "On the next boot fsck will be forced."
fi

The purpose of modifying the system halt files is so that apcupsd will be recalled after the system is in a stable state. At that point, apcupsd will instruct the UPS to shut off the power. This is necessary if you wish your system to automatically reboot when the mains power is restored.


Looking at the Gentoo powerfail init script:

Code:
#!/sbin/openrc-run
# Copyright 2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

description='Signal the UPS to kill power in a power failure condition'

depend() {
        need mount-ro
}

start() {
        if [ "$(runlevel | cut -d' ' -f2)" = "0" -a -f /etc/apcupsd/powerfail ] ; then
                ebegin 'Signaling UPS to kill power'
                /sbin/apcupsd --killpower
                eend $?
        fi
}

perhaps you need to modify it as per the APCUPSD User Manual so that it explicitly calls the killpower script mentioned in my previous post:

Code:
#!/sbin/openrc-run
# Copyright 2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

description='Signal the UPS to kill power in a power failure condition'

depend() {
        need mount-ro
}

start() {
        if [ "$(runlevel | cut -d' ' -f2)" = "0" -a -f /etc/apcupsd/powerfail ] ; then
           echo
           echo "APCUPSD will now power off the UPS"
           echo
           /etc/apcupsd/apccontrol killpower
           echo
           echo "Please ensure that the UPS has powered off before rebooting"
           echo "Otherwise, the UPS may cut the power during the reboot!!!"
           echo
           eend $?
        fi
}

_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1655
Location: United Kingdom

PostPosted: Thu Mar 02, 2017 2:21 pm    Post subject: Reply with quote

If the above does not work, another thing to consider is whether Gentoo is shutting down USB before it runs the killpower script. Apparently this is what happens in Ubuntu 16.04 specifically: APCUPSD does not send killpower command to UPS (only happens on Ubuntu 16.04):

JanCeuleers wrote:
According to discussion on the apcupsd-users mailing list [1] this issue is OS-specific rather than being a problem in upstream apcupsd.

Specifically it is believed that this issue is due to Ubuntu shutting down USB before the killpower command is issued to the UPS, which which it is no longer possible to communicate without USB.

[1]: https://marc.info/?t=147606479000001&r=1&w=2

_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Robert S
Guru
Guru


Joined: 15 Aug 2004
Posts: 443
Location: Canberra Australia

PostPosted: Thu Mar 02, 2017 9:26 pm    Post subject: APC UPS - PC won't power on after AC outage [SOLVED] Reply with quote

I have discovered that the apcupsd.powerfail script has an error. If I modify the script to display the runlevel, it displays it as "unknown", and therefore the "/sbin/apcupsd --killpower" command never runs. I've modified the script as below:
Code:
#!/sbin/openrc-run
# Copyright 2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

description='Signal the UPS to kill power in a power failure condition'

depend() {
        need mount-ro
}

start() {
        if [ "$(runlevel)" = "unknown" -a -f /etc/apcupsd/powerfail ] ; then
                ebegin 'Signaling UPS to kill power'
                /sbin/apcupsd --killpower
                eend $?
        fi
}

It all works as expected now.

Can anybody see any situation where this could cause problems through the reporting of $runlevel as "unknown"?

Otherwise I'll send in a bug report.
Back to top
View user's profile Send private message
cboldt
l33t
l33t


Joined: 24 Aug 2005
Posts: 833

PostPosted: Thu Mar 02, 2017 10:25 pm    Post subject: Reply with quote

That "unknown runlevel" is weird. What do you get if you just run `runlevel` from the command line?

The issue isn't with the the script, per se. It has to do with how openrc sees itself at that point in the reaction to the powerfailure.
Back to top
View user's profile Send private message
Robert S
Guru
Guru


Joined: 15 Aug 2004
Posts: 443
Location: Canberra Australia

PostPosted: Thu Mar 02, 2017 10:40 pm    Post subject: Reply with quote

Quote:
~ # runlevel
N 3

I get "unknown" when I start in recovery mode. As far as I can remember I have always had this behaviour. I seem to remember that I've had this happen with every installation of gentoo that I've done.

Any suggestions as to how (or whether) I should deal with this? I agree that it doesn't look right.
Back to top
View user's profile Send private message
cboldt
l33t
l33t


Joined: 24 Aug 2005
Posts: 833

PostPosted: Thu Mar 02, 2017 11:11 pm    Post subject: Reply with quote

I haven't studied the details (obviously), I don't use apcupsd at all, just following along here. But, reading the APC material, much of it is tailored to RedHat scripts, and it may be that the Gentoo implementation is more DIY and less "emerge it and it works."

From your earlier ...

Code:
apcupsd.powerfail | shutdown
killprocs | shutdown
mount-ro | shutdown
savecache | shutdown


Out of those four, the only script that even questions what runlevel it is in, is apcupsd.powerfail

Now, maybe apcupsd.powerfail has some generic design, where the script can be called other than from the openrc shutdown level, and knowing the runlevel matters.

But it seems to me that in the case outlined in this thread, looking for the file "/etc/apcupsd/powerfail" and checking runlevel is belt and suspenders. Fitzcarraldo's killpower script is another case of highly customized code, compared with what is provided by the apcupsd package.

On startup, notice what gets rid of etc/apcupsd/powerfail ... `/etc/init.d/apcupsd start` The mere presence of /etc/apcupsd/powerfail is enough to tell us the system is in a powerfail situation.
Back to top
View user's profile Send private message
cboldt
l33t
l33t


Joined: 24 Aug 2005
Posts: 833

PostPosted: Thu Mar 02, 2017 11:23 pm    Post subject: Reply with quote

Digging a little more, it seems the script in question is derived from /etc/init.d/powerfail

That script, at least the reference to it that I find in a goggle search, is a Debian construct called by /etc/inittab, not by openrc.
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1655
Location: United Kingdom

PostPosted: Fri Mar 03, 2017 12:33 am    Post subject: Reply with quote

cboldt, indeed I had to alter significantly the scripts in /etc/apcupsd/, including the script /etc/apccontrol that calls them. In my case I did not want my server to tell the UPS to go into hibernation (which is what the command '/sbin/apcupsd --killpower' does) when apcupsd runs the killpower script, hence my modifications to /etc/apcups/killpower listed in a previous post. In my case, I edited /etc/apcupsd/killpower to do the same thing as /etc/apcupsd/doshutdown just to be sure, and I configured the BIOS not to boot automatically when the power supply is restored. My understanding of the intended process is as follows:

1. Mains supply ceases.

2. UPS tells apcupsd that the mains supply has ceased.

3. apcupsd uses $BATTERYLEVEL, $MINUTES, and $TIMEOUT (set in /etc/apcupsd.conf) to determine when to shutdown the OS (Step 4 below).

4. apcupsd runs /etc/apcupsd/doshutdown to initiate shutdown of the OS.

5. After the OS initiates shutdown, the OS uses apcupsd (which runs /etc/apcupsd/killpower) to tell the UPS to go into hibernation. The Gentoo apcupsd.powerfail init script only tells apcupsd to put the UPS into hibernation when the OS is in Runlevel 0 and the OS has almost completed shutting down (the file systems have already been mounted Read-Only).

6. I think the UPS goes into hibernation $KILLDELAY seconds after /etc/apcupsd/doshutdown runs (setting KILLDELAY=0 in /etc/apcupsd.conf stops apcupsd from running /etc/apcupsd/killpower if I understand correctly, and I have set KILLDELAY=0).

In my case I was not interested in making my UPS go into hibernation once the OS shuts down. To be honest, I did not want to risk the UPS going into hibernation before my server had shutdown the OS and powered down the server. Furthermore, it is not the only device powered by the UPS. Currently I have configured apcupsd in my server to initiate shutdown of the OS either when the remaining UPS battery power has dropped to 5% or there is only 3 minutes of runtime left (as calculated by the UPS). This is achieved by setting BATTERYLEVEL=5, MINUTES=3 and TIMEOUT=0 (zero means no check on how long the server has been running on battery power) in /etc/apcupsd/apcupsd.conf.
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Akkara
Administrator
Administrator


Joined: 28 Mar 2006
Posts: 6693
Location: &akkara

PostPosted: Fri Mar 03, 2017 7:57 am    Post subject: Reply with quote

Fitzcarraldo wrote:
Currently I have configured apcupsd in my server to initiate shutdown of the OS either when the remaining UPS battery power has dropped to 5% or there is only 3 minutes of runtime left (as calculated by the UPS). This is achieved by setting BATTERYLEVEL=5, MINUTES=3 and TIMEOUT=0 (zero means no check on how long the server has been running on battery power) in /etc/apcupsd/apcupsd.conf.

Does your UPS have lead-acid batteries (sealed or otherwise)? If so, you'll get much better life out of the batteries if you shut down nearer to 30%. Most UPS batteries are undersized as it is, and will fail after only a year when run down this hard.

If you *have* to keep your server running because that's how you assure it powers back up, then set the UPS turn-off threshold to 11.25V (if it uses a 12V battery).
_________________
Many think that Dilbert is a comic. Unfortunately it is a documentary.
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1655
Location: United Kingdom

PostPosted: Fri Mar 03, 2017 11:38 am    Post subject: Reply with quote

Thanks for the advice, Akkara. My APC Back-UPS ES 700 uses a 12V sealed lead-acid battery.

apcupsd does not appear to have a parameter to be able to configure a voltage threshold. The three parameters it uses to determine when to trigger shutdown are:

APCUPSD User Manual wrote:

BATTERYLEVEL percent of battery
If BATTERYLEVEL is specified, during a power failure, apcupsd will halt the system when the remaining battery charge falls below the specified percentage. The default is 5 percent. This directive is ignored for dumb (voltage-signalling) UPSes. To totally disable this counter, set BATTERYLEVEL -1 in your apcupsd.conf file.

MINUTES battery runtime in minutes
If MINUTES is specified, during a power failure, apcupsd will shutdown the system when the remaining runtime on batteries as internally calculated by the UPS falls below the time specified. The default is 3. This directive is ignored for dumb (voltage-signalling) UPSes. It should be noted that some UPSes report an incorrect value for remaining runtime when the battery is fully charged. This can be checked by examining the TIMELEFT value as printed in the output of an 'apcaccess status' command. If the value is zero or otherwise unreasonable, your UPS is probably broken. In this case, we recommend that you disable this timer by setting MINUTES -1 in your apcupsd.conf file.

TIMEOUT time in seconds
After a power failure, apcupsd will halt the system when TIMEOUT seconds have expired. A value of zero disables this timer. Normally for all Smart UPS models and dumb UPSes with cables that support low battery detection, this should be zero so that the shutdown time will be determined by the battery level and/or remaining runtime (see above) or in the case of a voltage-signalling UPS, when the battery is exhausted. This command is required for dumb UPSes that do not provide a battery exhausted signal (only testing can determine this point). For more information, see the Testing Apcupsd section of this manual. This timer can also be useful if you want some slave machines to shutdown before other machines to conserve battery power. It is also useful for testing apcupsd because you can force a rapid shutdown by setting a small value (e.g. 60) and pulling the plug to the UPS.

TIMEOUT, BATTERYLEVEL, and MINUTES can be set together without problems. apcupsd will react to the first case or test that is valid. Normally SmartUPS users will set TIMEOUT to zero so that the system is shutdown depending on the percentage battery charge remaining (BATTERYLEVEL) or the remaining battery runtime (MINUTES).

Quote from the APCUPSD User Manual: http://www.apcupsd.com/manual/manual.html#configuration-directive-reference

Anyway, I'll take your advice and change BATTERYLEVEL to 30 (%) instead of the default 5. Actually, the powercuts in my location are few and far between (the frequency is once annually or even less), although we get a few micro power cuts lasting a second or two during a year, usually overnight (my guess is switchgear switching).

Coming back to what I wrote in previous posts regarding putting the UPS into hibernation ('killpower') at shutdown, I think my caution and my disabling of it are justified:

APCUPSD User Manual wrote:
KILLDELAY time in seconds
If KILLDELAY is set, apcupsd will continue running after a shutdown has been requested, and after the specified time in seconds, apcupsd will attempt to shut off the UPS the power. This directive should normally be disabled by setting the value to zero, but on some systems such as Win32 systems apcupsd cannot regain control after a shutdown to force the UPS to shut off the power. In this case, with proper consideration for the timing, the KILLDELAY directive can be useful. Please be aware, if you cause apcupsd to kill the power to your computer too early, the system and the disks may not have been properly prepared. In addition, apcupsd must continue running after the shutdown is requested, and on Unix systems, this is not normally the case as the system will terminate all processes during the shutdown.

_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum