On Tue, 21 Mar 2017, Arnaud Quette wrote:

Hi Roger,

reviving this discussion, since we have a Github ticket for 2.7.5:
https://github.com/networkupstools/nut/issues/293
...
I've made some additions to clarify things on the timer, and complete the 
script:
https://github.com/networkupstools/nut/compare/upssched-doc?expand=1

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

    AT ONBATT * START-TIMER onbattwarn 30
    AT ONLINE * CANCEL-TIMER onbattwarn

      Is there some other way of forcing routine cancel_timer from a script or 
a configuration file?

this is the last point to address, but I'd need to better understand prior to 
potentially taking action:
theoretically, each event that triggers a timer (like ONBATT) has a counterpart 
to cancel it (like ONLINE).
Ex (from the doc):
    AT ONBATT * START-TIMER onbattwarn 30
    AT ONLINE * CANCEL-TIMER onbattwarn

So is there any use case we're missing here?

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.

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.

To solve the problem of cancelling an arbitrary timer from a script such as upssched-cmd, I submitted a proposal to nut-upsdev:

   [Nut-upsdev] Proposal for technique to stop a timer at any moment
https://lists.alioth.debian.org/pipermail/nut-upsdev/2016-July/007202.html

and a set of patches :

https://lists.alioth.debian.org/pipermail/nut-upsdev/2016-July/007203.html
https://lists.alioth.debian.org/pipermail/nut-upsdev/2016-July/007204.html

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

   AT SIGUSR1 * CANCEL-TIMER shutdown-timer

Will my patches be included in NUT?

Roger
_______________________________________________
Nut-upsuser mailing list
Nut-upsuser@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsuser

Reply via email to