event_handlers macro contactemail

Marc Powell marc at ena.com
Fri Mar 10 02:07:03 CET 2006


Comments inline...

> -----Original Message-----
> From: nagios-users-admin at lists.sourceforge.net [mailto:nagios-users-
> admin at lists.sourceforge.net] On Behalf Of Carlos de Sousa
> Sent: Thursday, March 09, 2006 4:19 PM
> To: nagios-users at lists.sourceforge.net
> Subject: Re: [Nagios-users] event_handlers macro contactemail
> 
> Hi!
> 
> Thanx for the prompt answer, I realize now that
> I shouldn't try to fool the system by using obscure
> ways.
> 
> BUT .....
> 
>     If I use the suggested "contact"-path, could u
> pls explain what is the major difference between
> a notification and an event?

An event-handler is run for every non-OK check up to max_check_attempts
(soft and hard states) and once when the service recovers to an OK
state. A notification is launched when non-OK checks reach
max_check_attempts (hard state), when a recovery occurs and whenever you
have repeat notifications scheduled (if at all). I'm excluding
escalations but those could be useful as well.

> 
> If I already have in production  a event-handler
> script that works fine (except for not using the CONTACTx stuff),
> would I then disable "event_handler processing" completely
> and use the contactgroup in a host definition to use a contact
> that would call the same script as I am using for events?

If you did this then the event_handler would be redundant. I don't know
what you're really trying to accomplish but a notification is the only
way that the CONTACT_* macros are currently available directly from
within Nagios. 
 
> The example I gave before is somewhat shortened, here is what
> I really use
> 
> define command {
> command_name                   send_snmptrap_host
> command_line                   /usr/bin/perl
> $USER1$/eventhandlers/send_nagiostrap HOST $HOSTSTATE$ $HOSTSTATETYPE$
> $HOSTATTEMPT$
$HOSTNAME$#$HOSTADDRESS$#$HOSTALIAS$#$SERVICEDESC$#$USER2$
> }
> 
> Would I still be able to use the above macros through a notification
> command?

I presume you'd be adding $CONTACTEMAIL$ and $CONTACTPAGER$ to the above
but the answer is yes. Again, the chart linked below details where each
macro is valid. Just look for a Yes in the Service Notifications or Host
Notifications column, whichever you are going to use --

http://nagios.sourceforge.net/docs/2_0/macros.html

> Would the macros above contain the exact same information if I used
> them in a notification command rather than in a event_handler?

Yes, with the caveat that they're only run when the check reaches a HARD
state so $HOSTSTATETYPE$ would always be HARD and $HOSTATTEMPT$ would
always be max_check_attempts for that host (I believe).

> So basically, If I understood u right, u say that I could do
> 
[config example removed]

Looks workable to me.

> would I loose any functionality at all by not using eventhandlers
> in favor of notification commands?

Some, related to when they are executed as noted above. Whether that's
important or not is up to you. From what I've gathered, you're looking
for kind of fire-and-forget functionality which is very similar to a
notification.

--
Marc



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&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