summaryrefslogtreecommitdiff
path: root/mrpe
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2018-09-26 20:20:11 (GMT)
committerChristian Pointner <equinox@helsinki.at>2018-09-26 20:20:11 (GMT)
commit678e3b57d4bd482c8ae0ef50801aea77b8491780 (patch)
tree54ffc840bfd1bc6afe5d0e4588ebd3ca3f41c46a /mrpe
parentcb207bddd741f9e382f5b9027d690463ceaf34f7 (diff)
more generic check for olsr
Diffstat (limited to 'mrpe')
-rwxr-xr-xmrpe/check_olsr-neigh.sh44
-rwxr-xr-xmrpe/check_olsr.sh43
2 files changed, 43 insertions, 44 deletions
diff --git a/mrpe/check_olsr-neigh.sh b/mrpe/check_olsr-neigh.sh
deleted file mode 100755
index 0365eac..0000000
--- a/mrpe/check_olsr-neigh.sh
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/bin/bash
-
-readonly NAGIOS_OK=0
-readonly NAGIOS_WARNING=1
-readonly NAGIOS_CRITICAL=2
-readonly NAGIOS_UNKNOWN=3
-
-function main {
- local warn_level="$1"
- local crit_level="$2"
-
- curlout=$(curl --connect-timeout 5 --max-time 10 -s http://localhost:2006/neigh)
- if [ $? -ne 0 ]; then
- echo "UNKNOWN - failed to fetch olsr neighbours"
- return "$NAGIOS_UNKNOWN"
- fi
-
- local neighs=$(echo "$curlout" | awk '($0 != "" && NR > 2) { print($1) }')
- local neighs_len=$(echo -n "$neighs" | wc -l)
-
- local code="$NAGIOS_OK"
- local state="OK"
- local tag=""
-
- if [ $neighs_len -le $crit_level ]; then
- code="$NAGIOS_CRITICAL"
- state="CRIT"
- tag="(!!)"
- elif [ $neighs_len -le $warn_level ]; then
- code="$NAGIOS_WARNING"
- state="WARN"
- tag="(!)"
- fi
-
- echo "$state - $neighs_len$tag olsr neighbours found."
- exit "$code"
-}
-
-if [ -z "$1" ] || [ -z "$2" ]; then
- echo "UNKNOWN - please specify warn and critical values for neighbour counts"
- exit "$NAGIOS_UNKNOWN"
-fi
-
-main "$1" "$2"
diff --git a/mrpe/check_olsr.sh b/mrpe/check_olsr.sh
new file mode 100755
index 0000000..307ae17
--- /dev/null
+++ b/mrpe/check_olsr.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+readonly NAGIOS_OK=0
+readonly NAGIOS_WARNING=1
+readonly NAGIOS_CRITICAL=2
+readonly NAGIOS_UNKNOWN=3
+
+function main {
+ local res_name="$1"
+ local warn_level="$2"
+ local crit_level="$3"
+
+ curlout=$(curl --connect-timeout 5 --max-time 10 -s "http://localhost:2006/$res_name")
+ if [ $? -ne 0 ]; then
+ echo "UNKNOWN - failed to fetch resource '$res_name' from olsr txtinfo plugin"
+ return "$NAGIOS_UNKNOWN"
+ fi
+ local num_res=$(echo "$curlout" | awk '($0 != "" && NR > 2) { print($1) }' | wc -l)
+
+ local code="$NAGIOS_OK"
+ local state="OK"
+ local tag=""
+
+ if [ $num_res -le $crit_level ]; then
+ code="$NAGIOS_CRITICAL"
+ state="CRIT"
+ tag="(!!)"
+ elif [ $num_res -le $warn_level ]; then
+ code="$NAGIOS_WARNING"
+ state="WARN"
+ tag="(!)"
+ fi
+
+ echo "$state - $num_res$tag olsr $res_name found."
+ exit "$code"
+}
+
+if [ -z "$1" ] || [ -z "$2" ]; then
+ echo "UNKNOWN - please specify resource name, warn and critical values"
+ exit "$NAGIOS_UNKNOWN"
+fi
+
+main "$1" "$2" "$3"