renamed to show it is a shell script
authorHeiko Schlittermann (JUMPER) <hs@schlittermann.de>
Wed, 02 Nov 2011 15:03:39 +0100
changeset 1 b8c814c738cf
parent 0 d3e953788d3f
child 2 e81beebd168f
renamed to show it is a shell script
submit-via-nsca
submit-via-nsca.sh
--- a/submit-via-nsca	Wed Nov 02 15:03:16 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-#! /bin/bash
-# © 2011 Heiko Schlittermann <hs@schlittermann.de>
-# source: https://ssl.schlittermann.de/hg/check-by-nsca
-
-set -e
-
-unset ${!LC_*} LANG
-export LC_ALL=C
-ME=$(basename $0)
-
-function send()       { send_nsca "$@"; }
-function debug_send() { echo "CMDLINE: $@"; cat; }
-send=send             # changed by option
-
-
-# read defaults, if exist
-test -f /etc/defaults/$ME \
-    && source /etc/defaults/$ME
-
-hostname=$(hostname -f)
-svcname=
-nsca_host=
-nsca_port=
-
-tmp=$(getopt -n $0 -o H:S:p:d \
-    -l help,hostname:,servicename:,nsca-host:,nsca-port:,debug \
-    -- "$@") || exit 2
-eval set -- "$tmp"
-
-while true; do
-    opt="$1"; shift
-    case "$opt" in
-        -H|--hostname)  hostname="$1"; shift;;
-        -S|--svcname)   svcname="$1"; shift;;
-           --nsca-host) nsca_host="$1"; shift;;
-        -p|--nsca-port) nsca_port="$1"; shift;;
-        -h|--help)      cat <<_USAGE
-Usage: $ME [options] -- {test} [test-options]
-       -H|--hostname    Hostname to be sent along the result ($hostname).
-       -S|--servicename Servicename to be sent along the result.
-                        Use "-" to mark a host check.
-                        Use "" (the default) to have the servicename
-                        guessed from the test output.
-       --nsca-host      Destination host ($nsca_host)
-       --nsca-port      Destination port ($nsca_port)
-_USAGE
-                        exit 0;;
-       -d|--debug)      send="debug_$send";;
-        --)     break;;
-    esac
-
-done
-
-set +e
-
-output=$("$@")
-rc=$?
-
-test "$svcname" || svcname="${output%% *}"
-
-tab=$'\x09'
-echo "$hostname$tab$svcname$tab$rc$tab$output" \
-        | $send -H "$nsca_host" ${nsca_port:+-p $nsca_port}
-
-# vim:sts=4 sw=4 aw ai sm et:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/submit-via-nsca.sh	Wed Nov 02 15:03:39 2011 +0100
@@ -0,0 +1,65 @@
+#! /bin/bash
+# © 2011 Heiko Schlittermann <hs@schlittermann.de>
+# source: https://ssl.schlittermann.de/hg/check-by-nsca
+
+set -e
+
+unset ${!LC_*} LANG
+export LC_ALL=C
+ME=$(basename $0)
+
+function send()       { send_nsca "$@"; }
+function debug_send() { echo "CMDLINE: $@"; cat; }
+send=send             # changed by option
+
+
+# read defaults, if exist
+test -f /etc/defaults/$ME \
+    && source /etc/defaults/$ME
+
+hostname=$(hostname -f)
+svcname=
+nsca_host=
+nsca_port=
+
+tmp=$(getopt -n $0 -o H:S:p:d \
+    -l help,hostname:,servicename:,nsca-host:,nsca-port:,debug \
+    -- "$@") || exit 2
+eval set -- "$tmp"
+
+while true; do
+    opt="$1"; shift
+    case "$opt" in
+        -H|--hostname)  hostname="$1"; shift;;
+        -S|--svcname)   svcname="$1"; shift;;
+           --nsca-host) nsca_host="$1"; shift;;
+        -p|--nsca-port) nsca_port="$1"; shift;;
+        -h|--help)      cat <<_USAGE
+Usage: $ME [options] -- {test} [test-options]
+       -H|--hostname    Hostname to be sent along the result ($hostname).
+       -S|--servicename Servicename to be sent along the result.
+                        Use "-" to mark a host check.
+                        Use "" (the default) to have the servicename
+                        guessed from the test output.
+       --nsca-host      Destination host ($nsca_host)
+       --nsca-port      Destination port ($nsca_port)
+_USAGE
+                        exit 0;;
+       -d|--debug)      send="debug_$send";;
+        --)     break;;
+    esac
+
+done
+
+set +e
+
+output=$("$@")
+rc=$?
+
+test "$svcname" || svcname="${output%% *}"
+
+tab=$'\x09'
+echo "$hostname$tab$svcname$tab$rc$tab$output" \
+        | $send -H "$nsca_host" ${nsca_port:+-p $nsca_port}
+
+# vim:sts=4 sw=4 aw ai sm et: