<div dir="auto">I wonder if you refer to <a href="https://nut-upsuser.alioth.debian.narkive.com/Fj636tRZ/support-of-shutdown-return-on-a-apc-back-ups-cs-500">https://nut-upsuser.alioth.debian.narkive.com/Fj636tRZ/support-of-shutdown-return-on-a-apc-back-ups-cs-500</a> discussion from a decade ago...<div dir="auto"><br></div><div dir="auto">Essentially, with the command you tell the UPS to cut power in X seconds from now (some may not support it at all, some may have effective minimal units e.g. some CPS use whole 30 or 60 second chunks - so asking to go down in 59 sec often means immediately in fact).</div><div dir="auto"><br></div><div dir="auto">This is a risky thing to request while the OS just begins a shutdown and would take indeterminate time to stop all services and unmount filesystems.<br><br></div><div dir="auto">Traditionally NUT "killpower" handling was injected into the end of (init/rc-script driven) shutdown routine. While the drivers and upsd were stopped as any other services, another copy of the driver is spawned in the final seconds to tell the ups to cut power (on the primary server in upsmon terms).</div><div dir="auto"><br></div><div dir="auto">Often this part of code also deals with a "power race condition" (on all clients) - as your systems take time to go down, wall power may return and some UPS models may refuse to continue emergency power off. Power consumers should wait "a lot" (more time than the UPS provides normally) and reboot.</div><div dir="auto"><br></div><div dir="auto">Nowadays systemd allows shutdown hooks for similar effect, other frameworks (e.g. SMF) might not. Anyhow these tricks may be time-limited by the framework ("we were asked to go down, so `killall -9` after X sec").</div><div dir="auto"><br></div><div dir="auto">Still, wondering what was "too convoluted" with standard upsmon? What could be done better? Note recent ML discussions about `upssched` use that may allow for finer-grained reaction (but that is tangentially related and may be "convoluted" indeed). </div><div dir="auto"><br></div><div dir="auto">Hope this helps,</div><div dir="auto">Jim Klimov</div><div dir="auto"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jan 1, 2023, 10:41 Gennadiy Poryev via Nut-upsuser <<a href="mailto:nut-upsuser@alioth-lists.debian.net">nut-upsuser@alioth-lists.debian.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all and happy new year!<br>
<br>
I have a server minifarm at home but it's Kyiv/Ukraine so wall power <br>
goes on and off unexpectedly quite a few times a day. What I want is for <br>
servers to gracefully start when power appears and gracefully shut down <br>
when it disappears.<br>
<br>
To that end I've got some APC Back-UPS RS 1000, set up an usbhid-ups <br>
driver and upsd. upsmon configuration turned out to be too convoluted so <br>
I decided to write my own custom solution, since the protocol is fairly <br>
simple.<br>
<br>
So the daemon I wrote connects to upsd and monitors input.voltage and <br>
ups.status. BTW had to override pollinterval = 1 and pollfreq = 1 in <br>
ups.conf to make input.voltage report input voltage in more or less <br>
real-time instead of cached.<br>
<br>
The code logic is such that as soon as input.voltage goes below <br>
input.transfer.low and ups.status goes from OL to OB the farm shutdown <br>
is initiated and ups is issued INSTCMD load.off.delay command and is <br>
smart enough to shut itself down too.<br>
<br>
So far this part of the project works OK -- the farm turns itself off <br>
nicely and unattended.<br>
<br>
BUT.<br>
<br>
There seem to be lack of facility to do shutdown.return though. Still <br>
have to to that manually each time.<br>
<br>
I've attached upsc/upscmd/upsrw outputs but so far haven't figured out a <br>
combination that might do the trick. Provided my UPS can do it, of <br>
course, but why shouldn't it?<br>
<br>
From what I've read in the certain discussion on this maillist that <br>
occurred 12 years ago and from nut documentation I suspect the hope is <br>
not lost and it is possible to somehow hack in proper shutdown.return<br>
<br>
But my expertise ends here. Should anyone help me run all the debug mode <br>
magic I've read of and make good use of it, my thankfullness will have <br>
no bounds.<br>
<br>
Best regards,<br>
<br>
G.<br>
_______________________________________________<br>
Nut-upsuser mailing list<br>
<a href="mailto:Nut-upsuser@alioth-lists.debian.net" target="_blank" rel="noreferrer">Nut-upsuser@alioth-lists.debian.net</a><br>
<a href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser" rel="noreferrer noreferrer" target="_blank">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a><br>
</blockquote></div>