R: R: email notification problem

Arno Lehmann al at its-lehmann.de
Fri Jan 27 11:23:32 CET 2006


Hi,

On 1/27/2006 11:00 AM, Nicola Agnelli wrote:
> Thank you for answer,
> so the correct command should be:
> 
> define command{
> 
>>        command_name    notify-by-email
>>        command_line    /usr/bin/printf "%b" "***** Nagios
>>*****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService:
>>$SERVICEDESC$\nHost: $HOSTALIAS$\nAdd$ | mail -s Notification
>>        }
> 
> 
> 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: $$ | mail -s Notification
>>        }
> 

That depends on your mail command. I suppose you need to set the 
receiver address, and possibly the sender, too.
> 
> ?
> 
> Sorry for my questions but I'm new to nagios ..

That's something that will fix itself in a short time :-)

But, for good results, you do need a good understanding of the way 
Nagios works, as well as of the underlying operating system and your 
network...

Arno

> 
> 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.50
> A: nagios-users at lists.sourceforge.net
> Oggetto: Re: R: [Nagios-users] email notification problem
> 
> 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
>>
> 
> 

-- 
IT-Service Lehmann                    al at its-lehmann.de
Arno Lehmann                  http://www.its-lehmann.de



-------------------------------------------------------
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&kid3432&bid#0486&dat1642
_______________________________________________
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