Hi,
I am trying to create object Service with inner loop over variable. Service must be executed locally.
It’s clearly stated in the documentation how to iterate over variable within apply Service statement but it’s always applied for Service executed remotely (in term of Top Down cluster it’s command endpoint scenario).
The most successful example, I was able to create, is attached bellow (most successful means the validation passed with warnings). With the example below the services won’t appear in WebUI and the cofig validation yield that the service won’t fit anywhere…
Please, is there anyone who knows the general solution for the topic?
Thank you in advance.
Example:
object CheckCommand "some_command" {
command = [PluginDir + "/some_command"]
arguments = {
"--first" = {
value = "$first_arg$"
}
"--second" = {
value = "$second_args$"
}
}
}
object Host "test.example" {
import "generic-host"
address = "test.example"
vars.os = "Linux"
vars.distro = "Debian"
vars.agent_type = "Icinga"
vars.agent_endpoint = "test.example"
zone = "master"
vars.first = ["a", "b", "c"]
}
apply Service "some_service" for (value in host.vars.first) {
import "generic-service"
display_name = "name"
host_name = "test.example"
check_command = "some_command"
vars.first = value
vars.second = "4000"
assign where host.vars.address == "test.example"
}
Environment:
- Icinga2* - 2.13.3-1
- Icinga2web* - 2.8.2-1
- OS: Debian 10 - Buster
- Icinga2 validation passed with warning: Apply rule “some_service” for type Service does not match anywhere!
- Plugin is self-made