zabbix-monitoring/gateway_scripts/batman-maximum-gateway-metric.sh
2014-12-01 20:46:39 +01:00

22 lines
372 B
Bash
Executable file

#!/bin/bash
GATEWAYS=$(/usr/sbin/batctl gwl | awk -F' ' 'NR <= 1 {next} {print $1}')
METRIC=0
for i in $GATEWAYS
do
TRACEROUTE=$(/usr/sbin/batctl traceroute "$i" | awk 'NR>1')
if [[ "$TRACEROUTE" =~ "Unreachable" ]]; then
echo 99
exit
fi
THISMETRIC=$(wc -l <<< $TRACEROUTE)
if [ "$THISMETRIC" -gt "$METRIC" ]; then
METRIC=$THISMETRIC
fi
done
echo $METRIC