<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> </head> <body smarttemplateinserted="true"> <div id="smartTemplate4-template"><font size="2" face="Verdana">Hi Roger,<br> <br> /sbin/upssched is the standard binary that installs with the Debian NUT package. From my understanding, /sbin/upssched then calls CMDSCRIPT (in my case, /etc/nut/upssched-cmd) passing some parameters to that script. Here is my /etc/nut/upssched-cmd:<br> </font> <blockquote><font size="2"><tt>#!/bin/bash</tt></font><br> <font size="2"><tt>#</tt></font><br> <font size="2"><tt># This script should be called by upssched via the CMDSCRIPT directive.</tt></font><br> <font size="2"><tt>#</tt></font><br> <font size="2"><tt># Here is a quick example to show how to handle a bunch of possible</tt></font><br> <font size="2"><tt># timer names with the help of the case structure.</tt></font><br> <font size="2"><tt>#</tt></font><br> <font size="2"><tt># This script may be replaced with another program without harm.</tt></font><br> <font size="2"><tt>#</tt></font><br> <font size="2"><tt># The first argument passed to your CMDSCRIPT is the name of the timer</tt></font><br> <font size="2"><tt># from your AT lines.</tt></font><br> <font size="2"><tt>OPTION="$1"</tt></font><br> <font size="2"><tt>SCRIPT="$0"</tt></font><br> <br> <font size="2"><tt>logger -t $SCRIPT "Script called with arg $OPTION"</tt></font><br> <br> <font size="2"><tt>case $OPTION in</tt></font><br> <font size="2"><tt> lowbatt)</tt></font><br> <font size="2"><tt> MSG="NUT upssched \"lowbatt\" sequence start: UPS Low Battery; Begin shutting down clients"</tt></font><br> <font size="2"><tt> echo "$SCRIPT: $MSG"</tt></font><br> <font size="2"><tt> logger -t $SCRIPT "$MSG"</tt></font><br> <font size="2"><tt> /etc/nut/scripts/shutdown-control &</tt></font><br> <font size="2"><tt> MSG="NUT upssched \"lowbatt\" sequence initiated"</tt></font><br> <font size="2"><tt> echo "$SCRIPT: $MSG"</tt></font><br> <font size="2"><tt> logger -t $SCRIPT "$MSG"</tt></font><br> <font size="2"><tt> ;;</tt></font><br> <font size="2"><tt> onbatt)</tt></font><br> <font size="2"><tt> logger -t $SCRIPT "UPS on battery"</tt></font><br> <font size="2"><tt> ;;</tt></font><br> <font size="2"><tt> online)</tt></font><br> <font size="2"><tt> logger -t $SCRIPT "UPS power restored and back online"</tt></font><br> <font size="2"><tt> ;;</tt></font><br> <font size="2"><tt> upsgone)</tt></font><br> <font size="2"><tt> logger -t $SCRIPT "The UPS has been gone for awhile"</tt></font><br> <font size="2"><tt> ;;</tt></font><br> <font size="2"><tt> *)</tt></font><br> <font size="2"><tt> logger -t $SCRIPT "Unrecognized arg: $OPTION"</tt></font><br> <font size="2"><tt> ;;</tt></font><br> <font size="2"><tt>esac</tt></font><br> <br> <font size="2"><tt>exit 0</tt></font><br> </blockquote> <font size="2" face="Verdana"><br> The shutdown-control script shuts down multiple Windows desktops and NAS devices when the "lowbatt" state is triggered by NUT.<br> <br> But if I understand the question correctly, I think we're getting ahead of ourselves.<br> <br> The driver is giving this incorrect response (simulated for illustration purposes - not actual):<br> </font><font size="2"><tt>$ upsc myups1</tt><tt><br> </tt><tt>Init SSL without certificate database</tt><tt><br> </tt><tt>battery.charge: 1</tt><tt><br> </tt><tt>...</tt></font><font size="2" face="Verdana"><br> <br> I don't think there's any turning back unless I can get the NUT upsmon to retry or wait for a second POLLFREQ interval. Let me know your thoughts and appreciate the help.<br> <br> Thanks,<br> -MikeD<br> </font></div> <br> <div id="smartTemplate4-quoteHeader"> <hr> <font size="2" face="Consolas"> <b>Date:</b> Saturday, May 25, 2019, at 09:52:13 AM PDT (GMT/UMT -0700)<br> <b>From:</b> Roger Price <a class="moz-txt-link-rfc2396E" href="mailto:roger@rogerprice.org"><roger@rogerprice.org></a><br> <b>To:</b> Nut Users <a class="moz-txt-link-rfc2396E" href="mailto:nut-upsuser@alioth-lists.debian.net"><nut-upsuser@alioth-lists.debian.net></a><br> <b>Subject:</b> Re: [Nut-upsuser] Low Battery False Alarms<br> </font> <br> </div> <div class="replaced-blockquote" cite="mid:alpine.LSU.2.20.1905251849000.43054@titan" type="cite">On Sat, 25 May 2019, Mike Dillinger wrote: <br> <br> <blockquote type="cite">I have a CyberPower 1350VA and it's around 2 to 3 years old. I'm seeing random occurrences of low battery false alarm indicators with a battery supply of 1%. I would assume this means the unit needs replacement, but in the meantime, is there any way I can ask upsmon to verify with two consecutive POLLFREQ intervals? Meaning, try again one more time. <br> </blockquote> <br> What does your /sbin/upssched look like? Do you EXECUTE a further script on AT LOWBATT? <br> <br> Roger<br> <br> <fieldset class="mimeAttachmentHeader"></fieldset> <pre class="moz-quote-pre" wrap="">_______________________________________________ Nut-upsuser mailing list <a class="moz-txt-link-abbreviated" href="mailto:Nut-upsuser@alioth-lists.debian.net">Nut-upsuser@alioth-lists.debian.net</a> <a class="moz-txt-link-freetext" href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a></pre> </div> <br> </body> </html>
On Sat, 25 May 2019, Mike Dillinger wrote: How about something like this:> case $OPTION in > lowbatt)MSG="NUT upssched \"lowbatt\" confirmation begins. Waiting for 5 seconds" echo "$SCRIPT: $MSG" logger -t $SCRIPT "$MSG" Wait for 5 seconds CHARGE=$( upsc <myups> battery.charge ) if CHARGE ok then exit from script> MSG="NUT upssched \"lowbatt\" sequence start: UPS Low Battery; Begin shutting down clients" > echo "$SCRIPT: $MSG" > logger -t $SCRIPT "$MSG" > /etc/nut/scripts/shutdown-control & > MSG="NUT upssched \"lowbatt\" sequence initiated" > echo "$SCRIPT: $MSG" > logger -t $SCRIPT "$MSG" > ;;...> esac > exit 0
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> </head> <body smarttemplateinserted="true"> <div id="smartTemplate4-template"><font size="2" face="Verdana">Hi Roger,<br> <br> Your previous reply got me thinking in this direction too, although I came up with a slightly different approach. Thanks for the help and suggestion. Below is what I came up with.<br> <br> </font><font size="2"><tt>#!/bin/bash</tt><tt><br> </tt><tt>#</tt><tt><br> </tt><tt># This script should be called by upssched via the CMDSCRIPT directive.</tt><tt><br> </tt><tt>#</tt><tt><br> </tt><tt># Here is a quick example to show how to handle a bunch of possible</tt><tt><br> </tt><tt># timer names with the help of the case structure.</tt><tt><br> </tt><tt>#</tt><tt><br> </tt><tt># This script may be replaced with another program without harm.</tt><tt><br> </tt><tt>#</tt><tt><br> </tt><tt># The first argument passed to your CMDSCRIPT is the name of the timer</tt><tt><br> </tt><tt># from your AT lines.</tt><tt><br> </tt><tt>OPTION="$1"</tt><tt><br> </tt><tt>SCRIPT="$0"</tt><tt><br> </tt><tt><br> </tt><tt>function MyLogging () {</tt><tt><br> </tt><tt> echo "$1"</tt><tt><br> </tt><tt> logger -t $SCRIPT $1</tt><tt><br> </tt><tt>}</tt><tt><br> </tt><tt><br> </tt><tt>function Shutdown () {</tt><tt><br> </tt><tt> MyLogging "NUT upssched \"lowbatt\" sequence start: UPS Low Battery; Begin shutting down clients"</tt><tt><br> </tt><tt> /etc/nut/scripts/shutdown-control &</tt><tt><br> </tt><tt> MyLogging "NUT upssched \"lowbatt\" sequence initiated"</tt><tt><br> </tt><tt>}</tt><tt><br> </tt><tt><br> </tt><tt>MyLogging "Script called with arg $OPTION"</tt><tt><br> </tt><tt><br> </tt><tt>UPS_STATE=$(upsc myups1@localhost:3493 ups.status)</tt><tt><br> </tt><tt>MyLogging "NUT upsmon UPS state: $UPS_STATE"</tt><tt><br> </tt><tt><br> </tt><tt>BAT_PERCENT=$(upsc myups1@localhost:3493 battery.charge)</tt><tt><br> </tt><tt>MyLogging "NUT upsmon battery percent: $BAT_PERCENT"</tt><tt><br> </tt><tt><br> </tt><tt>case $OPTION in</tt><tt><br> </tt><tt> lowbatt)</tt><tt><br> </tt><tt> if [[ $UPS_STATE =~ "OL" ]]; then</tt><tt><br> </tt><tt> SLEEP_TIME=6</tt><tt><br> </tt><tt> MyLogging "NUT upsmon set \"lowbatt\" state and \"online\" state together - Perform extra checks before initiating shutdown"</tt><tt><br> </tt><tt> MyLogging "Sleep $SLEEP_TIME seconds and check UPS status again"</tt><tt><br> </tt><tt> sleep $SLEEP_TIME</tt><tt><br> </tt><tt> UPS_STATE_2=$(upsc myups1@localhost:3493 ups.status)</tt><tt><br> </tt><tt> MyLogging "NUT upsmon UPS state: $UPS_STATE_2"</tt><tt><br> </tt><tt> if [[ $UPS_STATE_2 =~ "LB" ]]; then</tt><tt><br> </tt><tt> Shutdown</tt><tt><br> </tt><tt> else</tt><tt><br> </tt><tt> MyLogging "\"LB\" not in UPS state string after retry - Not performing shutdown"</tt><tt><br> </tt><tt> fi</tt><tt><br> </tt><tt> else</tt><tt><br> </tt><tt> Shutdown</tt><tt><br> </tt><tt> fi</tt><tt><br> </tt><tt> ;;</tt><tt><br> </tt><tt> onbatt)</tt><tt><br> </tt><tt> MyLogging "UPS on battery"</tt><tt><br> </tt><tt> ;;</tt><tt><br> </tt><tt> online)</tt><tt><br> </tt><tt> MyLogging "UPS power restored and back online"</tt><tt><br> </tt><tt> ;;</tt><tt><br> </tt><tt> upsgone)</tt><tt><br> </tt><tt> MyLogging "The UPS has been gone for awhile"</tt><tt><br> </tt><tt> ;;</tt><tt><br> </tt><tt> *)</tt><tt><br> </tt><tt> MyLogging "Unrecognized arg: $OPTION"</tt><tt><br> </tt><tt> ;;</tt><tt><br> </tt><tt>esac</tt><tt><br> </tt><tt><br> </tt><tt>exit 0</tt><tt><br> </tt></font><font size="2" face="Verdana"><br> Thanks again!<br> -MikeD<br> </font></div> <br> <div id="smartTemplate4-quoteHeader"> <hr> <font size="2" face="Consolas"> <b>Date:</b> Sunday, May 26, 2019, at 02:26:31 AM PDT (GMT/UMT -0700)<br> <b>From:</b> Roger Price <a class="moz-txt-link-rfc2396E" href="mailto:roger@rogerprice.org"><roger@rogerprice.org></a><br> <b>To:</b> Nut Users <a class="moz-txt-link-rfc2396E" href="mailto:nut-upsuser@alioth-lists.debian.net"><nut-upsuser@alioth-lists.debian.net></a><br> <b>Subject:</b> Re: [Nut-upsuser] Low Battery False Alarms<br> </font> <br> </div> <div class="replaced-blockquote" cite="mid:alpine.LSU.2.20.1905261117330.43054@titan" type="cite">On Sat, 25 May 2019, Mike Dillinger wrote: <br> <br> How about something like this: <br> <br> <blockquote type="cite"> case $OPTION in <br> lowbatt) <br> </blockquote> MSG="NUT upssched \"lowbatt\" confirmation begins. Waiting for 5 seconds" <br> echo "$SCRIPT: $MSG" <br> logger -t $SCRIPT "$MSG" <br> Wait for 5 seconds <br> CHARGE=$( upsc <myups> battery.charge ) <br> if CHARGE ok then exit from script <br> <blockquote type="cite"> MSG="NUT upssched \"lowbatt\" sequence start: UPS Low Battery; Begin shutting down clients" <br> echo "$SCRIPT: $MSG" <br> logger -t $SCRIPT "$MSG" <br> /etc/nut/scripts/shutdown-control & <br> MSG="NUT upssched \"lowbatt\" sequence initiated" <br> echo "$SCRIPT: $MSG" <br> logger -t $SCRIPT "$MSG" <br> ;; <br> </blockquote> ... <br> <blockquote type="cite"> esac <br> exit 0<br> </blockquote> <br> <fieldset class="mimeAttachmentHeader"></fieldset> <pre class="moz-quote-pre" wrap="">_______________________________________________ Nut-upsuser mailing list <a class="moz-txt-link-abbreviated" href="mailto:Nut-upsuser@alioth-lists.debian.net">Nut-upsuser@alioth-lists.debian.net</a> <a class="moz-txt-link-freetext" href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a></pre> </div> <br> </body> </html>