#!/bin/sh # #---------------------------------------------# # check_snmp_eigrp-neighbor.sh - nagios plugin # # Copyright (C) 2010 Rostislav Srb # # 25.07.2010 Version 1.0 # # Last modified by Rostislav Srb 20100725 # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # Usage: # ./check_snmp_eigrp-neighbors.sh [snmp community] [device hostname/IP] [neighbor name or 'list'] # # The list argument is used list all eigrp neighbors. community=$1 host=$2 action=$3 hex2dec () { echo "ibase=16;$@"|bc; } dec2hex () { echo "obase=16;$@"|bc; } hex2decip () { echo `hex2dec $1`.`hex2dec $2`.`hex2dec $3`.`hex2dec $4`; } if [[ $4 -lt '1' ]] ; then count='1' else count=$4 fi if [[ $# -lt '3' ]] ; then echo "Usage:" echo "$0 " echo "" echo "The list argument is used list all eigrp neighbors." exit 3 fi if [ $action == "list" ] ; then snmpbulkwalk -O qv -v 2c -c $community $host .1.3.6.1.4.1.9.9.449.1.4.1.1.3 | tr -d '"'| while read a b c d;do echo `hex2decip $a $b $c $d` done exit 3 fi snmpbulkwalk -O qv -v 2c -c $community $host .1.3.6.1.4.1.9.9.449.1.4.1.1.3 | tr -d '"'| while read a b c d;do echo `hex2decip $a $b $c $d` | fgrep $action &> /dev/null if [[ $? -eq '0' ]] ; then # match was found exit 1 fi done; if [[ $? -eq '1' ]] ; then # match was found echo "OK: neighbor $action is up" exit 0 else # no neighbor matches description given echo "Critical: No link up to $action" exit 2 fi