Hello,
Does Nagios XI allow for passing custom macros into free variables? For example, we would like to pass a variable from the host to a service. The values are:
host free variables:
"_environment" = "development"
"_owner" = xxxxxxx
service free variables:
"_environment" = "$_HOSTENVIRONMENT"
Tailing /tmp/nagios-send-service-event.txt shows the Service Environment coming through as "$"
However, when we set service free variable "_environment" = "$HOSTOWNER" the Service Environment comes through with the correct Host Owner value. So it seems like the functionality is there to pass a macro through a free variable but for some reason we can't get it to work with the macro we've created ($_HOSTENVIRONMENT). Are custom macros not compatible with this?
Thanks for your time!
Passing Macros Into Free Variables
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Passing Macros Into Free Variables
Hi,
You can pass the free variables assigned at the host level, to services, that will work. However, I just tested this and got similar results ($). I'm not quite sure why it doesn't pass the whole string along without parsing the variable, but that may be a security issue or the parsing rules.
You can pass the free variables assigned at the host level, to services.
What are the requirements? I can try to suggest a workaround.
Thanks,
Benjamin
You can pass the free variables assigned at the host level, to services, that will work. However, I just tested this and got similar results ($). I'm not quite sure why it doesn't pass the whole string along without parsing the variable, but that may be a security issue or the parsing rules.
You can pass the free variables assigned at the host level, to services.
What are the requirements? I can try to suggest a workaround.
Thanks,
Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Passing Macros Into Free Variables
How do we pass the free variables from the host to the service? Can we do it for just one host free variable and not all?
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Passing Macros Into Free Variables
Hi,
Are the free variables being passed to an event handler or plugin? One way to set this up, is to pass the free variable in the command definition. So if the host had a variable set for $_HOSTFREE$ (_free in the CCM), then you would configure the command for the script like,
Every service is associated with a host, so only the free variable assigned for that service's host would be passed.
Hopefully, that helps answer your question. Let us know if you need clarification on anything.
--Benjamin
Are the free variables being passed to an event handler or plugin? One way to set this up, is to pass the free variable in the command definition. So if the host had a variable set for $_HOSTFREE$ (_free in the CCM), then you would configure the command for the script like,
Code: Select all
$USER1$/event_handler_test.sh $_SERVICEFREE$ $_HOSTFREE$
Hopefully, that helps answer your question. Let us know if you need clarification on anything.
--Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Passing Macros Into Free Variables
Hi Benjamin,
We worked it a couple different ways and settled on editing the script we use to send service events to our Event Handler. This way we can pass the $HOSTOWNER$ and $HOSTENVIRONMENT$ through to the service. Thank you for your time and insights.
-Will
We worked it a couple different ways and settled on editing the script we use to send service events to our Event Handler. This way we can pass the $HOSTOWNER$ and $HOSTENVIRONMENT$ through to the service. Thank you for your time and insights.
-Will
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Passing Macros Into Free Variables
Hi Will,
Your welcome. Thanks for the update!
We'll go ahead this out, but feel free to open another if you have any new questions.
--Benjamin
Your welcome. Thanks for the update!
We'll go ahead this out, but feel free to open another if you have any new questions.
--Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!