Author: havner                       Date: Mon Aug  8 12:42:16 2005 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- for nscap 2.4

---- Files affected:
SOURCES:
   nagios-nsca.init (NONE -> 1.1)  (NEW), nagios-nsca.submit (NONE -> 1.1)  
(NEW)

---- Diffs:

================================================================
Index: SOURCES/nagios-nsca.init
diff -u /dev/null SOURCES/nagios-nsca.init:1.1
--- /dev/null   Mon Aug  8 14:42:16 2005
+++ SOURCES/nagios-nsca.init    Mon Aug  8 14:42:11 2005
@@ -0,0 +1,70 @@
+#!/bin/sh
+#
+# nagios-nsca  This shell script takes care of starting and stopping
+#              nsca.
+#
+# chkconfig:   345 85 23
+#
+# description: nsca is a daemon which listens for reports from remote machines
+# processname: nsca
+# config:      /etc/nagios/nsca.cfg
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Source networking configuration.
+. /etc/sysconfig/network
+
+# Get service config
+[ -f /etc/sysconfig/nagios-nsca ] && . /etc/sysconfig/nagios-nsca
+
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+       if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; 
then
+               # nls "ERROR: Networking is down. %s can't be run." <service>
+               msg_network_down "nagios NSCA daemon"
+               exit 1
+       fi
+else
+       exit 0
+fi
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       # Check if the service is already running?
+       if [ ! -f /var/lock/subsys/nagios-nsca ]; then
+               msg_starting "nagios NSCA daemon"
+               su - nagios -s /bin/sh -c '/usr/bin/setsid /usr/lib/nagios/nsca 
-d /etc/nagios/nsca.cfg </dev/null >/dev/null 2>&1'
+               [ $? -ne 0 ] && RETVAL=1
+               [ $RETVAL -eq 0 ] && touch /var/lock/subsys/nagios-nsca
+               [ $RETVAL -eq 0 ] && ok || fail
+       else
+               msg_already_running "nagios NSCA daemon"
+       fi
+       ;;
+  stop)
+       if [ -f /var/lock/subsys/nagios-nsca ]; then
+               msg_stopping "nagios NSCA daemon"
+               killproc nsca
+               rm -f /var/lock/subsys/nagios-nsca
+       else
+               msg_not_running "nagios NSCA daemon"
+       fi
+       ;;
+  restart|force-reload)
+       $0 stop
+       $0 start
+       exit $?
+       ;;
+  status)
+       status nsca
+       exit $?
+       ;;
+  *)
+       msg_usage "$0 {start|stop|restart|force-reload|status}"
+       exit 3
+esac
+
+exit $RETVAL

================================================================
Index: SOURCES/nagios-nsca.submit
diff -u /dev/null SOURCES/nagios-nsca.submit:1.1
--- /dev/null   Mon Aug  8 14:42:16 2005
+++ SOURCES/nagios-nsca.submit  Mon Aug  8 14:42:11 2005
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+# Arguments:
+#  $1 = host_name (Short name of host that the service is
+#       associated with)
+#  $2 = svc_description (Description of the service)
+#  $3 = state_string (A string representing the status of
+#       the given service - "OK", "WARNING", "CRITICAL"
+#       or "UNKNOWN")
+#  $4 = plugin_output (A text string that should be used
+#       as the plugin output for the service checks)
+#
+
+# Convert the state string to the corresponding return code
+return_code=-1
+
+case "$3" in
+       OK)
+               return_code=0
+               ;;
+       WARNING)
+               return_code=1
+               ;;
+       CRITICAL)
+               return_code=2
+               ;;
+       UNKNOWN)
+               return_code=-1
+               ;;
+esac
+
+# pipe the service check info into the send_nsca program, which
+# in turn transmits the data to the nsca daemon on the central
+# monitoring server
+
+central=`cat /etc/send_nsca-central | grep -v '^#'`
+
+echo -e "$1\t$2\t$return_code\t$4\n" | /usr/sbin/send_nsca $central -c 
/etc/send_nsca.cfg
================================================================
_______________________________________________
pld-cvs-commit mailing list
pld-cvs-commit@lists.pld-linux.org
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to