filter log/ filenames into sw.command
[dell-switch] / sw-snmpbulkwalk.sh
index aed79b4..7d27c63 100755 (executable)
@@ -1,4 +1,21 @@
-mkdir /dev/shm/snmpbulkwalk/
+#!/bin/sh -e
 
-./sw-names | xargs -i echo "snmpbulkwalk -OX -v2c -Cc -c $COMMUNITY {} | tee /dev/shm/snmpbulkwalk/{}" | parallel 
+# Usage: $0 [sw [oid]]
+
+dir=/dev/shm/snmpbulkwalk/
+if [ ! -d $dir ] ; then
+       mkdir $dir
+       ln -sv `pwd`/snmpbulkwalk/.git $dir/
+fi
+
+. ./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 sh -c \
+"snmpbulkwalk -OX -v2c -Cc -c $COMMUNITY {} $2 | tee $dir/$ext{} && test -z "$ext" && cd $dir && git add $dir/$ext{} && git commit -m {} $dir/$ext{}" #| parallel