HostGroup Monitoring in Icinga

Hi Guys,

I’m extremely new to Icinga. I have quite extensive experience monitoring via Nagios so the most part I’m handling the learning curve well.

However… for the past 3 days I’ve been pulling my hair out trying to find a Icinga equivalent for Nagios’ HostGroup monitoring (sample below)

Nagios hostgroup.cfg:

define hostgroup{
hostgroup_name
members
}

Nagios service.cfg:

define service{
use
hostgroup
service_description
check_command
max_check_attempts
}

With this method I was able to compose a single service check which would filter to all hosts in the hostgroup.cfg.

I have been searching via google and forums but thus far have had no luck.

Please let me know if anyone can assist.

Thanks Tim

You can have hostgroups in Icinga just like you had in Nagios:

https://icinga.com/docs/icinga2/latest/doc/09-object-types/#hostgroup

The good thing is, that now you can use apply rules to add hostgroups to hosts based on the attributes of the hosts. You don’t have to define them explicitly anymore. Like in the linked example.

object HostGroup "linux-servers" {
  display_name = "Linux Servers"

  assign where host.vars.os == "Linux"
}

But the best thing about this is that you don’t have to use hostgroups anymore. If you really want them, you can have them, but most things that were done by hostgroups can now be achieved much easier.

  • You can use apply rules to assign Services to hosts according to the hosts’ attributes. (Custom vars, patterns of names, patterns of addresses etc.)
  • You can build filters in Icinga Web 2, the API etc. based on these attributes, too.

So there’s really no need for hostgroups anymore. Please don’t try to use them in the “traditional” way - only for a quicker way of filtering your views or in combination with external tools that rely on them.

2 Likes

Thank you so much for your quick response… is there anyway you would be able to assist with a simple example?

http check:

object Service “App1” {
import “generic-service”
host_name = “server1”
check_command = “http”
vars.sla = “24x7”
vars.http_port=8080
vars.notification[“mail”] = { groups = [ “icingaadmins” ] }
}

This obviously work for a single host but I have about 24 servers which I would like to apply this check do and really don’t want to write this out 24 times specifying the individual hosts.

Your help is truly appreciated

You are very welcome.

Would you kindly use the markdown formatting? It really helps with reading code examples:

https://community.icinga.com/faq#format-markdown

You only need this:

apply Service "App1" {
  import "generic-service"
  check_command = "http"
  vars.sla = "24x7"
  vars.http_port = 8080
  vars.notification[“mail”] = { groups = [ “icingaadmins” ] }
apply where host.vars.app == "app1"

And on your host objects you add: vars.app = "app1"

Keep in mind that this is only one simple example what you can do. You can use assign where with pattern matching, compare every attribute and combine rules with || and &&.

If you add this and run icinga2 object list you will see Service objects being created for every host where the custom var app is set to app1. Icinga 2 knows the Service objects like you had them in Nagios but you don’t need to define them anymore but can let Icinga 2 do the heavy lifting with apply rules. The best part about this is that you don’t have to bother with Service objects to add or remove if you add or remove hosts. Whenever you restart/reload Icinga 2 the rules get evaluated.

And you can set custom vars like http_port on your host object. So if some hosts use 8080 but some use 80 you can still use a single rule.

1 Like