Page 1 of 1

Host Template Variable Inheritance

Posted: Wed Sep 30, 2015 1:15 pm
by Waynej
Hi, I'm following the recommended best practice method of distributing snmp community strings through a host template.
But I'm not getting the results as expected. The community string is not found by a service command.

I'm using the reference pages "Understanding Macros and How they work", "Standard Macros in Nagios" and "Object Inheritance"
Nagios XI 5R1.0 but had the same issue on r2014

In this scenario the snmp string is "12345" which Server1 should be inheriting from template Corp_Community.
It is called in Service TZ -5 as $_HOSTcommunity$. -Which does work if I set the variable on the Server1 host directly.

I appreciate your assistance in troubleshooting this issue.

Code: Select all

define host {
        host_name         		Server1
        use                   	Corp_Community
        address               	Server1.corporation.com
        max_check_attempts     	1
        check_interval        	5
        retry_interval        	1
        register              	1
        }

[b]define host[/b] {
       name                 	Corp_Community
       _community            	12345
       register               	0

}

define service {
        host_name             	Server1
        service_description   	TZ -5
        servicegroups          	NTP Check
        check_command          	Check_snmp_time!20!"-240"!$_HOSTcommunity$!!!!!
        max_check_attempts      1
        check_interval         	5
        retry_interval         	1
        check_period           	xi_timeperiod_24x7
        register             	1
        }

Re: Host Template Variable Inheritance

Posted: Wed Sep 30, 2015 9:56 pm
by jdalrymple
Custom Object Variables wrote:Custom variable names are converted to all uppercase before use
Change:

Code: Select all

        check_command             Check_snmp_time!20!"-240"!$_HOSTcommunity$!!!!!
to

Code: Select all

        check_command             Check_snmp_time!20!"-240"!$_HOSTCOMMUNITY$!!!!!
You'll be golden.

Re: Host Template Variable Inheritance

Posted: Thu Oct 01, 2015 8:21 am
by Waynej
Wow... I made the wrong assumption there. That... "variable names are converted to all uppercase before use."

I appreciate your help and for the simple solution.

Thank You

Re: Host Template Variable Inheritance

Posted: Thu Oct 01, 2015 9:47 am
by hsmith
Hi Waynej,

Is there anything else we can do to help you out, or are we free to close this one?

Re: Host Template Variable Inheritance

Posted: Thu Oct 01, 2015 10:47 am
by Waynej
Please close at your convenience.

Thank you