blob: 681d57bc968b59a0da6dfb100f7b45050270c6fb [file] [log] [blame]
David K. Bainbridgef3071012016-08-04 09:29:55 -07001#!/bin/bash
2
David K. Bainbridge9d5bd802016-08-15 12:49:02 -07003NODES="10.X.1.1 10.X.1.2 10.X.2.1 10.X.2.2 10.X.1.254 10.X.2.254 8.8.8.8"
David K. Bainbridgef3071012016-08-04 09:29:55 -07004
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
David K. Bainbridge9d5bd802016-08-15 12:49:02 -070024if [ "$FROM" != "none" ]; then
25 X=$(echo "$FROM" | cut -d. -f2)
26else
27 X='6'
28fi
29
30LIST=$(echo $LIST | sed -e "s/X/$X/g")
31
David K. Bainbridgef3071012016-08-04 09:29:55 -070032echo "from $(hostname) ($FROM):"
33for ip in $LIST; do
34 case $ip in
35 -*)
36 if [ "$ip" == "-" ]; then
37 IFACE=
38 ILABEL="none"
39 else
40 ILABEL="$(echo $ip | sed -e 's/^-//g')"
41 IFACE="-I $ILABEL"
42 fi
43 ;;
44 *)
45 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/')
46 ;;
47 esac
48done