Thomas Stather
2010-Jan-09 12:43 UTC
[Nut-upsuser] problem with mailing (nut 2.4.1 and a powermust650 -> megatec_usb)
Hello guys Yesterday i started do configure my Mustek Powermust650 with nut using the megatec_usb driver. Everything works fine except for the mailing when something happens. My upsmon looks like this: MONITOR powermust650 at localhost 1 local controller master MINSUPPLIES 1 SHUTDOWNCMD "/sbin/shutdown -h +0" NOTIFYCMD /root/upsmailer POLLFREQ 10 POLLFREQALERT 5 HOSTSYNC 15 DEADTIME 45 POWERDOWNFLAG /etc/killpower NOTIFYMSG ONLINE "UPS %s on line power" NOTIFYMSG ONBATT "UPS %s on battery" NOTIFYMSG LOWBATT "UPS %s battery is low" NOTIFYMSG FSD "UPS %s: forced shutdown in progress" NOTIFYMSG COMMOK "Communications with UPS %s established" NOTIFYMSG COMMBAD "Communications with UPS %s lost" NOTIFYMSG SHUTDOWN "Auto logout and shutdown proceeding" NOTIFYMSG REPLBATT "UPS %s battery needs to be replaced" NOTIFYMSG NOCOMM "UPS %s is unavailable" NOTIFYMSG NOPARENT "upsmon parent process died - shutdown impossible" 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 RBWARNTIME 43200 NOCOMMWARNTIME 300 INALDELAY 5 the /root/upsmailer is just a simple shell script that mails the events, it looks like: #!/bin/bash RECIPIENT="controller at xxx" SCRIPTNAME=`basename $0` [ `echo $UPSNAME | wc -w` -eq "0" ] && UPSNAME="unknown" [ `echo $NOTIFYTYPE | wc -w` -eq "0" ] && NOTIFYTYPE="unknown" echo "$*" | mailx -s "$SCRIPTNAME: $UPSNAME $NOTIFYTYPE" $RECIPIENT exit 0 When i disconnect the UPS from the power line, i get a message in my syslog but not on the wall and the script isn't started either. What have i done wrong (i'm relatively new to nut :) )? Greets Thomas
Charles Lepple
2010-Jan-09 13:41 UTC
[Nut-upsuser] problem with mailing (nut 2.4.1 and a powermust650 -> megatec_usb)
On Jan 9, 2010, at 7:43 AM, Thomas Stather wrote:> Hello guys > > > Yesterday i started do configure my Mustek Powermust650 with nut > using the megatec_usb driver. Everything works fine except for the > mailing when something happens. My upsmon looks like this: > > > MONITOR powermust650 at localhost 1 local controller master > MINSUPPLIES 1 > SHUTDOWNCMD "/sbin/shutdown -h +0" > NOTIFYCMD /root/upsmailer > POLLFREQ 10 > POLLFREQALERT 5 > HOSTSYNC 15 > DEADTIME 45 > POWERDOWNFLAG /etc/killpower > NOTIFYMSG ONLINE "UPS %s on line power" > NOTIFYMSG ONBATT "UPS %s on battery" > NOTIFYMSG LOWBATT "UPS %s battery is low" > NOTIFYMSG FSD "UPS %s: forced shutdown in progress" > NOTIFYMSG COMMOK "Communications with UPS %s established" > NOTIFYMSG COMMBAD "Communications with UPS %s lost" > NOTIFYMSG SHUTDOWN "Auto logout and shutdown proceeding" > NOTIFYMSG REPLBATT "UPS %s battery needs to be replaced" > NOTIFYMSG NOCOMM "UPS %s is unavailable" > NOTIFYMSG NOPARENT "upsmon parent process died - shutdown > impossible" > 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 > RBWARNTIME 43200 > NOCOMMWARNTIME 300 > INALDELAY 5^ I assume this is a cut-n-paste error? If not, check to see if there are any messages in syslog saying that the configuration file couldn't be reloaded.> the /root/upsmailer is just a simple shell script that mails the > events, it looks like: > > > #!/bin/bash > > RECIPIENT="controller at xxx" > SCRIPTNAME=`basename $0` > > [ `echo $UPSNAME | wc -w` -eq "0" ] && UPSNAME="unknown" > [ `echo $NOTIFYTYPE | wc -w` -eq "0" ] && NOTIFYTYPE="unknown" > echo "$*" | mailx -s "$SCRIPTNAME: $UPSNAME $NOTIFYTYPE" $RECIPIENT > exit 0 > > When i disconnect the UPS from the power line, i get a message in my > syslog but not on the wall and the script isn't started either. What > have i done wrong (i'm relatively new to nut :) )?Does your script have the execute bit turned on? Also, the script will be run as the user you defined in the ./ configure script (or some username like "nut", if you are running from a package). Be sure that the permissions on /root allow this mostly- unprivileged user to run the script. Usually this means at least scan permissions on /root (+x), but a better idea might be to put the script in /usr/local/sbin. If you're interested in efficiency (embedded system or the like), you might want to rewrite the "unknown" checks - in their current form, they will fork a new subshell (``) and run wc. I think the following line will do the same thing: echo "$*" | mailx -s "$SCRIPTNAME: ${UPSNAME:=unknown} $ {NOTIFYTYPE:=unknown}" $RECIPIENT
Charles Lepple
2010-Jan-09 21:33 UTC
[Nut-upsuser] problem with mailing (nut 2.4.1 and a powermust650 -> megatec_usb)
[cc'ing the list.] On Sat, Jan 9, 2010 at 10:43 AM, Thomas Stather <thomasstather at aol.com> wrote:> Am 09.01.2010 14:41, schrieb Charles Lepple: >> >> On Jan 9, 2010, at 7:43 AM, Thomas Stather wrote: >>> INALDELAY 5 >> >> ^ I assume this is a cut-n-paste error? >>...> The above error was an copy&paste mistake. And furthermore, the hint with > the execution bit in /root was correct as well, /root hat rwx------ > I copied the script to /usr/local/sbin and now i have to wait if there will > be a mail notification (i edited the shell script as well like you said).Good to know that fixed it. -- - Charles Lepple