UPS service not shutting FreeNAS down

statalently

Dabbler
Joined
Oct 11, 2019
Messages
35
UPS: Cyberpower ol1500rtxl2u

Hi there,
I have connected my UPS to my FreeNAS server by USB and I see communication using upsc in the shell. However, the FreeNAS does not shut down once the UPS goes on battery. Judging by the logs, the upsmon detects that the UPS goes on battery, then upssched fires a SHUTDOWN event, but nothing more. Can anyone help me please?
Thank you!

Logs
Code:
Jan  9 10:04:31 freenas-bk-new usbhid-ups[14469]: Startup successful
Jan  9 10:04:31 freenas-bk-new upsd[14470]: listening on 0.0.0.0 port 3493
Jan  9 10:04:31 freenas-bk-new upsd[14470]: Connected to UPS [ups]: usbhid-ups-ups
Jan  9 10:04:31 freenas-bk-new upsd[14470]: /usr/local/etc/nut/cmdvartab not found - disabling descriptions
Jan  9 10:04:31 freenas-bk-new upsd[14471]: Startup successful
Jan  9 10:04:31 freenas-bk-new upsmon[14494]: Startup successful
Jan  9 10:04:31 freenas-bk-new upsd[14471]: User upsmon@127.0.0.1 logged into UPS [ups]
Jan  9 10:04:31 freenas-bk-new upslog[14517]: Startup successful
Jan  9 10:05:02 freenas-bk-new upsmon[14495]: UPS ups on battery
Jan  9 10:05:02 freenas-bk-new upssched[14807]: Executing command: EMAIL
Jan  9 10:05:02 freenas-bk-new upssched[14816]: Timer daemon started
Jan  9 10:05:02 freenas-bk-new upssched[14816]: New timer: SHUTDOWN (1 seconds)
Jan  9 10:05:03 freenas-bk-new upssched[14816]: Event: SHUTDOWN
Jan  9 10:05:19 freenas-bk-new upssched[14816]: Timer queue empty, exiting


Services -> UPS -> Settings
  • UPS Mode: Master
  • Cyber Power Systems ups 2 Value 1500ELCD-RU USB (usbhid-ups) (but have tried others)
  • Port: /dev/uhid0 (have also tried ugen1.4)
  • Shutdown mode: UPS goes on battery
  • Shutdown timer: 1 (for testing)
  • Shutdown command: /sbin/shutdown -p now
  • Monitor user: upsmon
  • Monitor password: fixmepass
  • Remote monitor: check
Please note the System configuration in my signature is a different FreeNAS box. If the FreeNAS hardware for this box is relevant, please say and I will post it.
 
Joined
Jan 7, 2015
Messages
1,155
If you look at the FreeNAS terminal and unplug and then replug the UPS it detects it and tells you which port it is. Mine is a similar UPS and is on ugen0.4. However, I agree with you it looks as if it finds it, but cant execute a shutdown. Could be port related? Verify uhid0 is the correct port. See what the output of "upsc <your ups name>@localhost" is.
 
Joined
Jan 7, 2015
Messages
1,155
Heres mine if you want to compare for anything
Code:
root@freenas:# upsc ups@localhost
battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 20
battery.mfr.date: CPS
battery.runtime: 1567
battery.runtime.low: 300
battery.type: PbAcid
battery.voltage: 14.0
battery.voltage.nominal: 12
device.mfr: CPS
device.model:  CP 1350C
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 2
driver.parameter.port: /dev/ugen0.4
driver.parameter.synchronous: no
driver.version: 2.7.4
driver.version.data: CyberPower HID 0.4
driver.version.internal: 0.41
input.transfer.high: 140
input.transfer.low: 90
input.voltage: 123.0
input.voltage.nominal: 120
output.voltage: 122.0
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.delay.start: 30
ups.load: 23
ups.mfr: CPS
ups.model:  CP 1350C
ups.productid: 0501
ups.realpower.nominal: 298
ups.status: OL
ups.test.result: Done and warning
ups.timer.shutdown: -60
ups.timer.start: 0
ups.vendorid: 0764
 

statalently

Dabbler
Joined
Oct 11, 2019
Messages
35
Hi John, thank you for your help.
I have tried ugen1.4 and uhid0 to no avail.

I have been doing a bit more digging and I think I have traced the problem to the /usr/local/sbin/upssched script. It is being called by the upsmon service, but is not sending the shutdown command because it believes the UPS is on line power (plugged in) when it is not.

I'm not great with shell, but I believe the problem line to be:
Code:
if [ -n $(upsc $ident | grep "ups.status.*OL") ]; then
    logger -t upssched-cmd "Shutdown was not initiated as ups.status indicates ${ident} is ONLINE (OL)"


When it calls upsc to get the status, it seems to always evaluate to true, and therefore always go to "Shutdown was not initiated."

Can I change this without messing something up or losing my changes on restart?
 

G8One2

Patron
Joined
Jan 2, 2017
Messages
248
Have you tried to test the battery in the UPS. There is usually a mode you can use to test it. Mine was set to power down on UPS power, but the battery couldnt sustain the load so it shut right off, similar to just pulling the plug. Not good. Wasnt until i replaced the UPS battery before it actually was able to do a proper shut down once it switched to UPS power. Not saying this is your issue, but might be worth looking into, if you dont know the battery condition of your UPS.
 

statalently

Dabbler
Joined
Oct 11, 2019
Messages
35
Thanks for the input G8One2. The battery is quite new, and I have used it in an actual power outage and charged my phone! So I know it can last a good half an hour.
 

statalently

Dabbler
Joined
Oct 11, 2019
Messages
35
Update!
I edited the /usr/local/sbin/custom-upssched-cmd config file.
The code is as follows. Have I broken anything by doing this? Should I be filing it as a bug report? Was the original code not working because I didn't quite have the right driver?

Code:
status="$upsc $ident ups.status)"

case  "${status}" in
    *OL*)
            logger -t upssched-cmd "Not shutting down"
            logger -t upssched-cmd "Status: ${status}"
            
;;
esac

case  "${status}" in
    *OB*)
            logger -t upssched-cmd "issuing shutdown"
            /usr/local/sbin/upsmon -c fsd
;;
esac

 
Top