How to best organize hour hosts?

(Hans Gruber) #1

Hello icinga community, i am currently rebuilding our monitoring based on icinga2 and icinga2 director.
Question is: How do i best organize my hosts and apply services to them baes on the role they have?
Ide would be maybe create different hostgroups, like HTTPS servers, Apache Servers, DB Servers and so on and assign particular hosts “by hand” in director. Like “Assign where host.name = foo” or so. the assign the services like check_https_certificxate or so to the hostgroups and therefore to the https hosts.
One could also add a variable or macro to each host like “is_http” and then do a apply the hosts to the hostgroups with “assign where host.role.https = yes” or so, the outcome was the same but the what i want to ask is how to you organize this in your environment? simple add the hosts name by name to the hostgroups or do this in a more sophisticated manner?

Thanks already

(Thomas Widhalm) #2

The best way to assign services to hosts via Director is adding the services to hosttemplates and then importing these templates with your hosts. “Under the hood” Director will create apply rules to make this work but in Director it will still look as if you just added the services to the templates.

Keep in mind that every host can inherit several templates. So like to build subtrees for OS, App and Team.

You can seen an example here:

(Hans Gruber) #3

Hi Thomas,

thanks for the reply. Yes, would have done this the same way. May question was more like: how to organize the hosts themselves. For example: i have 2 datacenters, north and south. with 10 hosts each. I could now either take hostgroup HG_DC_north and assign there every hosts to the HG by hostname wir Hostgroup apply rule, OR i cold add a variable like “DC_LOCATION” to the the generic host template and then assign the varibable “DC_Location” to arvery host and have then and assign the hosts to the HG by having a HG apply rule like “var.DC_LOCATION = north (or south)”
Thenassign the services to the HG, as you suggestes. So, what are your thoughts on this? Still not sure how to do it properly so it scales well…

Thanks already
Killerloop

(Thomas Widhalm) #4

I’d go for templates which add hostgroups. Normally you don’t need hostgroups at all - they were handy with Nagios or Icinga 1, but in Icinga 2 you don’t need them anymore. You can use them for organisation, though.

You don’t assign services to hostgroups anymore, that’s legacy configuration. In Director you assign Services to Director-Templates and then Director-Templates to Hosts. In Icinga 2 without Director you use apply rules to assign Services directly to Hosts. That’s both very versatile and powerful. Please forget about hostgroups!