<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Jerome,<br>
<br>
See the script below . Is that we use in production:<br>
<br>
François<br>
FMC Luxembourg SA Luxembourg<br>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>
<div class="moz-text-plain" wrap="true" graphical-quote="true"
style="font-family: -moz-fixed; font-size: 12px;" lang="x-western">
<pre wrap="">#!/bin/sh
#
# chkconfig: 345 99 01
# description: Nagios network monitor
#
# File : nagios
#
# Author : Jorge Sanchez Aymar (<a class="moz-txt-link-abbreviated"
href="mailto:jsanchez@lanchile.cl">jsanchez@lanchile.cl</a>)
#
# Changelog :
#
# 1999-07-09 Karl DeBisschop <a class="moz-txt-link-rfc2396E"
href="mailto:kdebisschop@infoplease.com"><kdebisschop@infoplease.com></a>
# - setup for autoconf
# - add reload function
# 1999-08-06 Ethan Galstad <a class="moz-txt-link-rfc2396E"
href="mailto:egalstad@nagios.org"><egalstad@nagios.org></a>
# - Added configuration info for use with RedHat's chkconfig tool
# per Fran Boon's suggestion
# 1999-08-13 Jim Popovitch <a class="moz-txt-link-rfc2396E"
href="mailto:jimpop@rocketship.com"><jimpop@rocketship.com></a>
# - added variable for nagios/var directory
# - cd into nagios/var directory before creating tmp files on startup
# 1999-08-16 Ethan Galstad <a class="moz-txt-link-rfc2396E"
href="mailto:egalstad@nagios.org"><egalstad@nagios.org></a>
# - Added test for rc.d directory as suggested by Karl DeBisschop
# 2000-07-23 Karl DeBisschop <a class="moz-txt-link-rfc2396E"
href="mailto:kdebisschop@users.sourceforge.net"><kdebisschop@users.sourceforge.net></a>
# - Clean out redhat macros and other dependencies
# 2003-01-11 Ethan Galstad <a class="moz-txt-link-rfc2396E"
href="mailto:egalstad@nagios.org"><egalstad@nagios.org></a>
# - Updated su syntax (Gary Miller)
#
# Description: Starts and stops the Nagios monitor
# used to provide network services status.
#
status_nagios ()
{
if test -x $NagiosCGI/daemonchk.cgi; then
if $NagiosCGI/daemonchk.cgi -l $NagiosRunFile; then
return 0
else
return 1
fi
else
if ps -p $NagiosPID > /dev/null 2>&1; then
return 0
else
return 1
fi
fi
return 1
}
printstatus_nagios()
{
if status_nagios $1 $2; then
echo "nagios (pid $NagiosPID) is running..."
else
echo "nagios is not running"
fi
}
killproc_nagios ()
{
kill $2 $NagiosPID
}
pid_nagios ()
{
if test ! -f $NagiosRunFile; then
echo "No lock file found in $NagiosRunFile"
exit 1
fi
NagiosPID=`head -n 1 $NagiosRunFile`
}
# Source function library
# Solaris doesn't have an rc.d directory, so do a test first
if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
elif [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
fi
prefix=/usr/local/nagios
exec_prefix=${prefix}
NagiosBin=${exec_prefix}/bin/nagios
NagiosCfgFile=/etc/nagios/nagios.cfg
NagiosStatusFile=${prefix}/var/status.dat
NagiosRetentionFile=${prefix}/var/retention.dat
NagiosCommandFile=${prefix}/var/rw/nagios.cmd
NagiosVarDir=${prefix}/var
NagiosRunFile=${prefix}/var/nagios.lock
NagiosLockDir=/var/lock/subsys
NagiosLockFile=nagios
NagiosCGIDir=${exec_prefix}/sbin
NagiosUser=nagios
NagiosGroup=nagios
# Check that nagios exists.
if [ ! -f $NagiosBin ]; then
echo "Executable file $NagiosBin not found. Exiting."
exit 1
fi
# Check that nagios.cfg exists.
if [ ! -f $NagiosCfgFile ]; then
echo "Configuration file $NagiosCfgFile not found. Exiting."
exit 1
fi
# See how we were called.
case "$1" in
start)
echo -n "Starting nagios:"
$NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
if [ $? -eq 0 ]; then
su - $NagiosUser -c "touch $NagiosVarDir/nagios.log $NagiosRetentionFile"
rm -f $NagiosCommandFile
touch $NagiosRunFile
chown $NagiosUser:$NagiosGroup $NagiosRunFile
$NagiosBin -d $NagiosCfgFile
if [ -d $NagiosLockDir ]; then touch $NagiosLockDir/$NagiosLockFile; fi
echo " done."
exit 0
else
echo "CONFIG ERROR! Start aborted. Check your Nagios configuration."
exit 1
fi
;;
stop)
echo -n "Stopping nagios: "
pid_nagios
killproc_nagios nagios
# now we have to wait for nagios to exit and remove its
# own NagiosRunFile, otherwise a following "start" could
# happen, and then the exiting nagios will remove the
# new NagiosRunFile, allowing multiple nagios daemons
# to (sooner or later) run - John Sellens
#echo -n 'Waiting for nagios to exit .'
for i in 1 2 3 4 5 6 7 8 9 10 ; do
if status_nagios > /dev/null; then
echo -n '.'
sleep 1
else
break
fi
done
if status_nagios > /dev/null; then
echo ''
echo 'Warning - nagios did not exit in a timely manner'
else
echo 'done.'
fi
rm -f $NagiosStatusFile $NagiosRunFile $NagiosLockDir/$NagiosLockFile $NagiosCommandFile
;;
status)
pid_nagios
printstatus_nagios nagios
;;
checkconfig)
printf "Running configuration check..."
$NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
if [ $? -eq 0 ]; then
echo " OK."
else
echo " CONFIG ERROR! Check your Nagios configuration."
exit 1
fi
;;
restart)
printf "Running configuration check..."
$NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
if [ $? -eq 0 ]; then
echo "done."
$0 stop
$0 start
else
echo " CONFIG ERROR! Restart aborted. Check your Nagios configuration."
exit 1
fi
;;
reload|force-reload)
printf "Running configuration check..."
$NagiosBin -v $NagiosCfgFile > /dev/null 2>&1;
if [ $? -eq 0 ]; then
echo "done."
if test ! -f $NagiosRunFile; then
$0 start
else
pid_nagios
if status_nagios > /dev/null; then
printf "Reloading nagios configuration..."
killproc_nagios nagios -HUP
echo "done"
else
$0 stop
$0 start
fi
fi
else
echo " CONFIG ERROR! Reload aborted. Check your Nagios configuration."
exit 1
fi
;;
*)
echo "Usage: nagios {start|stop|restart|reload|force-reload|status|checkconfig}"
exit 1
;;
esac
# End of this script
</pre>
</div>
<br>
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>
<br>
Meyer Jerome wrote:
<blockquote
cite="mid:46EEEA5FAED9CA479556002BA9C27FD705C59DC1@iw50.iwbnet.ch"
type="cite">
<meta http-equiv="Content-Type" content="text/html; ">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:#404040;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.E-MailFormatvorlage17
{mso-style-type:personal-compose;
font-family:"Courier New";
color:#404040;
font-weight:normal;
font-style:normal;}
.MsoChpDefault
{mso-style-type:export-only;}
@page Section1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="Section1">
<p class="MsoNormal">Hi<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size: 9pt;"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt;">I used with RedHat
„service
nagios stop/start“ to manage the nagios server but I’ll see that the
stop is not enough because one process is running :<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt;"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt;" lang="FR">ps
-ef|grep nagios<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt;" lang="FR">root
16729 16670
0 09:21 pts/1 00:00:00 grep nagios<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt;" lang="FR">nagios
27223 1
0 Apr24 ? 00:02:10 /usr/local/nagios/bin/nagios -d
/etc/nagios/nagios.cfg<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt;" lang="FR"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt;" lang="FR">Which
command to use
to stop nagios properly??<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt;" lang="FR"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt;" lang="FR"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt;" lang="FR"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt;" lang="FR">Thanks
in advance<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt;" lang="FR">Jérôme
Meyer</span><span lang="FR"><o:p></o:p></span></p>
</div>
<pre wrap="">
<hr size="4" width="90%">
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. <a class="moz-txt-link-freetext" href="http://p.sf.net/sfu/kodak-com">http://p.sf.net/sfu/kodak-com</a></pre>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Nagios-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Nagios-users@lists.sourceforge.net">Nagios-users@lists.sourceforge.net</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/nagios-users">https://lists.sourceforge.net/lists/listinfo/nagios-users</a>
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null</pre>
</blockquote>
<br>
</body>
</html>