Hi,
I'm trying to pass the $ARG4$ argument from a service check to the event handler it is triggering.
I tried adding $ARG4$ to the event handler command but it seems to not pass the original service's $ARG4$
How can I achieve this?
Thanks,
Tal
Pass arguments from service to event handler
Re: Pass arguments from service to event handler
I believe you can achieve this by using the free variables in the host or service definition.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Pass arguments from service to event handler
CGraham is correct, we have some documentation for something similar to this used for restarting services
http://library.nagios.com/library/produ ... -nagios-xi
http://library.nagios.com/library/produ ... -nagios-xi
Re: Pass arguments from service to event handler
One important thing to note, which might be confusing is that in the NSClient++ config file (nsc.ini) they use the $ARG1$ and $ARG2$ nomenclature. This represents the first, second, etc argument that you pass to the nrpe command (using the -a switch) and are not related to the $ARG1$, $ARG2$ that you configure in your original check command.
If you post the details of what you're doing, we can suggest a possible setup. Helpful info:
What the check and eventhandler is trying to do
Service check config
event handler config
If you post the details of what you're doing, we can suggest a possible setup. Helpful info:
What the check and eventhandler is trying to do
Service check config
event handler config
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Pass arguments from service to event handler
Yes, the event_handler also uses them in Core under the hood, so if you had a command for your event handler like
And a config like this
It would execute the following
Code: Select all
define command {
command_name a_test
command_line $USER1$/myevent.sh -a $ARG1$
}
Code: Select all
define host {
host_name 10.0.0.1
use linux-server
check_command check-host-alive!!!!!!!!
event_handler test_arg!XXXXXXXXX
event_handler_enabled 1
register 1
}Code: Select all
/usr/local/nagios/libexec/myevent.sh -a XXXXXXXXXRe: Pass arguments from service to event handler
The free variable method worked great.
FYI, I couldn't find a way to edit the service config file and add an argument to be sent to the event handler like you stated:
Thanks for your help!
FYI, I couldn't find a way to edit the service config file and add an argument to be sent to the event handler like you stated:
Code: Select all
define host {
host_name 10.0.0.1
use linux-server
check_command check-host-alive!!!!!!!!
event_handler test_arg!XXXXXXXXX
event_handler_enabled 1
register 1
}-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: Pass arguments from service to event handler
I should have been clearer, there isn't a way to do this in XIcellact wrote:FYI, I couldn't find a way to edit the service config file and add an argument to be sent to the event handler like you stated: