event_handler with Nagios 3 beta ?

oboissard at free.fr oboissard at free.fr
Sat Aug 11 00:19:38 CEST 2007


I forgot system informations  :

OS : Redhat ES4
nagios 3.01 beta compiled from tar.gz file

I used previously nagios 1.x versions

Olivier



oboissard at free.fr a écrit :
> Hello
>
>
> Did anyone succeded in implementing event_handler for services with the 
> new Nagios 3 version ?
> I tried to use them but It didn't work
> So I tried the example in nagios 3 documentation (http-restart) but It 
> didn't work too.
> Maybe I made something wrong because I didn't see anything in 
> nagios.log  referring EVENT handler
>
> parts of conf :
>
> nagios.cfg
> ----------
> => log events , but I don't know where
> log_event_handlers=1
>
> =>I comment it because I wanted specific handler for each services
> #global_host_event_handler=somecommand
> #global_service_event_handler=somecommand
>
> => dont think it's the  problem :
> event_handler_timeout=30
>
> =>enable event handlers
> enable_event_handlers=1
>
>
> commands.cfg
>
> define service{
> 	host_name		127.0.0.1
> 	service_description	check HTTP
> 	max_check_attempts	3
> 	event_handler		restart-httpd
> 	...
> 	}
>
> define command{
> 	command_name	restart-httpd
> 	command_line	/usr/local/nagios/libexec/eventhandlers/restart-httpd  $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$
> 	}
>
>    //usr/local/nagios/libexec/eventhandlers/restart-httpd/ script( from 
> nagios.org)
>
>
> #!/bin/sh
> #
> # Event handler script for restarting the web server on the local machine
> #
> # Note: This script will only restart the web server if the service is
> #       retried 3 times (in a "soft" state) or if the web service somehow
> #       manages to fall into a "hard" error state.
> #
>
>
> # What state is the HTTP service in?
> case "$1" in
> OK)
> 	# The service just came back up, so don't do anything...
> 	;;
> WARNING)
> 	# We don't really care about warning states, since the service is probably still running...
> 	;;
> UNKNOWN)
> 	# We don't know what might be causing an unknown error, so don't do anything...
> 	;;
> CRITICAL)
> 	# Aha!  The HTTP service appears to have a problem - perhaps we should restart the server...
>
> 	# Is this a "soft" or a "hard" state?
> 	case "$2" in
> 		
> 	# We're in a "soft" state, meaning that Nagios is in the middle of retrying the
> 	# check before it turns into a "hard" state and contacts get notified...
> 	SOFT)
> 			
> 		# What check attempt are we on?  We don't want to restart the web server on the first
> 		# check, because it may just be a fluke!
> 		case "$3" in
> 				
> 		# Wait until the check has been tried 3 times before restarting the web server.
> 		# If the check fails on the 4th time (after we restart the web server), the state
> 		# type will turn to "hard" and contacts will be notified of the problem.
> 		# Hopefully this will restart the web server successfully, so the 4th check will
> 		# result in a "soft" recovery.  If that happens no one gets notified because we
> 		# fixed the problem!
> 		3)
> 			echo -n "Restarting HTTP service (3rd soft critical state)..."
> 			# Call the init script to restart the HTTPD server
> 			/etc/rc.d/init.d/httpd restart
> 			;;
> 			esac
> 		;;
> 				
> 	# The HTTP service somehow managed to turn into a hard error without getting fixed.
> 	# It should have been restarted by the code above, but for some reason it didn't.
> 	# Let's give it one last try, shall we?  
> 	# Note: Contacts have already been notified of a problem with the service at this
> 	# point (unless you disabled notifications for this service)
> 	HARD)
> 		echo -n "Restarting HTTP service..."
> 		# Call the init script to restart the HTTPD server
> 		/etc/rc.d/init.d/httpd restart
> 		;;
> 	esac
> 	;;
> esac
> exit 0
>
>
>
>
> Regards
>
> Olivier
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/
> _______________________________________________
> 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
>
>
>   


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
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