Hi all,
I just discovered a strange behaviour I can’t explain.
We have a rather complex dictionary structure in certain host objects:
vars.ibm_perfserv = {
servers = {
"server1" = {
jdbc = {
"jdbc/myjdbc1" = {
dbconnectionpoolwaitingthreadcount.perfserv_warn = 10
dbconnectionpoolwaitingthreadcount.perfserv_crit = 20
}
}
}
}
}
We are using the following apply rule to parse the mentioned data:
apply Service for (jdbc_name => jdbc_config in
flatten_dictionary(host.vars.ibm_perfserv.servers, "jdbc")) {
name = "IBM WebSphere database connection pool waiting thread count " + jdbc_config.parent + "/" + jdbc_name
import "generic-service"
check_command = "perfserv"
vars += jdbc_config.dbconnectionpoolwaitingthreadcount
vars.perfserv_cellname = host.vars.ibm_perfserv.cellname
vars.perfserv_nodename = host.vars.ibm_perfserv.nodename
vars.perfserv_servername = jdbc_config.parent
vars.perfserv_jdbcname = jdbc_name
vars.perfserv_command = "show"
vars.perfserv_metric = "DBConnectionPoolWaitingThreadCount"
assign where typeof(host.vars.ibm_perfserv) == Dictionary && jdbc_config.contains("dbconnectionpoolwaitingthreadcount")
}
This is all working as intended, but when I now inspect the host object’s vars in Icingaweb2 or via API, I get the following:
"ibm_perfserv": {
"servers": {
"server1": {
"jdbc": {
"jdbc/myjdbc1": {
"dbconnectionpoolwaitingthreadcount": {
"perfserv_crit": 20.0,
"perfserv_warn": 10.0
},
"parent": "server1"
}
}
}
}
}
As you can see, there is now a key “parent” below “jdbc/myjdbc1”.
I suspect this is due to the use of jdbc_config.parent
, but from my unterstanding parent
should rather resolve to the parent element than creating a key by that name.
To me it seems that parent
does both, since jdbc_config.parent
also is being replaced properly, as my service is created with the name IBM WebSphere database connection pool waiting thread count server1/jdbc/myjdbc1
Can someone explain this behaviour?
Cheers,
Markus