X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=find-port-for-hostname;h=6e8485322d64a8c00a6b327dcac7b499427db1be;hb=f9fe79479e3a8845f472e0804c6b467c3431df59;hp=44fa015e3e9e136c3ed309227f4b45cd940eca71;hpb=a2509b10cacc5d6bc708cd04fde6f76e4c49f070;p=dell-switch diff --git a/find-port-for-hostname b/find-port-for-hostname index 44fa015..6e84853 100755 --- a/find-port-for-hostname +++ b/find-port-for-hostname @@ -13,6 +13,12 @@ ping -c 1 $host | grep from > /dev/shm/port.$host.ping ip=`cat /dev/shm/port.$host.ping | cut -d' ' -f5 | tr -d '():'` host=`cat /dev/shm/port.$host.ping | cut -d' ' -f4` mac=`sudo arp -a -n | grep "($ip)" | cut -d' ' -f4 | sort -u` +if [ -z "$mac" ] ; then + bro=`./bro-conn-ip-vlan-mac.sh $ip` + echo "# bro $bro" + mac=`echo $bro | cut -d' ' -f3` + test -z "$mac" && exit 1 +fi grep -r -i $mac /dev/shm/snmp-mac-port/ | tee /dev/shm/port.$host.switch | grep --file /dev/shm/trunk.regex -v | cut -d: -f2- echo "# $host $ip $mac on "`cat /dev/shm/port.$host.switch | cut -d: -f2- | cut -d' ' -f1 | sort -u | wc -l`" switches"