Page 1 of 1
Custom Macro/Variable Limitation
Posted: Mon Nov 26, 2018 11:55 am
by avezinaATetl
Hi,
I'm trying to use macro/variable to sets some urls/fqdn to check.
I am using the variable name : FQDN_Product_Service with a value of "devapi.example.org"
And the check command check_http : Check_API_Health!$_HOSTFQDN_PRO_SVC$!http://$_HOSTFQDN_PRO_SVC$/api/Health
When I do a network capture to see what is requested, I see that http://$/api/Health is requested.
Is there some limitation to the length or character choices in the variables? I already discovered that Nagios don't want hyphen '-' within variable names.
Re: Custom Macro/Variable Limitation
Posted: Mon Nov 26, 2018 12:15 pm
by scottwilkerson
Custom variables should start with an underscore
Code: Select all
_FQDN_Product_Service devapi.example.org
Re: Custom Macro/Variable Limitation
Posted: Mon Nov 26, 2018 1:08 pm
by avezinaATetl
Hi Scott, thank you for your reply.
Yes, custom variable starts with an underscore. I forgot about it in my post, but I do have them in my configs.
While I do some more test to expand my question, can you answer this question : Is there a character limitation (hyphens, underscore, other symbols) or limit for custom variables?
Re: Custom Macro/Variable Limitation
Posted: Mon Nov 26, 2018 1:16 pm
by scottwilkerson
Not specifically, other that what is posted here
https://assets.nagios.com/downloads/nag ... tvars.html
However I just realized you are adding them in the $ARGn$ fields, and honestly, I don't think that will work
You will likely need to make a new command definition and pass the $_HOSTFQDN_PRO_SVC$ variable where you have $ARG1$, etc.
ALSO, I just saw this
you said the variables are named
but you are referencing
instead of
Re: Custom Macro/Variable Limitation
Posted: Mon Nov 26, 2018 2:11 pm
by avezinaATetl
Thank you again.
The variables are not the same in my initial post because I used placeholders and didn't use them the same way for the post.
After checking everything again, I had some typo at multiple places. Fixed them.
I think my problem was caused by not using all upercase in my variables names and places where I use them.
Here is my check_command that works:
$USER1$/check_http -I $HOSTADDRESS$ -e '200 OK' -H $_HOSTFQDN_ENROUTE-ROUTE$ -u https://$_HOSTFQDN_ENROUTE-ROUTE$/api/Health -S
Re: Custom Macro/Variable Limitation
Posted: Mon Nov 26, 2018 4:27 pm
by scottwilkerson
avezinaATetl wrote:Thank you again.
The variables are not the same in my initial post because I used placeholders and didn't use them the same way for the post.
After checking everything again, I had some typo at multiple places. Fixed them.
I think my problem was caused by not using all upercase in my variables names and places where I use them.
Here is my check_command that works:
$USER1$/check_http -I $HOSTADDRESS$ -e '200 OK' -H $_HOSTFQDN_ENROUTE-ROUTE$ -u https://$_HOSTFQDN_ENROUTE-ROUTE$/api/Health -S
Great! May we mark this resolved?