Page 1 of 2

$HOSTGROUPNAME$ macro

Posted: Thu Apr 21, 2016 3:40 am
by karen9876543210
Hello
I am trying to construct notes_url in host and service template definition by using macros.
for host hostname/$HOSTGROUPNAME$:$HOSTNAME$
for service hostname/$HOSTGROUPNAME$:$HOSTNAME$:$SERVICEDESC$
Macros $HOSTNAME$ and $SERVICEDESC$ are getting their values, but $HOSTGROUPNAME$ are not .

the documentation says
$HOSTGROUPNAME$ The short name of the hostgroup that this host belongs to. This value is taken from the hostgroup_name directive in the hostgroup definition. If the host belongs to more than one hostgroup this macro will contain the name of just one of them.

But whan I use this macro in hostgroup notes_url definition it works fine, I cannot understand why.


The question is - Can I use $HOSTGROUPNAME$ in host/ service template definition? Or is there any lists of macros where I can find out which macros where to use ?

Re: $HOSTGROUPNAME$ macro

Posted: Thu Apr 21, 2016 11:18 am
by bwallace
Sounds like this doc might be helpful, have you already seen it?
https://assets.nagios.com/downloads/nag ... olist.html

Re: $HOSTGROUPNAME$ macro

Posted: Thu Apr 21, 2016 1:18 pm
by karen9876543210
Thank you for response !! Yes sure I have already seen it!! In my post there is description of
$HOSTGROUPNAME$ from documentation.

Re: $HOSTGROUPNAME$ macro

Posted: Thu Apr 21, 2016 1:38 pm
by tmcdonald
What version of Nagios Core are you using?

Re: $HOSTGROUPNAME$ macro

Posted: Fri Apr 22, 2016 12:03 am
by karen9876543210
I am using nagios 3.5.1

Re: $HOSTGROUPNAME$ macro

Posted: Fri Apr 22, 2016 2:08 pm
by tgriep
Are you having issues with setting up your host / service settings to use those macros?
If so, can you post your config file so we can see it?

Re: $HOSTGROUPNAME$ macro

Posted: Mon Apr 25, 2016 2:06 am
by karen9876543210
Here is my config
hostgroups.cfg
define hostgroup{
hostgroup_name hostgroup2
alias hostgroup2
members localhost
}


define hostgroup{
hostgroup_name hostgroup1
alias hostgroup1
members localhost
}

templates.cfg
define host{
name generic-host
....
.....
notes_url http://hostname/$HOSTGROUPNAME$:$HOSTNAME$

}

define service{
name generic-service
.....
notes_url http://hostname/$HOSTGROUPNAME$:$HOSTNAME$:$SERVICEDESC$
}

and after I use this template in my hosts, for example for localhost


define host{

use linux-server host_name localhost
....
}


and in nagios i can see hostgroups and image icon, after clicking on it i see url like this

for host http://hostname/$HOSTGROUPNAME$:localhost
for service http://hostname/$HOSTGROUPNAME$:localhost:HTTP

and i also would like to say when I use this macros in command line that work fine.

Re: $HOSTGROUPNAME$ macro

Posted: Mon Apr 25, 2016 1:19 pm
by tgriep
Try adding the notes_url to the host / service directly, not through a template, and see if that works for you.

Re: $HOSTGROUPNAME$ macro

Posted: Mon Apr 25, 2016 11:59 pm
by karen9876543210
That does not working

Re: $HOSTGROUPNAME$ macro

Posted: Tue Apr 26, 2016 2:31 pm
by tgriep
I confirmed the issue you are seeing on Core 3.5.1.
I tested it out on Core 4.11 and the macro worked in the notes url so my suggestion is to upgrade to core 4.x to get the hostgroupname macro to function for you.