faster snmpbulkget for topology
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 10 Jul 2018 16:47:19 +0000 (18:47 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 10 Jul 2018 16:47:19 +0000 (18:47 +0200)
sw-topology-snmpbulkget.sh [new file with mode: 0755]

diff --git a/sw-topology-snmpbulkget.sh b/sw-topology-snmpbulkget.sh
new file mode 100755 (executable)
index 0000000..490fb7a
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh -e
+
+# Usage: $0 [sw [oid]]
+
+dir=/dev/shm/snmp-topology/
+test ! -d $dir && mkdir $dir
+
+. ./snmp.conf
+
+ext=""
+if [ ! -z "$2" ] ; then
+       ext=".$2/"
+       test ! -d "$dir/$ext" && mkdir "$dir/$ext"
+fi
+
+( test ! -z "$1" && echo $1 || ./sw-names ) | xargs -i echo \
+"test ! -e $dir/{} && " \
+"snmpbulkwalk -OX -v2c -Cc -c $COMMUNITY {} IF-MIB::ifPhysAddress        | tee -a $dir/{}     && "\
+"snmpbulkwalk -OX -v2c -Cc -c $COMMUNITY {} Q-BRIDGE-MIB::dot1qTpFdbPort | tee -a $dir/$ext{} || "\
+"snmpbulkwalk -OX -v2c -Cc -c $COMMUNITY {} BRIDGE-MIB::dot1dTpFdbPort   | tee -a $dir/{} " | sh -x
+
+