Hi,
I wrote a small wrapper to have an “always OK” configuration for check commands if needed.
The use case is let a service exit with OK even if the executed plugin exits with WARNING or CRITICAL.
I need this feature only for a few services, so I’m trying to hack the command definitions to execute this wrapper if needed:
object CheckCommand "_check_pve" {
import "ipv4-or-ipv6"
if (vars.pve_always_ok == true) {
vars.check_command = [ "/opt/icinga2-plugins/always-ok", "/opt/icinga2-plugins/check_pve.rb" ]
} else {
vars.check_command = [ "/opt/icinga2-plugins/check_pve.rb" ]
}
command = vars.check_command
arguments = {
[...]
}
}
I added the variable pve_always_ok
to the Service definition:
But it is not working:
If I try changing the command definition condition to:
if (true) {
vars.check_command = [ "/opt/icinga2-plugins/always-ok", "/opt/icinga2-plugins/check_pve.rb" ]
} else {
vars.check_command = [ "/opt/icinga2-plugins/check_pve.rb" ]
}
it works:
Could you please help me to understand where I’m wrong in the following statement:
if (vars.pve_always_ok == true) {
Thank you very much!
Bye