(2015-03-04)
Example switchwalk script. This script takes the passed MAC address then feeds it to findmac.pl for each switch.
I wrap the "like-typed" switches together in a for-&-wait loop because otherwise you have to sit through each switch sequentially, which can get long.
#!/bin/bashFINDMAC=~dave/projects/findmac.pl/findmac.plif [ -z "$1" ] ; then
echo target?
exit 1
fi
echo Core
$FINDMAC -c mycomm sa4-39 $1 &
$FINDMAC -c mycomm sa4-38 $1 &
wait
echo Edge
for i in sa1-41 sa2-39 sa3-37 sa3-41 sa4-42 sa5-41 sa6-41 sa7-41 sb5-41; do
$FINDMAC -c mycomm $i $1 &
done | sort | uniq
wait
echo Front
for i in sa4-16 sa4-19 sa4-20 ; do
$FINDMAC -c mycomm $i $1 &
done | sort | uniq
wait
Example output:
$ switchwalk 00:1C:23:65:B9:20
Core
sa4-38: port 6(ae5.0)
sa4-39: port 528(ge-0/0/15.0)
Edge
sa1-41: port 560(ge-0/0/47.0)
sa2-39: port 560
sa3-37: port 21(ae20.0)
sa3-41: port 560(ge-0/0/47.0)
sa4-42: port 27(Slot0/27)
sa5-41: port 560(ge-0/0/47.0)
sa6-41: port 560(ge-0/0/47.0)
sa7-41: port 560(ge-0/0/47.0)
sb5-41: port 1(ae0.0)
Front
sa4-16: port 24(g24)
sa4-19: port 23(g23)