Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/ksh
- #
- PROGNAME=`basename $0`
- PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
- REVISION=`echo '$Revision: 1.00 $' | sed -e 's/[^0-9.]//g'`
- . $PROGPATH/utils.sh
- print_usage() {
- echo "Usage: check_ospf <count of ospf neighbors>"
- echo "e.g. check_ospf 21"
- }
- # Make sure the correct number of command line
- # arguments have been supplied
- if [ $# -lt 1 ]; then
- print_usage
- exit $STATE_UNKNOWN
- fi
- TOTAL=`sudo /usr/local/sbin/show_neighbors | tail -n +4 | wc -l`
- INIT=`sudo /usr/local/sbin/show_neighbors | tail -n +4 | awk '{print $3}' | grep -c init`
- DIFF=`cat /etc/ospf-neigh/$(ls --sort=time /etc/ospf-neigh|grep ^diff-|head -n1)|grep -E '<|>'|awk '{print $1 $2 ":" $4}' | tr '<>' '-+'Â | xargs`
- if [ $INIT -gt 0 ] ; then
- echo "OSPF neighbors CRITICAL: ${INIT} of ${TOTAL} with state init: $DIFF"
- exit $STATE_CRITICAL
- elif [ $TOTAL -gt $1 ] ; then
- echo "OSPF neighbors CRITICAL: ${TOTAL} routers of $1: $DIFF"
- exit $STATE_CRITICAL
- elif [ $TOTAL -lt $1 ] ; then
- echo "OSPF neighbors WARNING: ${TOTAL} routers of $1: $DIFF"
- exit $STATE_WARNING
- else
- echo "OSPF neighbors OK: ${TOTAL}/$1 routers, ${INIT} with state init"
- exit $STATE_OK
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement