Stefan Fröchtenicht
2016-Oct-06 10:15 UTC
[Nut-upsuser] NOTIFYCMD doesn't work at all... not fully
Hi there, i have a problem with the NOTIFYCMD in the upsmon.conf file. My line in the config looks like this: NOTIFYCMD "/etc/nut/upsnotify.sh" Now this ist my "/etc/nut/upsnotify.sh": #!/bin/bash EMAIL='mail at domain.de' SMS1='+49123456789' SMS2='+491987654231' #eMail versenden echo -e "Die USV mit dem Namen '$UPSNAME' hat seinen Status ge?ndert!\n\nAktueller Status: '$NOTIFYTYPE'\n\nam `date +%d.%m.%Y` um `date +%H:%M` Uhr" |mail -s "[USV: $UPSNAME][STATUS] $NOTIFYTYPE am `date +%d.%m.%Y` um `date +%H:%M` Uhr" $EMAIL #SMS versenden echo -e "Die USV mit dem Namen '$UPSNAME' hat seinen Status ge?ndert!\n\nAktueller Status: '$NOTIFYTYPE'\n\nam `date +%d.%m.%Y` um `date +%H:%M` Uhr" |gammu-smsd-inject -l TEXT $SMS1 echo -e "Die USV mit dem Namen '$UPSNAME' hat seinen Status ge?ndert!\n\nAktueller Status: '$NOTIFYTYPE'\n\nam `date +%d.%m.%Y` um `date +%H:%M` Uhr" |gammu-smsd-inject -l TEXT $SMS2 when i execute the upsnotify.sh as root, then it works great. eMails and SMS are incoming. But when i for e.g. pull out the ups from power, then there will be only emails and NO SMS. Why? I can?t explain it. NUT runs the script but not complete. What can i do? Thanks! My System: Raspberry Pi with the latest Raspbian, updates, firmware etc. _______________________________________________ Mit freundlichen Gr??en Stefan Fr?chtenicht Stadt Northeim Systemadministrator - Informations- und Kommunikationsmanagement Scharnhorstplatz 1 37154 Northeim Froechtenicht at Northeim.de Tel +49 5551 966111 Fax +49 5551 966444 _______________________________________________ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20161006/30674b03/attachment.html>
Charles Lepple
2016-Oct-06 11:41 UTC
[Nut-upsuser] NOTIFYCMD doesn't work at all... not fully
> On Oct 6, 2016, at 6:15 AM, Stefan Fr?chtenicht wrote: > > when i execute the upsnotify.sh as root, then it works great. eMails and SMS are incoming. > But when i for e.g. pull out the ups from power, then there will be only emails and NO SMS. Why? >NUT runs the notify script as the "nut" user on many systems, including Debian. Check to see if $PATH is set the same, and that the nut user has privileges to run the SMS program. You could also try temporarily wrapping the SMS portion in a subshell that pipes stdout/stderr to mail (or a file): ( echo "..." | gammu-smsd-inject ... ) 2>&1 | mail -s "errors from SMS" $EMAIL -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20161006/31f86c60/attachment.html>
Stefan Fröchtenicht
2016-Oct-06 12:49 UTC
[Nut-upsuser] NOTIFYCMD doesn't work at all... not fully
Hey Charles, HOLY MOLY! Thanks. Why i didn?t see that!? With your tip, i get the error mails: Can't open log file "/var/log/gammu-smsd" Failed to read config: Kann gew?hlte Datei nicht ?ffnen. So i give the user "nut" permission on gammu-smsd: sudo usermod -aG dialout nut sudo usermod -aG dialout root sudo chmod 4755 /usr/bin/gammu-smsd sudo chmod 4755 /usr/bin/gammu-smsd-inject sudo chmod 4755 /usr/bin/gammu-smsd-monitor sudo chgrp -R dialout /var/spool/gammu/ sudo chgrp -R dialout /var/log/gammu-smsd sudo chgrp -R dialout /etc/gammu-smsdrc and now it works! Thanks! _______________________________________________ Mit freundlichen Gr??en Stefan Fr?chtenicht Stadt Northeim Systemadministrator - Informations- und Kommunikationsmanagement Scharnhorstplatz 1 37154 Northeim Froechtenicht at Northeim.de Tel +49 5551 966111 Fax +49 5551 966444 _______________________________________________ Von: Charles Lepple [mailto:clepple at gmail.com] Gesendet: Donnerstag, 6. Oktober 2016 13:41 An: Stefan Fr?chtenicht <froechtenicht at northeim.de> Cc: nut-upsuser at lists.alioth.debian.org Betreff: Re: [Nut-upsuser] NOTIFYCMD doesn't work at all... not fully On Oct 6, 2016, at 6:15 AM, Stefan Fr?chtenicht wrote: when i execute the upsnotify.sh as root, then it works great. eMails and SMS are incoming. But when i for e.g. pull out the ups from power, then there will be only emails and NO SMS. Why? NUT runs the notify script as the "nut" user on many systems, including Debian. Check to see if $PATH is set the same, and that the nut user has privileges to run the SMS program. You could also try temporarily wrapping the SMS portion in a subshell that pipes stdout/stderr to mail (or a file): ( echo "..." | gammu-smsd-inject ... ) 2>&1 | mail -s "errors from SMS" $EMAIL -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20161006/d49a39db/attachment.html>