Host Template Variable Inheritance

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
Waynej
Posts: 7
Joined: Wed Sep 16, 2015 2:51 pm

Host Template Variable Inheritance

Post 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
        }
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Host Template Variable Inheritance

Post 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.
Waynej
Posts: 7
Joined: Wed Sep 16, 2015 2:51 pm

Re: Host Template Variable Inheritance

Post 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
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Host Template Variable Inheritance

Post by hsmith »

Hi Waynej,

Is there anything else we can do to help you out, or are we free to close this one?
Former Nagios Employee.
me.
Waynej
Posts: 7
Joined: Wed Sep 16, 2015 2:51 pm

Re: Host Template Variable Inheritance

Post by Waynej »

Please close at your convenience.

Thank you
Locked