|
From: Heiko Z. <smi...@us...> - 2006-08-20 19:50:04
|
Update of /cvsroot/devil-linux/build/scripts/scripts In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv6713/scripts/scripts Added Files: Tag: rel-1-2-patches nagios nrpe nsca Log Message: added nagios nagios-plugin still needs work, since it hardcodes path names and didn't find everything --- NEW FILE: nrpe --- #!/bin/bash # # $Source: /cvsroot/devil-linux/build/scripts/scripts/Attic/nrpe,v $ # $Revision: 1.1.2.1 $ # $Date: 2006/08/20 19:49:57 $ # # http://www.devil-linux.org # ### BEGIN INIT INFO # Provides: nrpe # Required-Start: $network $syslog $named # Required-Stop: $network $syslog $named # Default-Start: # Default-Stop: # Description: Nagios Remote Execution Daemon ### END INIT INFO # settings source /etc/sysconfig/config # parameters NAME="Nagios Remote Execution Daemon" CONFIGNAME=NRPE DAEMON=/usr/sbin/nrpe PARAMETER="-c /etc/nagios/nrpe.cfg -d" # source function library source /etc/init.d/functions eval START=\$START_$CONFIGNAME # Determine the base and follow a runlevel link name. base=${0##*/} link=${base#*[SK][0-9][0-9]} # Force execution if not called by a runlevel directory. test $link = $base && START=yes test "$START" = "yes" || exit 0 if [ ! -e $DAEMON ]; then echo echo "$DAEMON not found. Did you install the package?" exit 1 fi case "$1" in start) echo -n "Starting $NAME: " loadproc $DAEMON $PARAMETER ;; stop) echo -n "Shutting down $NAME: " killproc $DAEMON ;; restart) $0 stop sleep 1 $0 start ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 ;; esac --- NEW FILE: nsca --- #!/bin/bash # # $Source: /cvsroot/devil-linux/build/scripts/scripts/Attic/nsca,v $ # $Revision: 1.1.2.1 $ # $Date: 2006/08/20 19:49:57 $ # # http://www.devil-linux.org # ### BEGIN INIT INFO # Provides: nsca # Required-Start: $network $syslog $named # Required-Stop: $network $syslog $named # Default-Start: # Default-Stop: # Description: Nagios Secure Comunication Daemon ### END INIT INFO # settings source /etc/sysconfig/config # parameters NAME="Nagios Secure Communication Daemon" CONFIGNAME=NSCA DAEMON=/usr/sbin/nsca PARAMETER="-c /etc/nagios/nsca.cfg -s" # source function library source /etc/init.d/functions eval START=\$START_$CONFIGNAME # Determine the base and follow a runlevel link name. base=${0##*/} link=${base#*[SK][0-9][0-9]} # Force execution if not called by a runlevel directory. test $link = $base && START=yes test "$START" = "yes" || exit 0 if [ ! -e $DAEMON ]; then echo echo "$DAEMON not found. Did you install the package?" exit 1 fi case "$1" in start) echo -n "Starting $NAME: " loadproc $DAEMON $PARAMETER ;; stop) echo -n "Shutting down $NAME: " killproc $DAEMON ;; restart) $0 stop sleep 1 $0 start ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 ;; esac --- NEW FILE: nagios --- #!/bin/bash # # $Source: /cvsroot/devil-linux/build/scripts/scripts/Attic/nagios,v $ # $Revision: 1.1.2.1 $ # $Date: 2006/08/20 19:49:56 $ # # http://www.devil-linux.org # ### BEGIN INIT INFO # Provides: nagios # Required-Start: $network $syslog $named # Required-Stop: $network $syslog $named # Default-Start: # Default-Stop: # Description: Nagios Daemon ### END INIT INFO # settings source /etc/sysconfig/config # parameters NAME="Nagios Network Monitor" CONFIGNAME=NAGIOS # source function library source /etc/init.d/functions eval START=\$START_$CONFIGNAME # Determine the base and follow a runlevel link name. base=${0##*/} link=${base#*[SK][0-9][0-9]} # Force execution if not called by a runlevel directory. test $link = $base && START=yes test "$START" = "yes" || exit 0 status_nagios () { if test ! -f $NagiosRunFile; then echo "No lock file found in $NagiosRunFile" return 1 fi NagiosPID=`head -n 1 $NagiosRunFile` 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; then return 0 else return 1 fi fi return 1 } killproc_nagios () { if test ! -f $NagiosRunFile; then echo "No lock file found in $NagiosRunFile" return 1 fi NagiosPID=`head -n 1 $NagiosRunFile` kill $2 $NagiosPID } prefix=/usr exec_prefix=${prefix} NagiosBin=${exec_prefix}/bin/nagios NagiosCfgFile=/etc/nagios/nagios.cfg NagiosStatusFile=/var/run/nagios/status.dat NagiosTempFile=/var/run/nagios/nagios.tmp NagiosRetentionFile=/var/run/nagios/retention.dat NagiosCommandFile=/var/run/nagios/rw/nagios.cmd NagiosVarDir=/var/run/nagios NagiosRunFile=/var/run/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 "Starting network monitor: 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 #sleep 1 #status_nagios nagios exit 0 else echo "CONFIG ERROR! Start aborted. Check your Nagios configuration." exit 1 fi ;; stop) echo "Stopping network monitor: 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 - running nagios did not exit in time' else echo ' done.' fi rm -f $NagiosStatusFile $NagiosTempFile $NagiosRunFile $NagiosLockDir/$NagiosLockFile $NagiosCommandFile ;; status) status_nagios nagios ;; restart) printf "Running configuration check..." $NagiosBin -v $NagiosCfgFile > /dev/null 2>&1; if [ $? -eq 0 ]; then echo "done" $0 stop $0 start else #$NagiosBin -v $NagiosCfgFile echo " FAILED! 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 NagiosPID=`head -n 1 $NagiosRunFile` if status_nagios > /dev/null; then printf "Reloading nagios configuration..." killproc_nagios nagios -HUP echo "done" else $0 stop $0 start fi fi else #$NagiosBin -v $NagiosCfgFile echo " FAILED! Reload aborted. Check your Nagios configuration." exit 1 fi ;; *) echo "Usage: nagios {start|stop|restart|reload|force-reload|status}" exit 1 ;; esac # End of this script |