<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-2022-jp" http-equiv=Content-Type>
<META content="MSHTML 5.00.2920.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>Hello everybody!</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>I've tried to apply the event handler to restart a
service,which is probed to be down by nagios,on a remote host.I don't know
what's wrong with my work. Please take a look at my work as mentioned
below.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>1. the script that is called by nagios to restart a
service.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> #!/bin/sh</FONT></DIV>
<DIV><FONT size=2> </FONT></DIV>
<DIV><FONT size=2> case "$1" in</FONT></DIV>
<DIV><FONT size=2> OK)</FONT></DIV>
<DIV><FONT size=2>
;;</FONT></DIV>
<DIV><FONT size=2> WARNING)</FONT></DIV>
<DIV><FONT size=2>
;;</FONT></DIV>
<DIV><FONT size=2> UNKNOWN)</FONT></DIV>
<DIV><FONT size=2>
;;</FONT></DIV>
<DIV><FONT size=2> CRITICAL)</FONT></DIV>
<DIV><FONT
size=2>
</FONT></DIV>
<DIV> </DIV>
<DIV><FONT
size=2> case
"$2" in</FONT></DIV>
<DIV><FONT
size=2>
SOFT)</FONT></DIV>
<DIV><FONT
size=2>
case "$3" in</FONT></DIV>
<DIV><FONT size=2>
3)</FONT></DIV>
<DIV><FONT size=2>
ssh
$4 /etc/rc.d/init.d/httpd restart</FONT></DIV>
<DIV><FONT size=2>
;;</FONT></DIV>
<DIV><FONT size=2>
esac</FONT></DIV>
<DIV><FONT size=2>
;;</FONT></DIV>
<DIV><FONT size=2>
HARD)</FONT></DIV>
<DIV><FONT size=2>
ssh $4 /etc/rc.d/init.d/httpd
restart</FONT></DIV>
<DIV><FONT size=2>
;;</FONT></DIV>
<DIV><FONT size=2>
esac</FONT></DIV>
<DIV><FONT size=2>
;;</FONT></DIV>
<DIV><FONT size=2> esac</FONT></DIV>
<DIV><FONT size=2> exit 0</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>2. Here is the syntax of serviccs.cfg</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2># Service definition<BR>define
service{<BR> use generic-service ; Name
of service template to use</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> host_name
hestia<BR> service_description HTTP<BR> is_volatile
0<BR> check_period
24x7<BR> max_check_attempts
4<BR> normal_check_interval
5<BR> retry_check_interval
1<BR> contact_groups
admins<BR> notification_interval
120<BR> notification_period
24x7<BR> notification_options w,u,c,r</DIV>
<DIV> event_handler_enabled 1</DIV>
<DIV> check_event_handler service-restart<BR> check_command
check_http<BR> }</DIV>
<DIV> </DIV>
<DIV>3. Here is the syntax of checkcommands.cfg</DIV>
<DIV> </DIV>
<DIV># 'event_handler' command definition<BR>define
command{<BR> command_name
service-restart<BR> command_line /usr/local/nagios/libexec/service-restart
$SERVICESTATE$ $STATETYPE$ $SERVICEATTEMP$ $HOSTADDRESS$<BR> }</DIV>
<DIV> </DIV>
<DIV>For test i stopped the http service on a remote machine and tried to
execute by hand the following command:
<DIV> ssh 192.168.1.200 /etc/rc.d/init.d/httpd restart .
Well, it worked well (of course i set ssh to passwordless).</DIV>
<DIV> </DIV>
<DIV>Is there anything wrong with my script?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Thanks in advance for your help</DIV>
<DIV> </DIV></DIV>
<DIV> </DIV><PRE> </PRE></FONT>
<DIV> </DIV>
<DIV><FONT
size=2>_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/<BR>_/<BR>_/$B!!!!F|K\%"%k%F%_%93t<02q<R(B<BR>_/$B!!!!%9!<%s!&%t%!%K!<(B
(Soeun Vanny)<BR>_/$B!!!!(Bmailto : <A
href="mailto:vanny@artemis-it.com">vanny@artemis-it.com</A><BR>_/<BR>_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/<BR></FONT></DIV></BODY></HTML>