Setting custom variables from host group and using them from a service


when I install icinga from Debian stable’s packages, I get default ping services for all of my hosts:

apply Service "ping4" {
  import "generic-service"
  check_command = "ping4"

  assign where host.address

I’d like to modify this service without actually modifying it. For example, for hosts in asia, I need other warning/critical thresholds. I have tried modifying ping4’s variables by establishing a host group:

object HostGroup "loc-asia" {
        assign where host.vars.loc == "asia"
        vars.ping_wrta = 500
        vars.ping_wpl = 20
        vars.ping_crta = 6000
        vars.ping_cpl = 60

When I add vars.loc = “asia” to a host definition, i see in the web ui that the host is added to the HostGroup loc-asia. However, ping4 still uses the default thresholds.

What addiitonally confuses me is that I need to write host.vars.loc in the assign clause (“Tried to access undefined script variable ‘vars’” instead) , while I cannot write host.vars.ping_wrta in the assignments (“Attribute ‘host’ does not exist.” instead) .

Am I holding things wrong, or are the example services that come with the package really only useable for the most basic of setups?


Hi and welcome,

hostgroup variables never worked and will never work. But you can put your variables into the host template for example or create a services that checks the host.vars.loc and decides how to set the thresholds.



I am now importing an addiitonal host template to my hosts that only sets the location-dependent variables. That works. Thanks.

Can you point me towards docs about the hostgroup variables issue? Does the same apply to variables set in a service group?


Host/service groups are an old relic from dark times of icinga1 or the n*** word. Custom vars are far mor flexible when it comes to apply rules or group things together. If you want to make groups for icingaweb2 you can use the cube module (i highle recomend it).


Hello there!
Glad to see you joined us here too now :slight_smile:

I can only agree with Carsten on this one, the cube helps a lot with the grouping.

You might have already looked into it, but here would be a good starting point to learn about templating and build your config around that :slight_smile:

Have a nice day!