rename upgrade file to include switch model N1148T-ON
[dell-switch] / find-port-for-mac
1 #!/bin/sh -e
2
3 # update with:
4 # fping -l $( ./sw-names ; ./wap-names )
5 # ./snmp-mac-port
6 # ./sw-port-status.sh
7
8 # example usage:
9 # ./find-port-for-mac $( ./mac4ip.sh wap-f300 )
10
11 test -z "$1" && echo "Usage: $0 d4:ca:6d:01:4c:f2" && exit 1
12
13 mac=$1
14
15 . ./shm-trunk.regex
16
17 grep -r -i $mac /dev/shm/snmp-mac-port/ | tee /dev/shm/mac.$mac | grep --file /dev/shm/trunk.regex -v | cut -d: -f2- | while read name vlan mac port ; do
18         # sw-rack2 - 2c:ea:7f:6f:0c:ec 27
19         echo -n "$name $vlan $mac $port "
20         grep " $port " /dev/shm/port-status/$name | cut -d' ' -f3- # add port status and description
21 done
22 echo "# mac $mac on "`cat /dev/shm/mac.$mac | cut -d: -f2- | cut -d' ' -f1 | sort -u | wc -l`" switches"