[Nut-upsuser] shutdown.return from a custom client

Gennadiy Poryev vecanoi at gmail.com
Sun Jan 1 09:12:29 GMT 2023


Hi all and happy new year!

I have a server minifarm at home but it's Kyiv/Ukraine so wall power 
goes on and off unexpectedly quite a few times a day. What I want is for 
servers to gracefully start when power appears and gracefully shut down 
when it disappears.

To that end I've got some APC Back-UPS RS 1000, set up an usbhid-ups 
driver and upsd. upsmon configuration turned out to be too convoluted so 
I decided to write my own custom solution, since the protocol is fairly 
simple.

So the daemon I wrote connects to upsd and monitors input.voltage and 
ups.status. BTW had to override pollinterval = 1 and pollfreq = 1 in 
ups.conf to make input.voltage report input voltage in more or less 
real-time instead of cached.

The code logic is such that as soon as input.voltage goes below 
input.transfer.low and ups.status goes from OL to OB the farm shutdown 
is initiated and ups is issued INSTCMD load.off.delay command and is 
smart enough to shut itself down too.

So far this part of the project works OK -- the farm turns itself off 
nicely and unattended.

BUT.

There seem to be lack of facility to do shutdown.return though. Still 
have to to that manually each time.

I've attached upsc/upscmd/upsrw outputs but so far haven't figured out a 
combination that might do the trick. Provided my UPS can do it, of 
course, but why shouldn't it?

 From what I've read in the certain discussion on this maillist that 
occurred 12 years ago and from nut documentation I suspect the hope is 
not lost and it is possible to somehow hack in proper shutdown.return

But my expertise ends here. Should anyone help me run all the debug mode 
magic I've read of and make good use of it, my thankfullness will have 
no bounds.

Best regards,

G.
-------------- next part --------------
upsc

battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 50
battery.date: 2001/09/25
battery.mfr.date: 2007/07/20
battery.runtime: 105
battery.runtime.low: 120
battery.type: PbAc
battery.voltage: 26.8
battery.voltage.nominal: 24.0
device.mfr: American Power Conversion
device.model: Back-UPS RS 1000
device.serial: 8B0729R16742
device.type: ups
driver.name: usbhid-ups
driver.parameter.pollfreq: 1
driver.parameter.pollinterval: 1
driver.parameter.port: auto
driver.parameter.synchronous: auto
driver.version: 2.8.0-Windows-190-g9fb8d6d5f
driver.version.data: APC HID 0.100
driver.version.internal: 0.49
driver.version.usb: libusb-1.0.26 (API: 0x1000109)
input.sensitivity: medium
input.transfer.high: 264
input.transfer.low: 194
input.transfer.reason: input voltage out of range
input.voltage: 226.0
input.voltage.nominal: 230
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.firmware: 7.g9a.I
ups.firmware.aux: g9a
ups.load: 14
ups.mfr: American Power Conversion
ups.mfr.date: 2007/07/20
ups.model: Back-UPS RS 1000
ups.productid: 0002
ups.realpower.nominal: 600
ups.serial: 8B0729R16742
ups.status: OL LB
ups.test.result: No test initiated
ups.timer.reboot: 0
ups.timer.shutdown: -1
ups.vendorid: 051d

upscmd
Instant commands supported on UPS [NorkaPower]:

beeper.disable - Disable the UPS beeper
beeper.enable - Enable the UPS beeper
beeper.mute - Temporarily mute the UPS beeper
beeper.off - Obsolete (use beeper.disable or beeper.mute)
beeper.on - Obsolete (use beeper.enable)
load.off - Turn off the load immediately
load.off.delay - Turn off the load with a delay (seconds)
shutdown.reboot - Shut down the load briefly while rebooting the UPS
shutdown.stop - Stop a shutdown in progress
test.battery.start.deep - Start a deep battery test
test.battery.start.quick - Start a quick battery test
test.battery.stop - Stop the battery test
test.panel.start - Start testing the UPS panel
test.panel.stop - Stop a UPS panel test

upsrw

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

[battery.mfr.date]
Battery manufacturing date
Type: STRING
Maximum length: 10
Value: 2007/07/20

[battery.runtime.low]
Remaining battery runtime when UPS switches to LB (seconds)
Type: STRING
Maximum length: 10
Value: 120

[input.sensitivity]
Input power sensitivity
Type: STRING
Maximum length: 10
Value: medium

[input.transfer.high]
High voltage transfer point (V)
Type: STRING
Maximum length: 10
Value: 264

[input.transfer.low]
Low voltage transfer point (V)
Type: STRING
Maximum length: 10
Value: 194

[ups.delay.shutdown]
Interval to wait after shutdown with delay command (seconds)
Type: STRING
Maximum length: 10
Value: 20


More information about the Nut-upsuser mailing list