Pages

Linux Ping continuous with show loss and output

1) MTR

mtr -i 0.2  -4  --psize 60  --no-dns -o "LD SR NABWV" 10.2.63.39

                         My traceroute  [v0.75]            
localhost.localdomain (0.0.0.0)                Mon Aug 21 16:30:06 2017
Keys:  Help   Display mode   Restart statistics   Order of fields   quit
                             Last  42 pings
 1. 10.2.14.3                ...............................>.......... 
 2. 0.0.0.0                  ????????????????????????????????????????? 
 3. 10.2.9.22                ......................................... 
Scale:  .:0 ms  1:1 ms  2:1 ms  3:2 ms  a:5 ms  b:7 ms  c:12 ms




2) PING

#####cat PING
#!/bin/bash

host=$1

if [ -z $host ]; then
    echo "Usage: `basename $0` [HOST]"
    exit 1
fi

while :; do
    result=`ping -W 1 -s 60 -c 1  $host | grep 'bytes from '`
    if [ $? -gt 0 ]; then
        echo -e "`date +'%Y/%m/%d %H:%M:%S'` - $host is \033[0;31mdown\033[0m"
    else
         echo -e "`date +'%Y/%m/%d %H:%M:%S'` - $host is \033[0;32mok\033[0m -`echo $result | cut -d ':' -f 2`"
        sleep 0.2 # avoid ping rain
    fi
done


PING 10.2.63.37 > PING-10.2.63.37.log

2017/08/21 12:18:26 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.04 ms
2017/08/21 12:18:26 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.03 ms
2017/08/21 12:18:26 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.08 ms
2017/08/21 12:18:26 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=0.995 ms
2017/08/21 12:18:27 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.09 ms
2017/08/21 12:18:27 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.08 ms
2017/08/21 12:18:27 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.08 ms
2017/08/21 12:18:27 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.04 ms
2017/08/21 12:18:28 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.00 ms
2017/08/21 12:18:28 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.10 ms
2017/08/21 12:18:28 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.15 ms
2017/08/21 12:18:28 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.03 ms
2017/08/21 12:18:28 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.07 ms
2017/08/21 12:18:29 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.00 ms
2017/08/21 12:18:29 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.02 ms
2017/08/21 12:18:29 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=0.986 ms
2017/08/21 12:18:29 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.01 ms
2017/08/21 12:18:29 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.04 ms
2017/08/21 12:18:30 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.03 ms
2017/08/21 12:18:30 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.01 ms
2017/08/21 12:18:30 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.04 ms
2017/08/21 12:18:30 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.00 ms
2017/08/21 12:18:30 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.05 ms
2017/08/21 12:18:31 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.06 ms
2017/08/21 12:18:31 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.04 ms
2017/08/21 12:18:31 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.12 ms
2017/08/21 12:18:31 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=0.943 ms
2017/08/21 12:18:32 - 10.2.63.37 is ok - icmp_seq=1 ttl=62 time=1.05 ms