Service/Process monitoring in Specific set of services with Icinga2

I am very new to Icinga2. In our environment we have around 350-400 servers are there… Most of the systems are windows based. We have only one service file that are updating for all metrics… Every time when i add apply service it is getting updated for all the servers at a time… How can we make changes that get effect only on specific set of servers. For example IIS windows service exists in few hosts, how can i update the service that get effect only on specific set of servers… Can someone please give an advise?

Yes, but first some information is required.
Do you use Director or just plain text configuration files?

In either case you need to set appropriate variables so that Icinga can tell apart the servers.

Cheers,
George

1 Like

I have not done through Icinga director… I am doing through configuration files.

Is it best practice to use the Icinga2 director? what is your advise on this.

It is not a case of best practice as both approaches are equally good.

As for the original question, you can use your own variables inside the host definition like:

vars.services = [“Apache”]

Look into groups.conf for more examples and I will elaborate further if you have more questions.

/George

1 Like

Currently we have 300 hosts & I have been making 300 host files for all servers through jenkins…

There are different services spread across all the hosts… In this case, I have to update
vars.services = [“”] for services for all hosts? This will be huge manual process to update every configuration file right? is there anyway best practice to do these kind of things? I am worried about both service & http checks… want to reduce human effort

Hi,

I would define base host templates which define the default services for Windows. Depending on which additional template is included, additional service apply rule may match.

template Host "windows-basic" {
  check_command = "hostalive"

  vars.services = [ "disk", "update" ]
}

template Host "windows-iss" {
  vars.services += [ "iss" ]
}
object Host "iss-server" {
  import "windows-basic"
  import "windows-iss"

  address = "..."
}

There’s two possibilities for assign where expressions now:

  • Use vars.services
apply Service "disk" {
   check_command = "disk-windows"

   assign where "disk" in host.vars.services
}

apply Service "iss" {
   check_command = "..."

   assign where "iss" in host.vars.services
}

  • Use the imported templates
apply Service "disk" {
   check_command = "disk-windows"

   assign where "windows-basic" in host.templates
}

apply Service "iss" {
   check_command = "..."

   assign where "windows-iss" in host.templates
}

The last option allows to change the templates without having to modify the host nor service apply rules later. It is harder to read immediately how the service apply rule works though. The Director follows a similar approach when creating such apply rules and service sets.

Cheers,
Michael

2 Likes

Excellent… Thanks a lot for your response. will definitely try this