David White
2019-Jul-18 20:28 UTC
[Nut-upsuser] Another New User Question - Notify Script Not Running
<html> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1252"> </head> <body bgcolor="#FFFFFF" text="#000000"> <font size="-1">Hello and thanks in advance for any help/tips. I am still new to nut but thanks to help here, I have managed to get my Ubuntu (chrooted on Android) to run both nut-server and nut-client without obvious complaints. So now I am trying to move on to getting the desired results when the UPS goes and stays on battery for at least 20 seconds. After looking here <a class="moz-txt-link-rfc2396E" href="https://networkupstools.org/docs/user-manual.chunked/ar01s07.html"><https://networkupstools.org/docs/user-manual.chunked/ar01s07.html></a> I am taking the simple approach - where my own script. Salient lines from the upsmon.conf are:<br> <br> NOTIFYCMD? /home/android/nutShutdown.sh<br> NOTIFYMSG? ONBATT? "USP %s on battery"<br> NOTIFYFLAG? ONBATT? EXEC<br> <br> The script file is rwx for all. So I do not think this is a permission issue (but certainly could be wrong).<br> <br> When I pull the battery nothing at all seems to happen. From an ssh terminal into the nut machine I can see the status go from O: to OB using upsc. But the script does not seem to get run.<br> <br> If I stop the nut-client service and instead run:<br> <br> ? /sbin/upsmon -DD<br> <br> (just from my logged in, non-priv user) I see the following:<br> <br> Network UPS Tools upsmon 2.7.1<br> ?? 0.000000???? fopen /var/run/nut/upsmon.pid: Permission denied<br> ?? 0.002205???? UPS: belkinusb@localhost (master) (power value 1)<br> ?? 0.004246???? Using power down flag file /etc/killpower<br> ?? 0.006807???? debug level is '2'<br> ?? 0.011487???? writepid: fopen /var/run/nut/upsmon.pid: Permission denied<br> ?? 0.000000???? Init SSL without certificate database<br> ?? 0.020224???? Trying to connect to UPS [belkinusb@localhost]<br> ?? 0.023170???? Logged into UPS belkinusb@localhost<br> ?? 0.023848???? pollups: belkinusb@localhost<br> ?? 0.024349???? parse_status: [OL]<br> ?? 5.024659???? pollups: belkinusb@localhost<br> ?? 5.026220???? parse_status: [OL]<br> ? 10.026791???? pollups: belkinusb@localhost<br> ? 10.028193???? parse_status: [OL]<br> ? 15.028838???? pollups: belkinusb@localhost<br> ? 15.030312???? parse_status: [OL]<br> ? 20.030886???? pollups: belkinusb@localhost<br> ? 20.032332???? parse_status: [OL]<br> ? 25.032913???? pollups: belkinusb@localhost<br> ? 25.034352???? parse_status: [OL]<br> ? 30.034942???? pollups: belkinusb@localhost<br> ? 30.036362???? parse_status: [OB]<br> ? 30.036722???? do_notify: ntype 0x0001 (ONBATT)<br> ? 35.038787???? pollups: belkinusb@localhost<br> ? 35.040404???? parse_status: [OB]<br> ? 40.040951???? pollups: belkinusb@localhost<br> ? 40.042425???? parse_status: [OB]<br> ? 45.042959???? pollups: belkinusb@localhost<br> ? 45.044429???? parse_status: [OB]<br> ? 50.044987???? pollups: belkinusb@localhost<br> ? 50.046388???? parse_status: [OB]<br> Init SSL without certificate database<br> SSHDroid<br> Use 'root' as username<br> Default password is 'admin'<br> Broadcasting: Intent { act=net.dinglisch.android.tasker.ACTION_TASK (has extras) }<br> Broadcast completed: result=0<br> Host key verification failed.<br> ? 55.046956???? pollups: belkinusb@localhost<br> ? 55.048372???? parse_status: [OB]<br> ? 60.049089???? pollups: belkinusb@localhost<br> ? 60.050535???? parse_status: [OB]<br> ? 65.051094???? pollups: belkinusb@localhost<br> ? 65.052528???? parse_status: [OB]<br> ? 70.053080???? pollups: belkinusb@localhost<br> ? 70.054476???? parse_status: [OB]<br> ? 75.055163???? pollups: belkinusb@localhost<br> ? 75.056574???? parse_status: [OB]<br> ? 80.057116???? pollups: belkinusb@localhost<br> ? 80.058570???? parse_status: [OB]<br> ? 85.059128???? pollups: belkinusb@localhost<br> ? 85.060598???? parse_status: [OB]<br> ? 90.061145???? pollups: belkinusb@localhost<br> ? 90.062614???? parse_status: [OL]<br> ? 90.063042???? do_notify: ntype 0x0000 (ONLINE)<br> ? 90.063510???? UPS belkinusb@localhost on line power<br> <br> Broadcast Message from android@loca<br> ??????? (/dev/pts/3) at 12:40 ...<br> <br> UPS belkinusb@localhost on line power<br> <br> ? 95.065644???? pollups: belkinusb@localhost<br> ? 95.067137???? parse_status: [OL]<br> ?100.067768???? pollups: belkinusb@localhost<br> ?100.069213???? parse_status: [OL]<br> ?105.069749???? pollups: belkinusb@localhost<br> ?105.071212???? parse_status: [OL]<br> ?110.071787???? pollups: belkinusb@localhost<br> ?110.073226???? parse_status: [OL]<br> ?115.073777???? pollups: belkinusb@localhost<br> ?115.075471???? parse_status: [OL]<br> ?120.076043???? pollups: belkinusb@localhost<br> ?120.077450???? parse_status: [OL]<br> ?125.078037???? pollups: belkinusb@localhost<br> ?125.079492???? parse_status: [OL]<br> <br> After line </font><font size="-1">50.046388?</font>I am seeing output from my script. So at least in this scenario, things appear to be working.<br> <br> Yet with service nut-client start'ed this doesn't seem to happen. Using:<br> <br> ??? ps -ef | grep nut<br> <br> I see entries for the blazer_usb driver, /sbin/upsd, and sbin/upsmon. They are all running as user:<br> <br> ? nut<br> <br> So I immediately thought to check permissions on the script file and, as said above, they are rwx all. So I doubt this is the problem.<br> <br> Any thoughts/comments?<br> <br> Cheers<br> <br> </body> </html>
Roger Price
2019-Jul-18 22:38 UTC
[Nut-upsuser] Another New User Question - Notify Script Not Running
On Thu, 18 Jul 2019, David White wrote:> NOTIFYCMD? /home/android/nutShutdown.sh > NOTIFYMSG? ONBATT? "USP %s on battery" > NOTIFYFLAG? ONBATT? EXECPerhaps before plunging into upsmon debugging, and debugging your own custom NOTIFYCMD script, you could get the basic notifications of upsmon working using more complete NOTIFYFLAG and NOTIFYMSG declarations covering all situations. You will then have a clearer view in the log of what is happening. Why don't you have the SYSLOG option on the NOTIFYFLAG ONBATT declaration? Can you call the nutShutdown.sh script from the command line as the user running upsmon? If you need a custom Shutdown Plan, then why not use upssched? I would also suggest increasing the log output of your script to identify and present more clearly what is happening in the script, for example by including the UPS status and charge. This will help you debug the script. Roger
David White
2019-Jul-20 00:37 UTC
[Nut-upsuser] Another New User Question - Notify Script Not Running
Roger, Thanks for the idea to add additional items to the notifyflag. That proved the monitor was indeed working as expected and led me to find that my script had myriad issues when run under the nut user. All remedied now. As I progress, I may well end up migrating to the upssched. As a newbie I was simply following the documented "simple" way described here <https://networkupstools.org/docs/user-manual.chunked/ar01s07.html>. Thanks to all! On 7/18/2019 3:38 PM, Roger Price wrote:> On Thu, 18 Jul 2019, David White wrote: > >> NOTIFYCMD? /home/android/nutShutdown.sh >> NOTIFYMSG? ONBATT? "USP %s on battery" >> NOTIFYFLAG? ONBATT? EXEC > > Perhaps before plunging into upsmon debugging, and debugging your own > custom NOTIFYCMD script, you could get the basic notifications of upsmon > working using more complete NOTIFYFLAG and NOTIFYMSG declarations > covering all situations. You will then have a clearer view in the log of > what is happening. Why don't you have the SYSLOG option on the > NOTIFYFLAG ONBATT declaration? > > Can you call the nutShutdown.sh script from the command line as the user > running upsmon? > > If you need a custom Shutdown Plan, then why not use upssched? > > I would also suggest increasing the log output of your script to > identify and present more clearly what is happening in the script, for > example by including the UPS status and charge. This will help you debug > the script. > > Roger > > > _______________________________________________ > Nut-upsuser mailing list > Nut-upsuser at alioth-lists.debian.net > https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser