<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.28.3">
</HEAD>
<BODY TEXT="#000099" BGCOLOR="#ffffff">
Hi All,<BR>
<BR>
Need help with an Eventhandler!<BR>
<BR>
After Nagios (successfully) executes the eventhandler, no further checks are done on any host. Nagios is like in a stopped or stalled state. <BR>
<BR>
Here is my config. I actually took it from the manual:<BR>
<BR>
define service {<BR>
host_name blah<BR>
service_description NSCA<BR>
use local_1m<BR>
check_command check_tcp!5667<BR>
event_handler handler_restart_nsca<BR>
event_handler_enabled 1<BR>
register 1<BR>
<BR>
}<BR>
define command {<BR>
command_name handler_restart_nsca<BR>
command_line /usr/share/nagios3/plugins/eventhandlers/restart-nsca $SERVICESTATE$ $SERVICESTATETYPE$ $SERVICEATTEMPT$<BR>
<BR>
}<BR>
<BR>
<BR>
/usr/share/nagios3/plugins/eventhandlers/restart-nsca<BR>
<BR>
#!/bin/sh<BR>
#<BR>
# Event handler script for restarting the web server on the local machine<BR>
#<BR>
# Note: This script will only restart the web server if the service is<BR>
# retried 3 times (in a "soft" state) or if the web service somehow<BR>
# manages to fall into a "hard" error state.<BR>
#<BR>
<BR>
<BR>
# What state is the NSCA service in?<BR>
case "$1" in<BR>
OK)<BR>
# The service just came back up, so don't do anything...<BR>
;;<BR>
WARNING)<BR>
# We don't really care about warning states, since the service is probably still running...<BR>
;;<BR>
UNKNOWN)<BR>
# We don't know what might be causing an unknown error, so don't do anything...<BR>
;;<BR>
CRITICAL)<BR>
# Aha! The HTTP service appears to have a problem - perhaps we should restart the server...<BR>
<BR>
# Is this a "soft" or a "hard" state?<BR>
case "$2" in<BR>
<BR>
# We're in a "soft" state, meaning that Nagios is in the middle of retrying the<BR>
# check before it turns into a "hard" state and contacts get notified...<BR>
SOFT)<BR>
<BR>
# What check attempt are we on? We don't want to restart the web server on the first<BR>
# check, because it may just be a fluke!<BR>
case "$3" in<BR>
<BR>
# Wait until the check has been tried 3 times before restarting the web server.<BR>
# If the check fails on the 4th time (after we restart the web server), the state<BR>
# type will turn to "hard" and contacts will be notified of the problem.<BR>
# Hopefully this will restart the web server successfully, so the 4th check will<BR>
# result in a "soft" recovery. If that happens no one gets notified because we<BR>
# fixed the problem!<BR>
3)<BR>
echo -n "Restarting NSCA service (3rd soft critical state)..."<BR>
# Call the init script to restart the NSCA server<BR>
/etc/init.d/nsca restart<BR>
;;<BR>
esac<BR>
;;<BR>
<BR>
# The HTTP service somehow managed to turn into a hard error without getting fixed.<BR>
# It should have been restarted by the code above, but for some reason it didn't.<BR>
# Let's give it one last try, shall we? <BR>
# Note: Contacts have already been notified of a problem with the service at this<BR>
# point (unless you disabled notifications for this service)<BR>
HARD)<BR>
echo -n "Restarting HTTP service..."<BR>
# Call the init script to restart the NSCA server<BR>
/etc/init.d/nsca restart<BR>
;;<BR>
esac<BR>
;;<BR>
esac<BR>
exit 0<BR>
<BR>
<BR>
<TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%">
<TR>
<TD>
<FONT SIZE="2"><FONT COLOR="#000080">Mit freundlichem Gruß,</FONT></FONT><BR>
<BR>
<FONT SIZE="2"><FONT COLOR="#000080">Harald Böhmecke</FONT></FONT><BR>
<BR>
<FONT SIZE="2"><FONT COLOR="#000080">Network / Infrastructure Services</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#000080">Informationstechnologie D-CSIT-ICS</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#000080">-------------------------------------------------</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#000080">arvato services</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#000080">An der Autobahn</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#000080">33310 Gütersloh</FONT></FONT><BR>
<BR>
<FONT SIZE="2"><FONT COLOR="#000080"><A HREF="http://www.arvato-services.de/">http://www.arvato-services.de</A></FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#000080"><A HREF="mailto:harald.milz@bertelsmann.de">harald.milz@bertelsmann.de</A></FONT></FONT><BR>
<BR>
<FONT SIZE="2"><FONT COLOR="#000080">Tel. +49 (0) 52 41 - 80-85660</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#000080">Fax. +49 (0) 52 41 - 80-9391</FONT></FONT><BR>
<FONT SIZE="2"><FONT COLOR="#000080">Mobile +49 (0) 160-473-9965</FONT></FONT><BR>
<BR>
<FONT SIZE="1"><FONT COLOR="#000080">arvato direct services GmbH: Sitz Gütersloh| Amtsgericht Gütersloh HRB 3826 | Geschäftsführer Ralf Bierfischer, Bodo Krönfeld, Markus Schmedtmann, Eckhard Südmersen</FONT></FONT><BR>
<FONT SIZE="1"><FONT COLOR="#000080">----------------------------------------------------------------------------------------------------------------------------------------------------------------------------</FONT></FONT><BR>
<FONT SIZE="1"><FONT COLOR="#000080">Diese E-Mail und eventuelle Anlagen können vertrauliche und/oder rechtlich geschützte Informationen enthalten. Wenn Sie </FONT></FONT><BR>
<FONT SIZE="1"><FONT COLOR="#000080">nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und </FONT></FONT><BR>
<FONT SIZE="1"><FONT COLOR="#000080">vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser E-Mail sind nicht gestattet</FONT></FONT><BR>
<FONT SIZE="1"><FONT COLOR="#000080">----------------------------------------------------------------------------------------------------------------------------------------------------------------------------</FONT></FONT><BR>
<FONT SIZE="1"><FONT COLOR="#000080">This e-mail and any attachments may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is forbidden.</FONT></FONT> <BR>
<BR>
</TD>
</TR>
</TABLE>
<PRE>
</PRE>
</BODY>
</HTML>