Iam using a custom variable for sending SMS notifications, for example:
object Host "myhost" {
...
vars.sms_services = [ "uptime","temperature" ]
}
This works well, at least technically.
Typos in the service names of vars.sms_services remain unrecognized.
So I tried to create a new service on each host with vars.sms_services for detecting typos, but this doesnt work at all.
apply Service "sms_configcheck" {
import "generic-service"
check_interval = 2h
max_check_attempts = 1
check_command = "dummy"
var error = 0
var mylist = [ ]
var svcarray = []
mylist = host.vars.sms_services
for (smssvc in mylist) {
error=0
svcarray=get_services(host.name).map(s => s.name)
if ( ! smssvc in svcarray) {
error=1
}
}
vars.dummy_state = error
vars.mylist = mylist
vars.svcarray = svcarray
assign where host.vars.sms_services
}
sms_configcheck is always ok, what is wrong?
tia
Timo