Custom Macro/Variable Limitation

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
avezinaATetl
Posts: 7
Joined: Mon Nov 26, 2018 11:46 am

Custom Macro/Variable Limitation

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Custom Macro/Variable Limitation

Post by scottwilkerson »

Custom variables should start with an underscore

Code: Select all

_FQDN_Product_Service     devapi.example.org
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
avezinaATetl
Posts: 7
Joined: Mon Nov 26, 2018 11:46 am

Re: Custom Macro/Variable Limitation

Post 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?
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Custom Macro/Variable Limitation

Post 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

Code: Select all

_FQDN_Product_Service
but you are referencing

Code: Select all

$_HOSTFQDN_PRO_SVC$
instead of

Code: Select all

$_HOSTFQDN_PRODUCT_SERVICE$
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
avezinaATetl
Posts: 7
Joined: Mon Nov 26, 2018 11:46 am

Re: Custom Macro/Variable Limitation

Post 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
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Custom Macro/Variable Limitation

Post 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?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked