测试域名ping延迟脚本

#!/bin/bash

if [ $# -lt 1 ]
then
echo "Usage:avg file1"
exit 1
fi
echo "====================`date`======================" >> result.txt
function main {
 time=`ping -c 10 -i 0.1 -q $1 | egrep "^rtt" | awk -F/ '{print $5}'`
 [[ "${time}" == "" ]] && echo -e "$1\ttime_out" >>result.txt || echo -e "$1\t${time}" >>result.txt
}

pipefile=/tmp/$$.fifo
mkfifo $pipefile
exec 5<>$pipefile
rm -rf $pipefile

for ((i=0;i<50;i++))
do
 echo
done>&5

while read domain
do
 read<&5
 (main $domain && echo>&5)&
done <$1
wait
exec 5>&-

posted @ 2016-05-08 23:19  chongchong88  阅读(633)  评论(0编辑  收藏  举报