Nagios Startup script
Grice, Brett
bgrice at newhopecoal.com.au
Wed Sep 3 05:09:32 CEST 2003
I could not get the orginal script to work correctly kept giving me errors
about the lock file not being found.
I rewrote it to be more uniform with redhats way of doing things now
everything
works the way I expected it to.
Thought it might be useful to someone
Brett,
---
#!/bin/sh
#
# chkconfig: 345 99 01
# description: Nagios network monitor
############################################################################
##
# Date : 03-09-2003
# Script Name : nagios
# Function : nagios startup / stop script
# Author : Brett Grice <bgrice at newhopecoal.com.au>
#
# Description : A rewrite of the nagios startup script for redhat
linux
#
# I'm not the worlds best script writer it works for me
but
# may not work others remember its a quick hack and
really
# only meant to work on Redhat Linux.
############################################################################
###
# Import Functions
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network
# Make sure nagios binaries and config files exist
# Check that networking is up ( redhat and redhat flavors only }
[ ${NETWORKING} = "no" ] && exit 0
[ -f /usr/bin/nagios ] || exit 0
[ -f /etc/nagios/nagios.cfg ] || exit 0
# Get nagios startup config
if [ -f /etc/ssyconfig/nagios ]; then
. /etc/sysconfig/nagios
else
OPTIONS="-d /etc/nagios/nagios.cfg"
fi
RETVAL=0
prog=nagios
start() {
# Start Daemons
echo -n $"Starting $prog: "
daemon nagios $OPTIONS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/nagios
echo $RETVAL
}
stop(){
# Stop Daemons
echo -n $"Shutting down $prog: "
killproc nagios
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/nagios && rm -f
/usr/local/nagios/var/rw/nagios.cmd
echo
return $RETVAL
}
restart(){
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status ${prog}
;;
*)
echo "Usage: nagios {start|stop|restart|status}"
exit 1
esac
# End of this script
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
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