RE: Passing Parameters to Event Handlers
Mike Dean <[email protected]>
| Newsgroups | gmane.network.netsaint.user |
|---|---|
| Message-ID | <F622FE8186D60B4087A71DAD42ABE5E20B38E8@fljaxeml02> |
Thanks for your reply. The command is defined in command.cfg (I should've
included that in my email). Following is the command definition and how I'm
trying to use it:
-- In command.cfg:
define command{
command_name router-host
command_line $USER5$/router-host.sh $HOSTNAME$ $HOSTSTATE$
$STATETYPE$ $HOSTATTEMPT$ $TIMET$ $ARG1$
}
Note that $USER5$ is a path defined in my resources.cfg file and is used for
all of my custom commands/event handlers,etc and that works.
Using a template for the hosts, the event handler configuration looks like
this:
define host {
name routers
use standard-host
event_handler_enabled 1
event_handler router-host
register 0
}
An acutal host configuration:
define host{
use routers ; Name of host template to
use
host_name jaxwanrt1
alias JAX 7507
address 10.10.10.10 ; IP Changed to protect the
innocent
parents jaxcoresw1,jaxcoresw2
}
Now, to pass the parameter to the command (to be parsed by $ARG1$) I have
tried modifying the event handler in the following ways:
event_handler router-host!VALUE
This causes an error that says that router-host!VALUE is not defined
I also tried:
event_handler router-host;VALUE
I forget where in the docs I saw something like this. This does not produce
an error, but the value is not passed to $ARG1$.
Mike
-----Original Message-----
From: Stanley Hopcroft [mailto:[email protected]]
Sent: Tuesday, November 19, 2002 11:57 PM
To: Mike Dean
Cc: [email protected]
Subject: Re: [netsaint] Passing Parameters to Event Handlers
Dear Sir,
Is the command you wish to be performed as your event handler defined in
command.cfg ?
I am using global event handlers (with other macro parameters) without
any problems.
command[global-host-handler]=$USER1$/global_host_handler $TIMET$
$HOSTNAME$ $HOSTSTATE$ $STATETYPE$
command[global-svc-handler]=$USER1$/global_svc_handler $TIMET$
$HOSTNAME$ '$SERVICEDESC$' $SERVICESTATE$ $STATETYPE$ '$OUTPUT$'
If it's not working you could consider enabling the appropriate debug
option (rebuilding Netsaint with the compile time debug switch, DEBUG3)
and potentially sending a bug report
However, the docco clearly distinguishes between commands used in
services (with parms etc) and those used in event handlers.
It may be that it is __not__ possible.
You can find out for sure by running it in the foreground (no -d) in the
debugger breaking at the local event handler and displaying the
processed command line.
I really can't see why it doesn't, since process_macros is called in
run_service_handler and this expands $ARG1$ etc.
Yours sincerely.
--
------------------------------------------------------------------------
Stanley Hopcroft
------------------------------------------------------------------------
'...No man is an island, entire of itself; every man is a piece of the
continent, a part of the main. If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friend's or of thine own were. Any man's death diminishes
me, because I am involved in mankind; and therefore never send to know
for whom the bell tolls; it tolls for thee...'
from Meditation 17, J Donne.