David K. Bainbridge | f307101 | 2016-08-04 09:29:55 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | NODES="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 | |
| 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 | |
| 24 | echo "from $(hostname) ($FROM):" |
| 25 | for 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 |
| 40 | done |