nagios 3.0.5 email notifications fail

Marc Powell marc at ena.com
Fri Jan 9 16:49:28 CET 2009


On Jan 9, 2009, at 8:42 AM, alex alex wrote:

> I will try to see the error in command. I already use a modified  
> command
>
>  define command {
>         command_name                    notify-host-by-email
>         command_line                       /usr/bin/printf "%b"  
> "Host: $HOSTNAME$\n $CONTACTEMAIL$\n" |cat >>/tmp/testfile
> }
>
>
> and I get in the log file just:
>
> Host: host1
>  $
> Host: host1
>  $
> Host: host1
>  $

Interesting...

> So I guess that nagios is not getting right the  $CONTACTEMAIL$  
> macro substitution.
>
> I don't know exactly the inner works that means that if it's correct  
> to define a host and use a template for providing the contact group  
> and from the contact group nagios can extract the email addresses  
> and put them in $CONTACTEMAIL$

I expect this to work fine.

> Also, the services are not notified also; the same happens (the  
> email sustituted from $CONTACTEMAIL$ seems to be $???).

I suspect that the more likely reason is that nagios is not replacing  
$CONTACTEMAIL$ with it's proper value before passing it on to the  
shell for some strange reason. The shell then interprets '$CONTACTEMAIL 
$' as a null shell variable of '$CONTACTEMAIL' followed by a literal  
'$' so you end up with the results your seeing (you could see this by  
enabling debug mode). The question is why nagios isn't doing the  
substitution properly. The most likely cause is that the macro is  
mistyped but that really doesn't look like the case.

Actually, now that I'm reviewing your original posting. I'm exactly  
sure that nagios isn't performing the subtitution at all. In your host  
template (and probably service template), you specify the notification  
commands as event_handlers. This is not a correct use of event  
handlers as the $CONTACTEMAIL$ macro (and others) are not valid for  
them. Disable event_handler_enabled and remove event_handler and you  
should be fixed. The notifications will still go out through the  
normal notification process.

--
Marc


------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
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