My bad. What if you create a new dictionary for this?
Maybe another possbile way: you could write a function to “filter” the interfaces beforehand:
object Host "test" {
check_command = "dummy"
vars.interfaces["test-1"] = {
usage = true
}
vars.interfaces["test-2"] = {
usage = false
}
}
apply Service "interfaces-usage" for (int => config in get_interfaces_with_usage(host.vars.interfaces)) {
check_command = "dummy"
vars += config
}
globals.get_interfaces_with_usage = function(interfaces) {
var res = {}
for (ifname => ifvalues in interfaces) {
if (ifvalues.usage) {
res[ifname] = ifvalues
}
}
return res
}
Just tested it and it seems to be working.
Kind regards