On Jun 29, 2017, at 6:52 AM, Andrea de Lutti wrote:>>> Anyway I still not receive any email on any test (power cord disconnected and/or reconnected for example) >> >> Oh, I misinterpreted "working script" as a script that was sending email, rather than work-in-progress. Does that same command work from the command line? Can you add something like "logger" before the mailx line to be sure that the script is executing properly? Be sure to "chmod a+x" the script. >> > ?Yep, the script works flawlessy with a command line. It is a "modified" script from other jobs, and I receive daily all the emails from them?Bear in mind that upsmon runs as user "nut" on Ubuntu, as does the NOTIFYCMD script. At one point, you said that the script is in /root, which is not commonly readable by other users. Does the script work if you move it to, say, /usr/local/bin? (With Ubuntu 16.04, there should be some error messages from upsmon in 'journalctl' referencing permissions.)>> >> I forget if I mentioned this earlier, but for testing notifications, you can use the dummy-ups driver: >> >> http://networkupstools.org/docs/man/dummy-ups.html >> >> The timer example will simulate the OL-OB-LB transition. >> > ?Maybe I have missing someting. I have exported my configuration to a .dev file, and then used for dummy ups, configured as dummy. Do i need to make circular tests (timer configuration) or may I do them manually? Just beacuse the only command allowed in dummy mode (upscmd -l dummy at artu) is load.off >Under the Bugs heading, the man page says "Instant commands are not yet supported in Dummy Mode..." - one of the use cases was automated developer testing of NUT, and there isn't much use in simulating all of the commands in that case. "load.off" is probably worth implementing at some point for user testing. So for your use case, the timers would probably be the easiest way with the current code.
> > > Bear in mind that upsmon runs as user "nut" on Ubuntu, as does the > NOTIFYCMD script. At one point, you said that the script is in /root, which > is not commonly readable by other users. Does the script work if you move > it to, say, /usr/local/bin? > > (With Ubuntu 16.04, there should be some error messages from upsmon in > 'journalctl' referencing permissions.) > > ?I have tried running from /etc/nut, now moved in /usr/local...will keepyou informed?> Under the Bugs heading, the man page says "Instant commands are not yet > supported in Dummy Mode..." - one of the use cases was automated developer > testing of NUT, and there isn't much use in simulating all of the commands > in that case. "load.off" is probably worth implementing at some point for > user testing. > > So for your use case, the timers would probably be the easiest way with > the current code.?Ok, I am testing it, thank you? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20170629/517e6c53/attachment.html>
Ok, I am running NUT in dummy mode.
I have added a new ups in ups.conf
[dummy]
    driver = dummy-ups
    port = upsc.dev
    desc = "dummy ups for testing purposes"
upsc.dev has been generated by exporting the Elit configuration.
I have added the monitor line in upsmon.conf and the "exec" flags (all
the
events)
MONITOR dummy at artu 1 user pass master
SHUTDOWNCMD "/sbin/shutdown -h +0"
NOTIFYCMD /usr/local/bin/upssched-script
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG FSD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC
NOTIFYFLAG NOPARENT SYSLOG+WALL+EXEC
The upssched-script is
#! /bin/sh
case "$1" in
    "ONBATT")
        echo "On batt" | mailx -v -r "adelutti at gmail.com"
-s "TEST NUT
object" -S smtp="smtp.gmail.com:587" -S smtp-use-starttls -S
smtp-auth=login -S smtp-auth-user="adelutti at gmail.com" -S
smtp-auth-password="gtmtnqyelhlumyds" -S ssl-verify=ignore
adelutti+server at gmail.com
        ;;
    "ONLINE")
        echo "On power" | mailx -v -r "adelutti at
gmail.com" -s "TEST NUT
object" -S smtp="smtp.gmail.com:587" -S smtp-use-starttls -S
smtp-auth=login -S smtp-auth-user="adelutti at gmail.com" -S
smtp-auth-password="gtmtnqyelhlumyds" -S ssl-verify=ignore
adelutti+server at gmail.com
        ;;
    "LOWBATT")
        echo "LOWBATT" | mailx -v -r "adelutti at gmail.com"
-s "TEST NUT
object" -S smtp="smtp.gmail.com:587" -S smtp-use-starttls -S
smtp-auth=login -S smtp-auth-user="adelutti at gmail.com" -S
smtp-auth-password="gtmtnqyelhlumyds" -S ssl-verify=ignore
adelutti+server at gmail.com
        ;;
    *)
        logger -t upssched-cmd "Unrecognized command: $1"
        ;;
    esac
while upssched.conf is
# Network UPS Tools - upssched.conf sample file
#
#
===========================================================================CMDSCRIPT
/usr/local/bin/upssched-script
PIPEFN /var/run/nut/upssched/upssched.pipe
LOCKFN /var/run/nut/upssched/upssched.lock
AT ONBATT * EXECUTE onbattwarn
AT ONLINE * EXECUTE ups-back-on-power
Running upson in debug mode I can see the change of the status (I have a
cycle of 30 secs for online/batterry/low battery) but the syslog reports
Jul  3 16:17:15 artu upsmon[4685]: UPS dummy at artu on battery
Jul  3 16:17:15 artu upssched-cmd: Unrecognized command: UPS dummy at artu on
battery
Jul  3 16:17:45 artu upsmon[4685]: UPS dummy at artu battery is low
Jul  3 16:17:45 artu upssched-cmd: Unrecognized command: UPS dummy at artu
battery is low
Jul  3 16:18:15 artu upsmon[4685]: UPS dummy at artu on line power
Jul  3 16:18:15 artu upssched-cmd: Unrecognized command: UPS dummy at artu on
line power
Jul  3 16:18:45 artu upsmon[4685]: UPS dummy at artu on battery
Jul  3 16:18:45 artu upssched-cmd: Unrecognized command: UPS dummy at artu on
battery
Jul  3 16:18:57 artu systemd[1]: Started CUPS Scheduler.
Jul  3 16:19:15 artu upsmon[4685]: UPS dummy at artu battery is low
Jul  3 16:19:15 artu upssched-cmd: Unrecognized command: UPS dummy at artu
battery is low
I have tried so many commands, but always the same result...
PS: this evening I will change the battery, I have some standby/cycle
voltage declared by the manufacturer: should I use them?
Thank you,
Regards
Andrea
2017-06-29 14:59 GMT+02:00 Andrea de Lutti <adelutti at gmail.com>:
>
>> Bear in mind that upsmon runs as user "nut" on Ubuntu, as
does the
>> NOTIFYCMD script. At one point, you said that the script is in /root,
which
>> is not commonly readable by other users. Does the script work if you
move
>> it to, say, /usr/local/bin?
>>
>> (With Ubuntu 16.04, there should be some error messages from upsmon in
>> 'journalctl' referencing permissions.)
>>
>> ?I have tried running from /etc/nut, now moved in /usr/local...will
keep
> you informed?
>
>
>
>> Under the Bugs heading, the man page says "Instant commands are
not yet
>> supported in Dummy Mode..." - one of the use cases was automated
developer
>> testing of NUT, and there isn't much use in simulating all of the
commands
>> in that case. "load.off" is probably worth implementing at
some point for
>> user testing.
>>
>> So for your use case, the timers would probably be the easiest way with
>> the current code.
>
>
> ?Ok, I am testing it, thank you?
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20170703/65f79274/attachment.html>