首页 > 其他 > 详细

批量ping测试脚本

时间:2014-10-22 18:27:00      阅读:308      评论:0      收藏:0      [点我收藏+]

ping测试脚本

#!/bin/bash
list=iplist.txt
log=ping.log
echo -n "" > $log
#清空历史日志
grep -v "#" $list | grep -v "^$" > .list
#从$list文件中读出ip地址列表,去掉包含#的行和空行,结果写入 .list
while read IP
do
        echo "$IP  `ping -s 1000 -f -c 100  $IP | grep transmitted | awk ‘{print $6}‘`" >> $log
done < .list
#从.list读入ip地址,执行ping检测
grep -v " 0%" $log
rm .list

ping 的参数 -s 指定icmp包大小,-c 指定ping包数量,-f 在数据包中设置不分段标志

man ping对于-f参数的说明如下

-f:Flood ping. For every ECHO_REQUEST sent a period ‘‘.‘‘ is printed, while for ever ECHO_REPLY received a backspace is printed. This provides a rapid display of how many packets are being dropped. If interval is not given, it sets interval to zero and outputs packets as fast as they come back or one hundred times per second, whichever is more. Only the super-user may use this option with zero interval.


本文出自 “foolishfish” 博客,请务必保留此出处http://foolishfish.blog.51cto.com/3822001/1566845

批量ping测试脚本

原文:http://foolishfish.blog.51cto.com/3822001/1566845

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!