Hi!
I’d like to do an active “Host rebooted?” check. Currently I have a passive check defined in Icinga2 and I’m running scripts on every nodes in every minute to check if the host rebooted. When a reboot is detected the script calls the Icinga2 API and send a passive check result to set the state of the check to “CRITICAL”. With this method I can detect easily an unexpected reboot(e.g. cluster fencing). If I would do it with an active check then my check would be “CRITICAL” for once and on the next time would be “OK” again.
I’d like to change this passive check method to an active check and I have the idea: I write a plugin that is called by my active check in every minute. The plugin can be return with “OK” and with “CRITICAL” when reboot was detected. I would define a condition in my apply Service definition if the state is not “OK” then set enable_active_checks=false, else so It will be “CRITICAL” until I change back to “OK” manually.
I think something like this:
apply Service “Uptime” {
import “generic-service”
command_endpoint = host.vars.client_endpoint
check_command = “custom_uptime”
if ( state != “OK” ) {
enable_active_checks=false
} else {
enable_active_checks=true
}
assign where host.zone == ZoneName && host.vars.os.type == “linux”
}
I’m affraid it’s not possibly what I want because the config evaluates on start/reload only. Is it possible to tell Icinga2 somehow if the check state is not OK then hang up checking and return to periodically checking when I send an “OK” passive check result manually?
Thanks!