$HOSTGROUPNAME$ macro

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.
karen9876543210
Posts: 11
Joined: Thu Apr 21, 2016 3:33 am

$HOSTGROUPNAME$ macro

Post 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 ?
bwallace
Posts: 1145
Joined: Tue Nov 17, 2015 1:57 pm

Re: $HOSTGROUPNAME$ macro

Post by bwallace »

Sounds like this doc might be helpful, have you already seen it?
https://assets.nagios.com/downloads/nag ... olist.html
Be sure to check out the Knowledgebase for helpful articles and solutions!
karen9876543210
Posts: 11
Joined: Thu Apr 21, 2016 3:33 am

Re: $HOSTGROUPNAME$ macro

Post by karen9876543210 »

Thank you for response !! Yes sure I have already seen it!! In my post there is description of
$HOSTGROUPNAME$ from documentation.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: $HOSTGROUPNAME$ macro

Post by tmcdonald »

What version of Nagios Core are you using?
Former Nagios employee
karen9876543210
Posts: 11
Joined: Thu Apr 21, 2016 3:33 am

Re: $HOSTGROUPNAME$ macro

Post by karen9876543210 »

I am using nagios 3.5.1
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: $HOSTGROUPNAME$ macro

Post 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?
Be sure to check out our Knowledgebase for helpful articles and solutions!
karen9876543210
Posts: 11
Joined: Thu Apr 21, 2016 3:33 am

Re: $HOSTGROUPNAME$ macro

Post 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.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: $HOSTGROUPNAME$ macro

Post by tgriep »

Try adding the notes_url to the host / service directly, not through a template, and see if that works for you.
Be sure to check out our Knowledgebase for helpful articles and solutions!
karen9876543210
Posts: 11
Joined: Thu Apr 21, 2016 3:33 am

Re: $HOSTGROUPNAME$ macro

Post by karen9876543210 »

That does not working
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: $HOSTGROUPNAME$ macro

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked