X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=snmp-port-status.sh;h=453b071eb5e08af20210f9a9341ce080f4fc1882;hb=a3e9e6f65fd50e3c6cbafef639c41ded109afb70;hp=158917b8c7599c704344af5bcc59b3a2e411e484;hpb=cf2a51aa94bf9ecba2fdba6e30dfbc74ef6f0bad;p=dell-switch diff --git a/snmp-port-status.sh b/snmp-port-status.sh index 158917b..453b071 100755 --- a/snmp-port-status.sh +++ b/snmp-port-status.sh @@ -4,7 +4,7 @@ # see /var/lib/snmp/mibs/ietf/IF-MIB if [ -z "$1" ]; then - echo Usage: "$0" hostname + echo Usage: "$0" hostname ifInErrors ifOutErrors ifInDiscards exit 4 fi @@ -12,6 +12,7 @@ log=/dev/shm/port-status/ test -d $log || mkdir $log sw="$1" +shift # rest of arguments are IfEntry SEQUENCE . ./snmp.conf snmp="snmpget -v 2c -c $COMMUNITY -Cf -Ov -OQ $sw" @@ -19,7 +20,8 @@ numports=`$snmp IF-MIB::ifNumber.0` :> $log/$sw for i in `seq 1 $numports`; do - name=`$snmp IF-MIB::ifAlias.$i` + name=`$snmp IF-MIB::ifName.$i` + alias=`$snmp IF-MIB::ifAlias.$i` if [ "$name" = "No Such Instance currently exists at this OID" ]; then continue fi @@ -36,9 +38,15 @@ for i in `seq 1 $numports`; do fi #descr=`$snmp IF-MIB::ifDescr.$i` - speed=`$snmp IF-MIB::ifSpeed.$i | sed 's/000000//'` + #speed=`$snmp IF-MIB::ifSpeed.$i | sed 's/000000//'` + speed=`$snmp IF-MIB::ifHighSpeed.$i` + + extra="" + for add in "$@"; do + extra="$extra "`$snmp IF-MIB::$add.$i` + done # echo "## $sw [$name] $iftype $status $descr $speed" - echo "$sw $i $speed $status [$name]" | tee -a $log/$sw + echo "$sw $i $name $speed $status $iftype$extra [$alias]" | tee -a $log/$sw done