<div dir="ltr">Hi Roger<br><div><div class="gmail_extra"><br><div class="gmail_quote">2017-03-21 19:34 GMT+01:00 Roger Price <span dir="ltr"><<a target="_blank" href="mailto:roger@rogerprice.org">roger@rogerprice.org</a>></span>:<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><span class="gmail-">On Tue, 21 Mar 2017, Arnaud Quette wrote:<br>
<br>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
Hi Roger,<br>
<br>
reviving this discussion, since we have a Github ticket for 2.7.5:<br>
<a target="_blank" rel="noreferrer" href="https://github.com/networkupstools/nut/issues/293">https://github.com/networkupst<wbr>ools/nut/issues/293</a><br>
</blockquote></span>
... <br><span class="gmail-">
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
I've made some additions to clarify things on the timer, and complete the script:<br>
<a target="_blank" rel="noreferrer" href="https://github.com/networkupstools/nut/compare/upssched-doc?expand=1">https://github.com/networkupst<wbr>ools/nut/compare/upssched-doc?<wbr>expand=1</a><br>
</blockquote>
<br></span>
Hi Arnaud, Your change to the documentation clears up what I had mis-understood.  The new text makes it clear that the upssched timers are an in-memory device, and that they can only be turned on and off with upssched.conf declarations such as<span class="gmail-"><br>
<br>
    AT ONBATT * START-TIMER onbattwarn 30<br>
    AT ONLINE * CANCEL-TIMER onbattwarn<br></span></blockquote><div><br></div><div>thanks for your confirmation. I'll check to merge that PR.<br></div><div> </div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><span class="gmail-">
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
      Is there some other way of forcing routine cancel_timer from a script or a configuration file?<br>
<br>
this is the last point to address, but I'd need to better understand prior to potentially taking action:<br>
theoretically, each event that triggers a timer (like ONBATT) has a counterpart to cancel it (like ONLINE).<br>
Ex (from the doc):<br>
    AT ONBATT * START-TIMER onbattwarn 30<br>
    AT ONLINE * CANCEL-TIMER onbattwarn<br>
<br>
So is there any use case we're missing here?<br>
</blockquote>
<br></span>
My use case was for a UPS unit which gave transient stupid status changes such as "OL DISCHARG CHARG LB" when the battery was 100% charged.  It was an old MGE unit which has since died.<br>
<br>
When the stupid status change occured, the LB began a system shutdown.  To overcome this unwanted stutdown, I wanted to start a 5 second timer, and when this ran out, upssched-cmd would review the situation, and decide if a shutdown was really needed.  If it was not needed, I had to cancel the system-shutdown timer.  I mistakenly assumed that such a timer was a file, and that it was sufficient to erase the file.<br>
<br>
To solve the problem of cancelling an arbitrary timer from a script such as upssched-cmd, I submitted a proposal to nut-upsdev:<br>
<br>
   [Nut-upsdev] Proposal for technique to stop a timer at any moment<br>
<a target="_blank" rel="noreferrer" href="https://lists.alioth.debian.org/pipermail/nut-upsdev/2016-July/007202.html">https://lists.alioth.debian.or<wbr>g/pipermail/nut-upsdev/2016-Ju<wbr>ly/007202.html</a><br>
<br>
and a set of patches :<br>
<br>
<a target="_blank" rel="noreferrer" href="https://lists.alioth.debian.org/pipermail/nut-upsdev/2016-July/007203.html">https://lists.alioth.debian.or<wbr>g/pipermail/nut-upsdev/2016-Ju<wbr>ly/007203.html</a><br>
<a target="_blank" rel="noreferrer" href="https://lists.alioth.debian.org/pipermail/nut-upsdev/2016-July/007204.html">https://lists.alioth.debian.or<wbr>g/pipermail/nut-upsdev/2016-Ju<wbr>ly/007204.html</a><br>
<br>
The technique is very general and is to send SIGUSR1/SIGUSR2 to the upsd daemon.  SIGUSR1 and SIGUSR2 are events just like ONBATT and ONLINE. The patch runs successfully on my opensuse 13.2 box, and solves my problem. In upssched.conf I now have declarations such as<br>
<br>
   AT SIGUSR1 * CANCEL-TIMER shutdown-timer<br>
<br>
Will my patches be included in NUT?<span class="gmail-HOEnZb"><font color="#888888"><br></font></span></blockquote></div><br></div><div class="gmail_extra">Thanks for sharing your use case, and the rationales behind.<br></div><div class="gmail_extra">First, the base point is to be able to cancel a timer anytime, from a command-line, which makes sense (as an extension, the opposite may also be true, to start a timer lively, without the event coming from upsmon).<br><br></div><div class="gmail_extra">I've quickly checked your 2 patches.<br></div><div class="gmail_extra">The solution seems to me not broad enough for injecting upstream. This works nice for a single device / UPS setup, but would not make it when there are more devices, as I get it.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">At first sight, I would more see something injecting into the PIPEFN fifo, i.e. acting the same way upsmon would when calling upssched with the upsname and the triggering event.<br></div><div class="gmail_extra">I think that this can be solved more easily with tools like socat or nc, sending the command directly to the pipe.<br></div><div class="gmail_extra">For example, to cancel the timer "shutdown-timer" from the upssched-cmd script, you would:<br><br>       echo "CANCEL shutdown-timer" | socat - UNIX-CLIENT:/var/run/nut/upssched.pipe<br><br></div><div class="gmail_extra">Please tell me back if such solution would make it for you.<br><br><div class="gmail_extra">I also realize that the distributed sample configuration and scripts do not fully match the doc.<br></div><div class="gmail_extra">I'll make another round of update for this, still on the same branch.<br></div></div><div class="gmail_extra">I would warmly welcome your help to complete the documentation, both with part of your patches that make sense, along with the above solution if it's good too.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">cheers,<br></div><div class="gmail_extra">Arno<br></div><div class="gmail_extra">-- <br><div class="gmail_signature">Eaton Data Center Automation Solutions - Opensource Leader - <a target="_blank" href="http://42ity.org">http://42ity.org</a><br>NUT (Network UPS Tools) Project Leader - <a target="_blank" href="http://www.networkupstools.org">http://www.networkupstools.org</a><br>Debian Developer - <a target="_blank" href="http://www.debian.org">http://www.debian.org</a><br>Free Software Developer - <a target="_blank" href="http://arnaud.quette.fr">http://arnaud.quette.fr</a><br></div>
</div></div></div>