Override vars not working for service-applies

Hi everybody,

based on the following setup:

  • icinga2 r2.10.2-1
  • icingaweb2 2.6.2
  • director 1.6.1 (master)

I have set up the following:

  • service template _srv_disk_win with inherited disk_win_crit and disk_win_warn from command
  • service apply “Disk $config$”, importing _srv_disk_win and applying host.vars.disks:
    apply Service for (config in host.vars.disks) {
    name = "Disk " + config
    import “srv_disk_win"
    assign where match("win
    *”, host.vars.os)
    vars.disk_win_path = config
    import DirectorOverrideTemplate
    }
  • a host service override for a specific host
    object Host “myhostname” {
    import “_host_generic”
    import “_os_win-srv-2008r2”
    import “_net_internal-lan”
    display_name = “My Server”
    address = “1.2.3.4.”
    check_command = “hostalive”
    vars["_override_servicevars"] += {
    “Disk $config$” = {
    disk_win_crit = “5%”
    disk_win_warn = “10%”
    }
    }
    vars.disks = [ “C:\”, “D:\” ]
    }

However, the servicevars override is not used in the check…the service is warning disk c: at 15% free.
Inspecting the service shows only “vars { disk_win_path: “C:\” }”

I found a bug @Github but which was fixed in Mid-2018.

Any ideas?
Best,
Matthias

This is using an apply for rule which looks into host.vars.disks and iterates over the array elements. The overriding import of the template doesn’t look good in the host object, especially the $config$ string will never match nor will the template override be aware of this.

Yet, I am not sure if apply for loops fully support such service overrides. At least the name expansion to “Disk C:” is missing in order to override the specific variables.

Which steps were taken in the web interface to achieve exactly this situation, best with screenshots? Maybe we can reproduce the question with you.

Cheers,
Michael

Hi @dnsmichi
thanks for your reply…
I did some screenshots, I hope I catched everything to gather the config path. But due to community limits I have to split it up…

External Command

Using it in a Service Template

Applying this service via apply rules


Overwriting service settings in host config

Inspecting the resulting service

Thanks,
Matthias

Btw: I am a little bit lost in the middle of using “service-apply rules” which makes it harder to have different defaults (e.g. different thresholds) or “service-sets” where I can not iterate through host.vars…:-/