David K. Bainbridge | f307101 | 2016-08-04 09:29:55 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
David K. Bainbridge | 9d5bd80 | 2016-08-15 12:49:02 -0700 | [diff] [blame] | 3 | NODES="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. Bainbridge | f307101 | 2016-08-04 09:29:55 -0700 | [diff] [blame] | 4 | |
| 5 | test -z $1 || NODES="$*" |
| 6 | |
| 7 | USE_LIST="br-int fabric" |
| 8 | for 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 |
| 14 | done |
| 15 | |
| 16 | LIST="-$USE_IFACE $NODES - 8.8.8.8" |
| 17 | IFACE= |
| 18 | ILABEL="none" |
| 19 | FROM="none" |
| 20 | if [ ! -z $USE_IFACE ]; then |
| 21 | FROM=$(ifconfig $USE_IFACE | grep "inet addr" | head -1 | awk '{print $2}' | cut -d: -f2) |
| 22 | fi |
| 23 | |
David K. Bainbridge | 9d5bd80 | 2016-08-15 12:49:02 -0700 | [diff] [blame] | 24 | if [ "$FROM" != "none" ]; then |
| 25 | X=$(echo "$FROM" | cut -d. -f2) |
| 26 | else |
| 27 | X='6' |
| 28 | fi |
| 29 | |
| 30 | LIST=$(echo $LIST | sed -e "s/X/$X/g") |
| 31 | |
David K. Bainbridge | f307101 | 2016-08-04 09:29:55 -0700 | [diff] [blame] | 32 | echo "from $(hostname) ($FROM):" |
| 33 | for 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 |
| 48 | done |