Event Handler for a service
Posted: Thu Jun 11, 2020 1:50 am
Good morning,
I was taking a look to event_handler in Nagios Core and it specifies an event handler as a trigger such as bellow
define service{
host_name somehost
service_description HTTP
max_check_attempts 4
event_handler restart-httpd
...
}
Once the service has been defined with an event handler, we must define that event handler as a command. An example command definition for restart-httpd is shown below. Notice the macros in the command line that I am passing to the event handler script - these are important!
define command{
command_name restart-httpd
command_line /usr/local/nagios/libexec/eventhandlers/restart-httpd $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$
}
Now, let's actually write the event handler script (this is the /usr/local/nagios/libexec/eventhandlers/restart-httpd script).
SO I UNDERSTAND WHEN THE SERVICE GOES DOWN THE SCRIPT IS TRIGGERED AND THE THE SERVICE IS RESTARTED.
HOW CAN CONFIGURE THIS IN NAGIOSXI
MANY THANKS IN ADVANCE
KIND REGARDS
I was taking a look to event_handler in Nagios Core and it specifies an event handler as a trigger such as bellow
define service{
host_name somehost
service_description HTTP
max_check_attempts 4
event_handler restart-httpd
...
}
Once the service has been defined with an event handler, we must define that event handler as a command. An example command definition for restart-httpd is shown below. Notice the macros in the command line that I am passing to the event handler script - these are important!
define command{
command_name restart-httpd
command_line /usr/local/nagios/libexec/eventhandlers/restart-httpd $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$
}
Now, let's actually write the event handler script (this is the /usr/local/nagios/libexec/eventhandlers/restart-httpd script).
SO I UNDERSTAND WHEN THE SERVICE GOES DOWN THE SCRIPT IS TRIGGERED AND THE THE SERVICE IS RESTARTED.
HOW CAN CONFIGURE THIS IN NAGIOSXI
MANY THANKS IN ADVANCE
KIND REGARDS