[Nut-upsuser] problem with mailing (nut 2.4.1 and a powermust650 -> megatec_usb)
Charles Lepple
clepple at gmail.com
Sat Jan 9 13:41:51 UTC 2010
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
More information about the Nut-upsuser
mailing list