Not shutting down when UPS reaches low battery

Status
Not open for further replies.

BlueDan

Cadet
Joined
Sep 15, 2013
Messages
4
Version: FreeNAS-8.3.1-RELEASE-p2-x64 (r12686+b770da6_dirty)
UPS model: APC Back-UPS CS 500, connected via USB

The issue I'm having here is: FreeNAS won't shut down according to a modified battery.charge.low field (shutdown mode: UPS reaches low battery, shutdown timer 1 second).

upsc ups@localhost gives me
Code:
battery.charge: 38                                                             
battery.charge.low: 10                                                         
battery.charge.warning: 50                                                     

(etc)

Once the UPS reaches 10% it keels over and completely shuts off - shutdown hadn't started by that point, at least I didn't get an email about it.

So, I tried adding override.battery.charge.low = 35 to the auxiliary parameters so it should begin shutdown at 35% - but it carries on past this anyway, despite the new setting being reflected by upsc.

It's not a case of the OS gets ready for shutdown, but the hardware doesn't finally power off - it's all still running (can access the shell, CIFS shares etc). I tried setting a custom value for override.battery.runtime.low too - this is ignored as well.

If I set it the shutdown mode to UPS goes on battery this works, but I have to specify a fairly short amount of time to be safe, when if the UPS is fully charged it'll run for around 10 minutes.

Help!

Apologies if this has been covered already and I missed something.
 

paleoN

Wizard
Joined
Apr 22, 2012
Messages
1,403
Once the UPS reaches 10% it keels over and completely shuts off - shutdown hadn't started by that point, at least I didn't get an email about it.
So, the UPS timer either needs to be calibrated or isn't accurate. Can you raise the value in the UPS itself via upsrw?

Apologies if this has been covered already and I missed something.
You missed providing the full output of upsc and the assorted nut config files.
 

BlueDan

Cadet
Joined
Sep 15, 2013
Messages
4
I don't have an APC UPS, but I found this bug report: https://bugs.freenas.org/issues/2548

Thank you - I forgot to check the bug tracker. I was having another issue with this UPS and NUT, perhaps the fix there will cure both issues. upsc would randomly report "data stale" until I replugged the cable (the same unit and cable working ok elsewhere). I'll be trying the fix posted there once the box isn't busy with other tasks.

(NB - when testing automatic shutdown when on battery, data was still being reported).

So, the UPS timer either needs to be calibrated or isn't accurate. Can you raise the value in the UPS itself via upsrw?

You missed providing the full output of upsc and the assorted nut config files.

I looked in to changing the value with upsrw, but along the way found it's normal for some UPS' "battery charge low" to actually mean empty, or perhaps shutting off early to prevent some sort of damage resulting from a completely drained battery. I wasn't sure if the value presented over USB was just a publicly-visible field just for reporting, or if it was also used internally by the UPS to maintain the health of the battery. So for now, I left it alone.

By missing something, I had meant if I had missed another thread about this; I forgot about the configs, and thought the entire output of upsc would mostly be chaff, my mistake.

Output of upsc ups@localhost
Code:
battery.charge: 100
battery.charge.low: 35
battery.charge.warning: 50
battery.mfr.date: 2002/12/05
battery.runtime: 2580
battery.type: PbAc
battery.voltage: 13.4
battery.voltage.nominal: 12.0
device.mfr: American Power Conversion
device.model: Back-UPS 500
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: /dev/ugen0.1
driver.version: 2.6.5
driver.version.data: APC HID 0.95
driver.version.internal: 0.37
ups.firmware:  6.5.I
ups.firmware.aux:  c1
ups.mfr: American Power Conversion
ups.mfr.date: 2002/12/05
ups.model: Back-UPS 500
ups.productid: 0002
ups.serial: AB0249245347
ups.status: OL
ups.timer.reboot: 0
ups.vendorid: 051d


upsc.conf
Code:
[ups]
    driver = usbhid-ups
    port = /dev/ugen0.1
    desc = ""
override.battery.charge.low = 35


upsmon.conf
Code:
FINALDELAY 30
MONITOR ups 1 upsmon fixmepass master
NOTIFYCMD "/usr/local/sbin/upssched"
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+EXEC
NOTIFYFLAG FSD SYSLOG+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+EXEC
SHUTDOWNCMD "/sbin/shutdown -p now"


upssched.conf
Code:
CMDSCRIPT  /usr/local/bin/custom-upssched-cmd
PIPEFN      /var/db/nut/upssched.pipe
LOCKFN      /var/db/nut/upssched.lock
 
AT NOCOMM  * EXECUTE EMAIL
AT COMMBAD  * START-TIMER COMMBAD 10
AT COMMOK  * CANCEL-TIMER COMMBAD COMMOK
AT FSD      * EXECUTE EMAIL
AT LOWBATT  * EXECUTE EMAIL
AT ONBATT  * START-TIMER ONBATT 1
AT ONBATT  * EXECUTE EMAIL
AT ONLINE  * CANCEL-TIMER ONBATT ONLINE
AT ONLINE  * EXECUTE EMAIL
AT REPLBATT * EXECUTE EMAIL
AT SHUTDOWN * EXECUTE EMAIL
 

paleoN

Wizard
Joined
Apr 22, 2012
Messages
1,403
upsc would randomly report "data stale" until I replugged the cable (the same unit and cable working ok elsewhere)
If this was happening during your low battery test it would be why you never shutdown. Stale data isn't used by nut.

I looked in to changing the value with upsrw, but along the way found it's normal for some UPS' "battery charge low" to actually mean empty, or perhaps shutting off early to prevent some sort of damage resulting from a completely drained battery.
Is this true for your generation APC Back-UPS CS 500?

thought the entire output of upsc would mostly be chaff, my mistake.
I wouldn't know until I actually see it. ;)

There also is an upsd.users, which needs to be configured for upsrw, but no need to post it. The rest of the configs look correct. I would change the port to auto, as in type auto into the field in the GUI. When you test again keep a SSH session open as you will then see the WALL notifications. Also, use upsc to see what ups.status is reporting.
 

BlueDan

Cadet
Joined
Sep 15, 2013
Messages
4
Right, I finally had some more time for this.

Re stale data: it was still reporting. This is how I knew it was going too low and not shutting down before power was lost. I haven't had any comms problems since (it really does seem to be completely random) - at least I get an email report about it.

I tried the driver from the bug tracker comments, it didn't work:
Sep 24 14:28:13 freenas notifier: /libexec/ld-elf.so.1: /usr/local/libexec/nut/usbhid-ups: Undefined symbol "_ThreadRuneLocale"
When trying to start the UPS service. Some brief Googling gives me the impression ld-elf.so is a software library, or acts in a similar fashion? And perhaps the underlying version of FreeBSD is different between FreeNAS 8 and 9 (the fix posted was meant for 9). Reverted the driver.

I tried using upsrw to set battery.power.low to 35 - it reports OK, and this is reflected in the report given by upsc ups@localhost. Disconnect the mains power and FreeNAS cleanly shuts down at 34% - it seems it goes down when the battery percentage is less than battery.power.low, not when it is at that figure. Plus email reports for LOWBATT and SHUTDOWN.

However, after rebooting, battery.power.low is back to 10 (even though the UPS hasn't been power cycled). Am I meant to do something else to fix the new settings in place, or will I have to add something to run upsrw at startup?
 

BlueDan

Cadet
Joined
Sep 15, 2013
Messages
4
Oh, and if you manually edit upsd.users and restart the UPS service from the web GUI, it overwrites it again - I hadn't noticed that new users should be added in the config there instead. Found out after manually editing the file, having it reset when restarting the service, mounting the FS as rw, editing again, mounting as read only, having it reset again, pulling hair out, etc.
 

aribs

Dabbler
Joined
Mar 21, 2016
Messages
25
How do you set the value to 35 using upsrw?

I have tried using the following and it didn't work

upsrw -s battery.charge.low=20 pfups (it asks me for user and password which was entered according to upsd.user)
I then receive the following error

Unexpected response from upsd: ERR ACCESS-DENIED

I am not sure what is going on... Can anybody help.

Thanks in advance.

Tried this too...

upsrw -u mynutuser -p mynutpassword -s battery.charge.low=20 myups

my current output is the following

[battery.charge.low]
Remaining battery level when UPS switches to LB (percent)
Type: STRING
Maximum length: 10
Value: 10

This is not enough time to shutdown once the battery is at critical. I want it to issue a warning at 20% or even 30% battery remaining so it can shutdown safely.

Thanks again.
 
Status
Not open for further replies.
Top