diff options
author | Christian Pointner <equinox@helsinki.at> | 2018-09-26 16:08:51 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2018-09-26 16:08:51 (GMT) |
commit | cb207bddd741f9e382f5b9027d690463ceaf34f7 (patch) | |
tree | 46fae0aa6ab1fee1523bc2a006cbb14ba8217a5b /mrpe | |
parent | 5f09079498b1ff43027aa5f6b8b69bc518b5ee40 (diff) |
added check for olsr neighbours
Diffstat (limited to 'mrpe')
-rwxr-xr-x | mrpe/check_olsr-neigh.sh | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/mrpe/check_olsr-neigh.sh b/mrpe/check_olsr-neigh.sh new file mode 100755 index 0000000..0365eac --- /dev/null +++ b/mrpe/check_olsr-neigh.sh @@ -0,0 +1,44 @@ +#!/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" |