3 # modified from https://gist.github.com/krokodilerian/a88b4ae992706c22e0b0
4 # see /var/lib/snmp/mibs/ietf/IF-MIB
7 echo Usage: "$0" hostname
11 log=/dev/shm/port-status/
12 test -d $log || mkdir $log
16 snmp="snmpget -v 2c -c $COMMUNITY -Cf -Ov -OQ $sw"
18 numports=`$snmp IF-MIB::ifNumber.0`
21 for i in `seq 1 $numports`; do
22 name=`$snmp IF-MIB::ifName.$i`
23 alias=`$snmp IF-MIB::ifAlias.$i`
24 if [ "$name" = "No Such Instance currently exists at this OID" ]; then
28 iftype=`$snmp IF-MIB::ifType.$i`
30 # if [ "$iftype" = "other" ] || [ "$iftype" = propVirtual ] || [ "$iftype" = softwareLoopback ]; then
34 status=`$snmp IF-MIB::ifOperStatus.$i`
35 if [ "$status" = "notPresent" ] ; then
39 #descr=`$snmp IF-MIB::ifDescr.$i`
40 speed=`$snmp IF-MIB::ifSpeed.$i | sed 's/000000//'`
42 # echo "## $sw [$name] $iftype $status $descr $speed"
43 echo "$sw $i $name $speed $status [$alias]" | tee -a $log/$sw