Eventhandlers

Capacci Thomas mrcapacci at free.fr
Fri Sep 10 20:47:08 CEST 2004


Martin, Stanley G [CGEY Contractor for Sprint] a écrit :

> I use eventhandlers all the time.  What's the question?
Hi
i am trying to make an eventhandler which allows nagios to restart httpd 
when it's stopped. I've followed documentation step to step.
i've enable event handler in nagios.cfg

i've defined first a service:
define service{
	use				generic-service		; Name of service template to use

	host_name			192.168.10.1
	service_description		HTTPD
	is_volatile			0
	check_period			24x7
	max_check_attempts		4
	normal_check_interval		5
	retry_check_interval		1
	event_handler			restart-http
	contact_groups			linux-admins
	notification_interval		120
	notification_period		24x7
	notification_options		w,u,c,r
	check_command			restart-http
	event_handler_enabled		1
	}
so this event correesponds to this service:
define service{
	use				generic-service		; Name of service template to use

	host_name			192.168.10.1
	service_description		HTTP
	is_volatile			0
	check_period			24x7
	max_check_attempts		4
	normal_check_interval		5
	retry_check_interval		1
	contact_groups			linux-admins
	notification_interval		120
	notification_period		24x7
	notification_options		w,u,c,r
	check_command			check_http
	event_handler_enabled		1
	}
i wasn't shure about the option event_handler_enabled so i put it in 
both services

then i've defined the command:

define command{
	command_name	restart-httpd
	command_line	/usr/local/nagios/libexec/eventhandlers/restart-http 
$SERVICESTATE$ $STATETYPE$ $SERVICEATTEMPT$
	}
i've placed this command definition in miscommands.cfg as the 
documentation tells this is where eventhandlers commands are stored
and a script:

#!/bin/sh
case "$1" in
OK)
;;
WARNING)
;;
UNKNOWN)
;;
CRITICAL)
	case "$2" in
	SOFT)
		case "$3" in
		3)
		echo -n "Redémarrage du service HTTP (3rd soft critical state)..."
	        /usr/bin/ssh nagios at 192.168.10.1 "sudo /etc/init.d/httpd restart"	
		;;
		esac
		;;

	HARD)
		echo -n "Redémarrage HTTP..."
		/usr/bin/ssh nagios at 192.168.10.1 "sudo /etc/init.d/httpd restart"
		;;
esac
;;
esac
exit 0

The script is working, i've tested it both on machine that support 
nagios and on the remote host.
Nagios says service HTTPD (the restart-http service not the check-http) 
is status ok but status information tells (No output!). I've stopped 
httpd to watch the eventhandler and nothing happens.
I'll be very happy to know how make this whole thing work fine, i've 
been looking for issue since several days now.
Hope to read you soon.

Regards.




-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. 
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list