From b2ba04a2710be13072ed1c229cdc4151fcfdead0 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Mon, 9 Apr 2018 08:57:24 +0200 Subject: [PATCH] added configurable community and create files in /dev/shm --- README | 4 ++++ snmp-get-arp | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README b/README index a133620..90d58c3 100644 --- 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 diff --git a/snmp-get-arp b/snmp-get-arp index 0913603..f546d9f 100755 --- a/snmp-get-arp +++ b/snmp-get-arp @@ -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 -- 2.20.1