Add route limit monitoring

This commit is contained in:
Alarig Le Lay 2018-08-29 15:48:08 +02:00
parent 399ab2f3b8
commit a7ff6c1529

View file

@ -94,15 +94,37 @@ if [ -z ${SESSION} ]; then
exit 2 exit 2
fi 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 # 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 # Plugin return codes: https://nagios-plugins.org/doc/guidelines.html#AEN78
case ${STATE} in case ${STATE} in
Established) Established)
printf "OK: ${SESSION} is ${STATE}\n" if [ ${RATIO_IN} -lt 90 ]; then
exit 0 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) OpenSent | OpenConfirm)
printf "WARNING: ${SESSION} is in ${STATE} state\n" printf "WARNING: ${SESSION} is in ${STATE} state\n"