Table of Contents

Linux Operation with Fabric (ope.py)

check_ping_gw.sh

$FHHOME/target/scripts/check_ping_gw.sh


check_ping_gw.sh

#!/bin/bash
#==============================================================================
# check_ping_gw.sh
#
# How to use
#     chek_ping_gw.sh
#==============================================================================

LANG=C

TMPFILE=/tmp/tmp.$$
ERROR=0

for i  in `route -n | awk {'print $2'} | grep -Evi "IP|Gateway|0.0.0.0"`
do
    ping -i 0.25 -c 3 -w 2 $i > ${TMPFILE}
    if [ $?  -ne 0 ] ; then
        ERROR=1
    fi
    tail -n 3 ${TMPFILE}
    rm ${TMPFILE}
done


if [ $ERROR -eq 1 ] ; then
   echo "ping NG"
   exit 1
fi

   echo "ping OK"
exit 0


Example

$ ./check_ping_gw.sh
--- 192.168.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 502ms
rtt min/avg/max/mdev = 0.783/0.838/0.902/0.054 ms
ping OK





Linux Operation with Fabric (ope.py)


Top#OS Management