Icinga2 check threshold scopes

Hi,

I’m quite new to icinga so please forgive if I might have overlooked certain things.
I setup a combination of two masters running FreeBSD 12.2.
icinga2-2.12.3

I’m currently also writing my own Ansible roles to get my setup up and running (ansible_managemynetwork/roles/ansible_icinga2 at main · imp1sh/ansible_managemynetwork · GitHub).

One concept I’m not able to grasp is how to handle threshold scopes for my checks. This is a generated check I use on all of my agent based hosts.

apply Service "procs" {
  import "generic-service"
  check_command = "procs"
  assign where host.vars.agent_endpoint
  command_endpoint = host.vars.agent_endpoint
}

This is an example host:

object Host "bsdrx1.mydomain.net" {
  address6 = "2a00:1111:2222:10::15"
  vars.agent_endpoint = "bsdrx1.mydomain.net"
  vars.os = "FreeBSD"
  import "generic-host"
}

So my host uses default thresholds which I tried to overwrite for several hosts like this:

object Host "mailrx1.mydomain.net" {
  address6 = "2a00:1111:2222:2::4"
  vars.agent_endpoint = "mailrx1.mydomain.net"
  vars.os = "Linux"
  vars.procs_warning = "500"
  vars.procs_critical = "700"
  import "generic-host"
}

I already found out that those vars set on host level unfortunately are not being used but according so some google results it seems I would have to modify the service object itself to use the host var if it is set.

if (host.vars.procs_warning) {
  vars.procs_warning = host.vars.procs_warning
} 

What I don’t understand is that it seems like I would have to modify every single check with such minor code so I will be able to get some kind of scope abstraction. I would have imagned it be be some kind of builtin feature.

Am I having trouble understanding the icinga2 concept?

Hi @pebrille

it works for me when I do not set any vars in the service object. Example:

object Host "dummy-host" {
  check_command = "dummy"
  vars.procs_warning = "333"
  vars.procs_critical = "444"
}
apply Service "dummy-procs" {
  check_command = "procs"
  assign where host.name == "dummy-host"
}

Result:
grafik

As soon as I set the var in the service object, the host vars are no longer applied.

apply Service "dummy-procs" {
  check_command = "procs"
  vars.procs_warning = "666"
  assign where host.name == "dummy-host"
}

Result:
grafik

I found out that my threshold is being accepted somehow…
The WebGUI is showing the correct threshold but after a minute or so the threshold just switches to 250/400 warning/critical without any user interaction. The service keeps alternating between my settings and the default settings. I have 0 clue what’s going on.