Team,
I am very new to Icinga and trying to implement event handlers.
Seems like I am missing something. Please help as it is not working.
My Config:
/etc/icinga2/zones.d/global-templates
# cat eventhandlers.conf
object EventCommand "event_by_ssh" {
import "plugin-event-command"
command = [ PluginDir + "/check_by_ssh" ]
arguments = {
"-H" = "$event_by_ssh_address$"
"-p" = "$event_by_ssh_port$"
"-C" = "$event_by_ssh_command$"
"-l" = "$event_by_ssh_logname$"
"-i" = "$event_by_ssh_identity$"
"-q" = {
set_if = "$event_by_ssh_quiet$"
}
"-w" = "$event_by_ssh_warn$"
"-c" = "$event_by_ssh_crit$"
"-t" = "$event_by_ssh_timeout$"
}
vars.event_by_ssh_address = "$address$"
vars.event_by_ssh_quiet = false
}
object EventCommand "event_by_ssh_restart_service" {
import "event_by_ssh"
vars.event_by_ssh_logname = "deploy"
vars.event_by_ssh_command = "test $service.state_id$ -gt 0 && sudo
/etc/init.d/httpd restart"
}
I tried creating http service ( as object) and in adding into existing
service as documented in "
http://docs.icinga.org/icinga2/snapshot/doc/module/icinga2/chapter/monitoring-basics"
under sectio 3.8.3.1.
apply Service "http_healthCheck" {
import "generic-service"
check_command = "check_http"
vars.http_ip = "localhost"
vars.http_port = 80
vars.http_string = "Health Check Ok"
vars.http_warn = "0.05"
vars.http_crit = "0.09"
vars.http_uri = "/index.html"
command_endpoint = host.vars.remote_client
event_command = "event_by_ssh_restart_service"
assign where match("webserver.example.com", host.name)
}
I am seeing in logs that event handler is getting triggered, but it is not
executing the command
[2016-06-12 23:32:29 -0700] notice/Checkable: State Change: Checkable
webserver.example.com!http_healthCheck soft state change from OK to
CRITICAL detected.
[2016-06-12 23:32:29 -0700] notice/Checkable: Executing event handler
'event_by_ssh_restart_service' for service 'webserver.example.com
!http_healthCheck'
*Best Regards,*
*__________________________________________*
*Yogesh Sharma*
_______________________________________________
icinga-users mailing list
[email protected]
https://lists.icinga.org/mailman/listinfo/icinga-users