Icinga2 - Variables

Dear Community,

i want to apply this Check:

apply Service "Local Storage" {
  import "generic-service"
  check_command = "check_xenhost"
  vars.check_name = "local_storage"
  vars.warn_value = 80
  vars.critical_value = 90
  assign where host.vars.application.xen.role == "xenserver"  
  ignore where "Local Storage" in host.vars.disabled_checks # -> geht
  #ignore where this.name in host.vars.disabled_checks # -> geht nicht

object Host "SERVER1" {
    vars.disabled_checks = ["Local Storage"]

Why is the vaiable this.name not working?
Has somebody an idea?


Your ignore rule is incorrect, you need it to be

ignore where host.vars.disabled_checks match ( “Local Storage”)

not sure the syntax is right, best check the docs.


try with service.name.



the variable “service.name” also doesn’t work.

[2020-03-20 10:46:54 +0100] critical/config: Error: Error while evaluating expression: Tried to access undefined script variable ‘service’
Location: in /data/app/icinga2/objects.d/services/server/xen-services.conf: 55:16-55:22
/data/app/icinga2/objects.d/services/server/xen-services.conf(53): #ignore where “Local Storage” in host.vars.disabled_checks
/data/app/icinga2/objects.d/services/server/xen-services.conf(54): #ignore where this.name in host.vars.disabled_checks
/data/app/icinga2/objects.d/services/server/xen-services.conf(55): ignore where service.name in host.vars.disabled_checks

I have started the debugger (icinga2 daemon -C -X) and looked into it.
It seems, that I can’t access the variables from the service object I want to apply. I think, this is because the assign/ignore rule using another scope.

If I’m writing the service.name to globals, I can access the name within the assign/ignore rule. But this solution isn’t very pretty :slight_smile:

globals.my_service_name = this.name
ignore where globals.my_service_name in host.vars.disabled_checks