#!/bin/bash

FILE='/var/www/html/monitor/db/'$1'.db'
#SNMP='/var/www/html/monitor/db/'$1'.snmp'
#if [ ! -f $FILE ]; then touch $FILE; fi
echo -n > $FILE


snmpwalk -Osfn -c rautusnmp -v2c $1 .1.3.6.1.2.1.17.7.1.2.2.1.2 | while read str
do
	mac_tst=`echo $str | awk -F '.' '{print $16,$17,$18,$19,$20,$21}' | awk -F '=' '{print $1}'`
	mac=`printf '%.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n' $mac_tst`
#	echo 'mac='$mac
	vlan=`echo $str | awk -F '.' '{print $15}'`
	port=`echo $str | awk '{print $4}'`
#	echo 'mac='$mac' port='$port' vlan='$vlan
	echo $vlan' '$port' '$mac >> $FILE
done

exit 0
vl po mac
# awk -F '.' '{print $16,$17,$18,$19,$20,$21}' | awk -F '=' '{print $1}' | while read mac; do printf '%.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n' $mac; done





expect -f /var/www/html/monitor/dgs1100.exp $1 'sh fdb' | grep Dynamic | grep -v Quit | tr '[\-]' '[\:]' | tr '[:upper:]' '[:lower:]' |  awk '{print $1,$4,$3}' | while read A 
do
echo $A >> $FILE
#echo $A
done
#cat $A | while read $test; do
#echo $test
#done

