Our team is just getting started with icinga2. We have an existing homegrown tool that checks a lot of different things depending on an argument so we have a series of CheckCommand
objects that vary by only one argument. These checks need to be applied to multiple database instances across multiple hosts. Creating separate CheckCommand
s is working fine, like this:
object Host "some.oracle.host" {
import "oracle-host"
address = "172.1.1.1"
vars.db_instances = {
"EnvName" = {
"username" = "username"
"password" = "EQo1OF95G8Gs"
"dbname" = "FOO"
"connstr" = "jdbc:oracle:thin:@(FOO)"
}
}
apply Service for (env => instance in host.vars.db_instances) {
import "oracle-db-svc"
check_command = "check_oracle_foocheck"
display_name = env + "-foocheck"
vars.svc_dbname = instance["dbname"]
}
apply Service for (env => instance in host.vars.db_instances) {
import "oracle-db-svc"
check_command = "check_oracle_barcheck"
display_name = env + "-barcheck"
vars.svc_dbname = instance["dbname"]
}
Here we are creating new “check_oracle_foocheck” and “check_oracle_barcheck” services for each instance of each host that has a db_instances
variable. It works well but the problem is, we have a couple dozen of those checks to implement. I’m looking for something simpler, something like:
const OracleChecks = ["foocheck", "barcheck"]
apply Service for (check in OracleChecks) {
import "oracle-db-svc"
for(env => instance in host.vars.db_instances){
check_command = "$check$"
display_name = env + "-$check$"
}
}
I assume this wouldn’t work because the apply for rule isn’t actually returning and maybe you can’t iterate on hosts within an apply for. Here I’m just trying to convey the objective.
What I’m after is an approach to make sort of a matrix assignment of a set of services to sets of instances which live on multiple hosts. Any tips?
Andy
p.s. - Cross-posted to SOF