added configurable community and create files in /dev/shm
authorDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 9 Apr 2018 06:57:24 +0000 (08:57 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Mon, 9 Apr 2018 06:57:24 +0000 (08:57 +0200)
README
snmp-get-arp

diff --git a/README b/README
index a133620..90d58c3 100644 (file)
--- a/README
+++ b/README
@@ -23,3 +23,7 @@ Backup switch configuration to tftp server:
 
 ./ips 1,2 | awk '{ print "./dell-switch.pl "$1" \"copy startup-config tftp://10.20.0.253/backups/"$2".config\"" }' | NO_LOG=1 sh -x
 
+
+To use snmp* utils, create snmp.conf with:
+
+COMMUNITY=my-comminity-or-public
index 0913603..f546d9f 100755 (executable)
@@ -1,5 +1,12 @@
-#!/bin/bash
-cat dell | while read line
+#!/bin/bash -e
+
+. snmp.conf # get COMMUNITY
+
+log=/dev/shm/sw.mac.port
+test -d $log && mv $log $log.last
+mkdir $log
+
+./ips | while read ip
 do
-       snmpwalk -v 2c -c XXXXXXXXXXXXXXXXXXX $line 1.3.6.1.2.1.17.4.3.1.2 | sed 's/iso.3.6.1.2.1.17.4.3.1.2./ /g' | awk '{print $1" .g"$4}' | awk -v sw="$line" -F '.' '{ printf "%02X:%02X:%02X:%02X:%02X:%02X,%s,%s\n", $1, $2, $3, $4, $5, $6, $7, sw }'
+       snmpwalk -v 2c -c $COMMUNITY $ip 1.3.6.1.2.1.17.4.3.1.2 2>>/dev/shm/sw.errors | sed 's/iso.3.6.1.2.1.17.4.3.1.2./ /g' | awk '{print $1" .g"$4}' | awk -v sw="$ip" -F '.' '{ printf "%02X:%02X:%02X:%02X:%02X:%02X,%s,%s\n", $1, $2, $3, $4, $5, $6, $7, sw }' | tee $log/$ip
 done