SOURCES: nagios-nsca.submit - allow also for host submits (3 param...
havner
havner at pld-linux.org
Tue Aug 9 15:36:47 CEST 2005
Author: havner Date: Tue Aug 9 13:36:47 2005 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- allow also for host submits (3 parameters instead of 4)
- more talkative
- more errors checks
- host type return codes (DOWN, UNREACHABLE)
---- Files affected:
SOURCES:
nagios-nsca.submit (1.2 -> 1.3)
---- Diffs:
================================================================
Index: SOURCES/nagios-nsca.submit
diff -u SOURCES/nagios-nsca.submit:1.2 SOURCES/nagios-nsca.submit:1.3
--- SOURCES/nagios-nsca.submit:1.2 Tue Aug 9 13:31:39 2005
+++ SOURCES/nagios-nsca.submit Tue Aug 9 15:36:42 2005
@@ -1,6 +1,6 @@
#!/bin/sh
-# Arguments:
+# Arguments for service:
# $1 = host_name (Short name of host that the service is
# associated with)
# $2 = svc_description (Description of the service)
@@ -11,21 +11,54 @@
# as the plugin output for the service checks)
#
+# Arguments for host:
+# $1 = host_name (Short name of host we check for status)
+# $2 = state_string (A string representing the status of
+# the given service - "OK", "DOWN", "UNREACHABLE"
+# or "UNKNOWN")
+# $3 = plugin_output (A text string that should be used
+# as the plugin output for the host checks)
+#
+
+if [ "$#" = 4 ]; then
+ TYPE=SERVICE
+ CODE=$3
+elif [ "$#" = 3 ]; then
+ TYPE=HOST
+ CODE=$2
+else
+ echo "You must specify exactly 3 or 4 arguments"
+ exit 1
+fi
+
+CENTRAL=`cat /etc/send_nsca-central 2>/dev/null | grep -v '^#'`
+
+if [ -z $CENTRAL ]; then
+ echo "You must specify nagios NSCA host in /etc/send_nsca-central"
+ exit 1
+fi
+
# Convert the state string to the corresponding return code
-return_code=3
+RETURN_CODE=3
-case "$3" in
+case "$CODE" in
OK)
- return_code=0
+ RETURN_CODE=0
;;
WARNING)
- return_code=1
+ RETURN_CODE=1
+ ;;
+ DOWN)
+ RETURN_CODE=1
;;
CRITICAL)
- return_code=2
+ RETURN_CODE=2
+ ;;
+ UNREACHABLE)
+ RETURN_CODE=2
;;
UNKNOWN)
- return_code=3
+ RETURN_CODE=3
;;
esac
@@ -33,6 +66,11 @@
# 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
+if [ "$TYPE" = "SERVICE" ]; then
+ echo -e "$1\t$2\t$RETURN_CODE\t$4\n" | /usr/sbin/send_nsca $CENTRAL -c /etc/send_nsca.cfg
+elif [ "$TYPE" = "HOST" ]; then
+ echo -e "$1\t$RETURN_CODE\t$3\n" | /usr/sbin/send_nsca $CENTRAL -c /etc/send_nsca.cfg
+else
+ echo "This cannot happen"
+ exit 1
+fi
================================================================
---- CVS-web:
http://cvs.pld-linux.org/SOURCES/nagios-nsca.submit?r1=1.2&r2=1.3&f=u
More information about the pld-cvs-commit
mailing list