blob: d6de75c9631604e385e8395a26a98c91cac22586 [file] [log] [blame]
David K. Bainbridgef3071012016-08-04 09:29:55 -07001#!/bin/bash
2
3NODES="10.2.1.1 10.2.1.2 10.2.2.1 10.2.2.2 10.2.1.254 10.2.2.254"
4
5test -z $1 || NODES="$*"
6
7USE_LIST="br-int fabric"
8for u in $USE_LIST; do
9 ifconfig $u > /dev/null 2>&1
10 if [ $? -eq 0 ]; then
11 USE_IFACE=$u
12 break
13 fi
14done
15
16LIST="-$USE_IFACE $NODES - 8.8.8.8"
17IFACE=
18ILABEL="none"
19FROM="none"
20if [ ! -z $USE_IFACE ]; then
21 FROM=$(ifconfig $USE_IFACE | grep "inet addr" | head -1 | awk '{print $2}' | cut -d: -f2)
22fi
23
24echo "from $(hostname) ($FROM):"
25for ip in $LIST; do
26 case $ip in
27 -*)
28 if [ "$ip" == "-" ]; then
29 IFACE=
30 ILABEL="none"
31 else
32 ILABEL="$(echo $ip | sed -e 's/^-//g')"
33 IFACE="-I $ILABEL"
34 fi
35 ;;
36 *)
37 printf " %-20s%s\n" "$ip ($ILABEL)" $(ping $IFACE -c 1 $ip 2>&1 | grep "^rtt min/avg/max/mdev" | sed -e 's/.*= \([.0-9]*\).*/\1/')
38 ;;
39 esac
40done