Add route limit monitoring

This commit is contained in:
Alarig Le Lay 2018-08-29 15:48:08 +02:00
parent 399ab2f3b8
commit a7ff6c1529
1 changed files with 25 additions and 3 deletions

View File

@ -94,15 +94,37 @@ if [ -z ${SESSION} ]; then
exit 2
fi
STATE="$($birdc show protocol ${SESSION} | awk -v session=${SESSION} '$0 ~ session { print $6 }')"
STATE="$($birdc show protocol ${SESSION} | \
awk -v session=${SESSION} '$0 ~ session { print $6 }')"
ROUTE_LIMIT_IN="$($birdc show protocol all ${SESSION} | \
awk '/Receive limit/ { print $3 }')"
ROUTES_IMPORTED="$($birdc show protocol all ${SESSION} | grep 'Routes:' | \
sed -Ee '/imported/{ s/^.* ([0-9]+) imported.*$/\1/; p;}' -e d)"
ROUTE_HIT_IN="$($birdc show protocol all ${SESSION} | \
grep -E 'Receive limit:.*HIT')"
RATIO_IN=$(echo "(${ROUTES_IMPORTED}*100)/${ROUTE_LIMIT_IN}" | bc)
ROUTE_HIT_OUT="$($birdc show protocol all ${SESSION} | \
grep -E 'Export limit:.*HIT')"
# Session states: https://gitlab.labs.nic.cz/labs/bird/blob/master/proto/bgp/bgp.c#L1465
# Plugin return codes: https://nagios-plugins.org/doc/guidelines.html#AEN78
case ${STATE} in
Established)
printf "OK: ${SESSION} is ${STATE}\n"
exit 0
if [ ${RATIO_IN} -lt 90 ]; then
printf "OK: ${SESSION} is ${STATE}\n"
exit 0
elif [ "${ROUTE_HIT_IN}" != "" ]; then
printf "CRITICAL: ${SESSION} has hit import route "
printf "limit\n"
exit 2
else
printf "WARNING: ${SESSION} import route limit is "
printf "over thresold\n"
exit 1
fi
;;
OpenSent | OpenConfirm)
printf "WARNING: ${SESSION} is in ${STATE} state\n"