how to customize which macros get sent with service event handlers?

Marc Powell marc at ena.com
Tue Mar 7 19:41:26 CET 2006



> -----Original Message-----
> From: nagios-users-admin at lists.sourceforge.net [mailto:nagios-users-
> admin at lists.sourceforge.net] On Behalf Of prosolutions at gmx.net
> Sent: Tuesday, March 07, 2006 12:22 PM
> To: nagios-users at lists.sourceforge.net
> Subject: [Nagios-users] how to customize which macros get sent with
> service event handlers?
> 
> 
> According to
http://nagios.sourceforge.net/docs/2_0/eventhandlers.html:
> 
> "In most cases, event handler commands will be shell or perl scripts.
At
> a minimum, the scripts should take the following macros as arguments:
> 
> Service event handler macros: $SERVICESTATE$, $SERVICESTATETYPE$,
> $SERVICEATTEMPT$"
> 
> 
> I have created a simple external command triggerend by a service event
> handler that just echoes $@ to a temp file and can verify that it does
> provide these three macros to the external command.  But I want/need
to
> provide other macros (such as $HOSTNAME$) to my external command.  I'm
am
> not sure how this is done - am not finding anything in the docs which
> mentions how to do this.  Is there some config option where which
macros
> are sent by an event handler can be defined?

Add it to your command definition for your event handler. Using the
example service event handler on the documentation page referenced above
it becomes --

define command{
	command_name	restart-httpd
	command_line
/usr/local/nagios/libexec/eventhandlers/restart-httpd  $SERVICESTATE$
$SERVICESTATETYPE$ $SERVICEATTEMPT$ $HOSTNAME$
	}

Your event handler script needs to grab that extra command line argument
to do something useful with it of course. How that's done varies widely
based on the scripting language used. For /bin/sh, the hostname would be
stored in the $4 variable.

--
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