Adding case where there is no import route limit

This commit is contained in:
Alarig Le Lay 2018-10-09 17:46:38 +02:00
parent 68e01fdb74
commit 36ac6fa3d2
2 changed files with 20 additions and 2 deletions

View file

@ -1,3 +1,6 @@
# nrpe-bird # nrpe-bird
Collection of scripts used to monitor bird sessions and route limits Collection of scripts used to monitor bird sessions and route limits
Its not well tested against bird2 yet, but using -4 for either IPv4 and IPv6
should be sufficient.

View file

@ -99,11 +99,26 @@ STATE="$($birdc show protocol ${SESSION} | \
ROUTE_LIMIT_IN="$($birdc show protocol all ${SESSION} | \ ROUTE_LIMIT_IN="$($birdc show protocol all ${SESSION} | \
awk '/Receive limit/ { print $3 }')" awk '/Receive limit/ { print $3 }')"
# Test if we are on a bird2
if [ -z ${ROUTE_LIMIT_IN} ]; then
ROUTE_LIMIT_IN="$($birdc show protocol all ${SESSION} | \
awk '/Import limit/ { print $3 }')"
fi
# There is no import limit, so no ratio either
if [ -z ${ROUTE_LIMIT_IN} ]; then
RATIO_IN=0
fi
ROUTES_IMPORTED="$($birdc show protocol all ${SESSION} | grep 'Routes:' | \ ROUTES_IMPORTED="$($birdc show protocol all ${SESSION} | grep 'Routes:' | \
sed -Ee '/imported/{ s/^.* ([0-9]+) imported.*$/\1/; p;}' -e d)" sed -Ee '/imported/{ s/^.* ([0-9]+) imported.*$/\1/; p;}' -e d)"
ROUTE_HIT_IN="$($birdc show protocol all ${SESSION} | \ ROUTE_HIT_IN="$($birdc show protocol all ${SESSION} | \
grep -E 'Receive limit:.*HIT')" grep -E 'Receive limit:.*HIT')"
if [ ! -z ${ROUTE_LIMIT_IN} ]; then
RATIO_IN=$(echo "(${ROUTES_IMPORTED}*100)/${ROUTE_LIMIT_IN}" | bc) RATIO_IN=$(echo "(${ROUTES_IMPORTED}*100)/${ROUTE_LIMIT_IN}" | bc)
fi
ROUTE_HIT_OUT="$($birdc show protocol all ${SESSION} | \ ROUTE_HIT_OUT="$($birdc show protocol all ${SESSION} | \
grep -E 'Export limit:.*HIT')" grep -E 'Export limit:.*HIT')"