$HOSTGROUPNAME$ macro
-
karen9876543210
- Posts: 11
- Joined: Thu Apr 21, 2016 3:33 am
$HOSTGROUPNAME$ macro
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 ?
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
Sounds like this doc might be helpful, have you already seen it?
https://assets.nagios.com/downloads/nag ... olist.html
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
Thank you for response !! Yes sure I have already seen it!! In my post there is description of
$HOSTGROUPNAME$ from documentation.
$HOSTGROUPNAME$ from documentation.
-
karen9876543210
- Posts: 11
- Joined: Thu Apr 21, 2016 3:33 am
Re: $HOSTGROUPNAME$ macro
I am using nagios 3.5.1
Re: $HOSTGROUPNAME$ macro
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?
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
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.
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
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
That does not working
Re: $HOSTGROUPNAME$ macro
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.
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!