#!/bin/sh # # Check ifoperstatus() without calling the perl routine, this script uses # snmpwalk to get the info. # # $1: Community string ; $2 Target address ; $3 Target interface # # by nAAs LIBEXEC="/usr/local/libexec/nagios/" .$LIBEXEC/utils.sh comm=$(snmpwalk -v1 -c $1 $2 ifOperStatus.$3 | awk -F: '{print $4}' | awk -F\( '{print $2}' | awk -F\) '{print $1}') if [ $comm -eq 1 ]; then echo "OK - Interface $3 is up." exit $STATE_OK elif [ $comm -eq 0 ]; then echo "CRITICAL - Interface $3 is down" exit $STATE_CRITICAL else echo "WARNING - No info is being retrieved" exit $STATE_WARNING fi