R: email notification problem

Don Lewis donnell.lewis at icoretechnology.com
Fri Jan 27 17:31:28 CET 2006


Yes, example of my mail config:


define command{
        command_name    notify-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios  *****\n
\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost:
$HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time:
$LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n\nComment:
$SERVICEACKCOMMENT$\n\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ alert -
$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
        }

Pay close attention to the binaries 'mail' and 'printf' and make sure
they BOTH exist on your system and are either in that path or change the
'/bin/ and /usr/bin/' to the location yours are at.

-Don


On Fri, 2006-01-27 at 10:50 +0100, Arno Lehmann wrote:
> Hello,
> 
> On 1/27/2006 10:23 AM, Nicola Agnelli wrote:
> > Hello all,
> > i've the same problem, i've installed nagios 2.0 and all works good, but the
> > email notifications can't be send..
> 
> The first step could be to modify your command_line to actually send a 
> message. Usually, you use printf to create and format the output AND 
> THEN pipe that output to your mail program.
> 
> Like 'printf "somethning" | mail -s Notification ...
> 
> Arno
> 
> > my command is the default command:
> > 
> > define command{
> >         command_name    notify-by-email
> >         command_line    /usr/bin/printf "%b" "***** Nagios
> > *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService:
> > $SERVICEDESC$\nHost: $HOSTALIAS$\nAdd$
> >         }
> > And:
> > define command{
> >         command_name    host-notify-by-email
> >         command_line    /usr/bin/printf "%b" "***** Nagios
> > *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState:
> > $HOSTSTATE$\nAddress: $$
> >         }
> > 
> > But I can't receive notifications mails.. 
> > Here are the nagios.log:
> > 
> > ....
> > [1138352948] HOST ALERT: w2k3-server;DOWN;SOFT;9;CRITICAL - Host Unreachable
> > (10.0.0.222)
> > [1138352951] HOST ALERT: w2k3-server;DOWN;HARD;10;CRITICAL - Host
> > Unreachable (10.0.0.222)
> > [1138352951] HOST NOTIFICATION:
> > nagios-admin;w2k3-server;DOWN;host-notify-by-email;CRITICAL - Host
> > Unreachable (10.0.0.222)
> > ....
> > 
> > How can I resolve ? 
> > 
> > Tnx all
> > 
> > nicola
> > 
> > 
> > -----Messaggio originale-----
> > Da: nagios-users-admin at lists.sourceforge.net
> > [mailto:nagios-users-admin at lists.sourceforge.net] Per conto di Arno Lehmann
> > Inviato: venerdì 27 gennaio 2006 10.02
> > A: nagios-users at lists.sourceforge.net
> > Oggetto: Re: [Nagios-users] email notification problem
> > 
> > Hello,
> > 
> > On 1/27/2006 3:44 AM, test 123king wrote:
> > 
> >>I have set up nagios nagios-1.3-14.fc4 in my FC4 server, the only 
> >>problem now is the email notification can't be send out.
> >>The original notify-by-email in misccommands.cfg file is like below:
> >># 'notify-by-email' command definition
> >>define command{
> >>command_name notify-by-email
> >>command_line /usr/bin/printf "%b" "***** Nagios *****nnNotification 
> >>Type: $NOTIFICATIONTYPE$nnService: $SERVIC
> >>EDESC$nHost: $HOSTALIAS$nAddress: $HOSTADDRESS$nState: 
> >>$SERVICESTATE$nnDate/Time: $DATETIME$nnAdditional Info:n
> >>n$OUTPUT$" | -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ 
> >>is $SERVICESTATE$ **" $CONTACTEMAIL$
> >>}
> >>
> >>I changed it to :
> >># 'notify-by-email' command definition
> >>define command{
> >>command_name notify-by-email
> >>command_line /bin/mail "%b" "***** Nagios *****nnNotification Type: 
> >>$NOTIFICATIONTYPE$nnService: $SERVIC
> >>EDESC$nHost: $HOSTALIAS$nAddress: $HOSTADDRESS$nState: 
> >>$SERVICESTATE$nnDate/Time: $DATETIME$nnAddi tional Info:n
> >>n$OUTPUT$" | -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ 
> >>is $SERVICESTATE$ **" $CONTACTEMAIL$
> >>}
> >>
> >>Basically I replaced /usr/bin/printf with /bin/mail.
> > 
> > 
> > And you don't have a valid command line left: after the pipe, there 
> > should be a program to read the output from mail. And your invocation of 
> > mail looks a little... non-standard to me.
> > 
> > 
> >>In the /var/log/messages log I see the following error:
> >>
> >>
> >>Warning: Attempting to execute the command "/bin/mail "%b" "***** Nagios 
> >>*****nnNotification Type: RECOVERYnHost: Server-1nState: UPnAddress: 
> >>10.100.1.79nInfo: PING OK - Packet loss = 0%, RTA = 0.76 msnnDate/Time: 
> >>Thu Jan 26 17:48:21 EST 2006n" | -s "Host UP alert for Server-OTM!" 
> >>sysadmin at www.com <mailto:sysadmin at www.com>" resulted in a return code of 
> >>127. Make sure the scri//pt or binary you are trying to execute actually 
> >>exists...
> > 
> > 
> > It's all there: the output from mail is piped to '-s' which, most 
> > probably, is not installed on your system as an executable program in 
> > the path.
> > 
> > 
> >>Any kind help is highly appreciated!!
> >>
> > 
> > 
> > Why don't you try the original notification script and simply insert 
> > your mail command between pipe and '-s'? The reason why it's missing, by 
> > the way, is probably that configure couldn't identify your mailer.
> > 
> > Arno
> > 
> 



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list