Group Template & Host Groups

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.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Group Template & Host Groups

Post by abrist »

itzik wrote:what is the best practice to add and manage host template upon host groups?
You cannot deploy templates to hosts based on their hostgroup membership. You can configure hostgroups on hosts through a template though.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
itzik
Posts: 11
Joined: Sun Jul 13, 2014 7:48 am

Re: Group Template & Host Groups

Post by itzik »

arbist,

thanks for posting,
configure hostgroups on hosts through a template though...
what do you mean by that?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Group Template & Host Groups

Post by tmcdonald »

You can define a template that assigns hostgroup membership, and then apply that template to all the hosts that you want to be a member of that hostgroup.
Former Nagios employee
itzik
Posts: 11
Joined: Sun Jul 13, 2014 7:48 am

Re: Group Template & Host Groups

Post by itzik »

tmcdonald,

i am not sure if i understood what you wrote though i think that what you suggested (if i understood right) is going 200 hosts one by one and adding the template manually... that is exactly what i don`t want to do.
let me know if i understood you right and if not please elaborate further,

thanks for replying and trying to assist anyhow,

itzik vilmovsky
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Group Template & Host Groups

Post by tmcdonald »

If you have 200 things and you need to put them in a group, at some point or another you will need to touch each of the 200 things. Whether you add them to a hostgroup from the hostgroup config or go to each host individually and add it to a group, you've got a fair amount of work. If you already have a list of the 200 hosts, you can probably script something pretty easily that will add the proper hostgroup line to each of the configs.
Former Nagios employee
itzik
Posts: 11
Joined: Sun Jul 13, 2014 7:48 am

Re: Group Template & Host Groups

Post by itzik »

tmcdonald

you miss the point of this whole thread, i have the hosts already assigned to a host group and even if i don`t adding them its ok and i agree with you that if i am already adding them (which is fat easy then adding template to each) i can insert them the template though that`s not the point.
the point of this thread is to better understand if its possible to assign host template to host group since if after adding them and configuring i will want to do a change to multiple hosts, (add another template/change parent/ETC) then i need to modify 100 and more hosts manually.
read my first post please and better understand the concept,

thanks man
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Group Template & Host Groups

Post by eloyd »

Hostgroups don't have templates assigned to them. Hosts do. So if you change the template used by 500 hosts, you will change the host definition for all 500 hosts at once.

Code: Select all

define host{
        use             voip-server
        host_name       mkgp-d01.localdomain
        alias           mkgp-d01.localdomain
        address         10.1.1.111
        hostgroups      private
}
define host{
        use             voip-server
        host_name       svip-d01.localdomain
        alias           svip-d01.localdomain
        address         10.1.1.109
        hostgroups      private
}

define hostgroup{
        hostgroup_name  private
        alias           VoIP Servers
}

define host{
        name                    smartvox-server
        use                     linux-server
        notification_period     24x7
        contact_groups          voip-support
        register                0
}
define host{
        name                    voip-server
        use                     smartvox-server
        register                0
}
Notice that the hosts "use voip-server" which is a TEMPLATE name, not a HOSTGROUP name. The host (template) named voip-server then uses another template called "smartvox-server" which in turn uses one called "linux-server" (which then uses one called generic-server, both of which are not included here).

If I want to change the notification period from 24x7 to 9x5 for all hosts (let's assume there are more than two) then I just change it in the smartvox-server or voip-server template and it will apply to all hosts that use those templates.

Hostgroups have nothing to do with what I think you are asking.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Group Template & Host Groups

Post by tmcdonald »

If all you want to know is "Can a host template be applied to a hostgroup?" then the answer is no. This applies both to "Can I apply a host template to multiple hosts by putting the hosts in a group and applying the template to that group?" and "Is there such a thing as a hostgroup template?" - either way, the answer is no. We're now trying to offer suggestions for a workaround.
Former Nagios employee
itzik
Posts: 11
Joined: Sun Jul 13, 2014 7:48 am

Re: Group Template & Host Groups

Post by itzik »

thanks for replying such an elaborated informative reply tmcdonald,

so how do you address this claims that i have in my first post?

itzik
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Group Template & Host Groups

Post by tmcdonald »

I'm not sure what claims you are referring to.

If you want to add a template to multiple hosts, it will need to be done one-by-one. Whether you add it by hand or by scripting, you will still at some point need to specify each host.
Former Nagios employee
Locked