All pastes #385026 Raw Edit

Anonymous

public shellscript v1 · immutable
·published 2007-03-07 15:16 UTC
rendered paste body
#!/bin/sh## Description: Starts and stops the Nagios monitor#              used to provide network services status.#status_nagios (){        if test ! -f $NagiosRun; then                echo "No lock file found in $NagiosRun"                return 1        fi        NagiosPID=`head -n 1 $NagiosRun`        if test -x $NagiosCGI/daemonchk.cgi; then                if $NagiosCGI/daemonchk.cgi -l $NagiosRun; 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 $NagiosRun; then                echo "No lock file found in $NagiosRun"                return 1        fi        NagiosPID=`head -n 1 $NagiosRun`        kill $2 $NagiosPID}# Source function library# Solaris doesn't have an rc.d directory, so do a test firstif [ -f /etc/rc.d/init.d/functions ]; then        . /etc/rc.d/init.d/functionselif [ -f /etc/init.d/functions ]; then        . /etc/init.d/functionsfiprefix=/usr/local/nagiosexec_prefix=${prefix}NagiosBin=${exec_prefix}/bin/nagiosNagiosCfg=${prefix}/etc/nagios.cfgNagiosLog=${prefix}/var/status.logNagiosTmp=${prefix}/var/nagios.tmpNagiosSav=${prefix}/var/status.savNagiosCmd=${prefix}/var/rw/nagios.cmdNagiosVar=${prefix}/varNagiosRun=${prefix}/var/nagios.lockNagiosLckDir=/var/lock/subsysNagiosLckFile=nagiosNagiosCGI=${exec_prefix}/sbinNagios=nagios# Check that nagios exists.test -f $NagiosBin || exit 0# Check that nagios.cfg exists.test -f $NagiosCfg || exit 0# See how we were called.case "$1" in        start)                echo "Starting network monitor: nagios"                su -l $Nagios -c "touch $NagiosVar/nagios.log $NagiosSav"                rm -f $NagiosCmd                $NagiosBin -d $NagiosCfg                if [ -d $NagiosLckDir ]; then touch $NagiosLckDir/$NagiosLckFile; fi                sleep 1                status_nagios nagios                ;;        stop)                echo "Stopping network monitor: nagios"                killproc_nagios nagios                rm -f $NagiosLog $NagiosTmp $NagiosRun $NagiosLckDir/$NagiosLckFile $NagiosCmd                ;;        status)                status_nagios nagios                ;;        check)                $NagiosBin -v $NagiosCfg                ;;        *)                echo "Usage: nagios {start|stop|check|status}"                exit 1                ;;esac# End of this script