码迷,mamicode.com
首页 > 其他好文 > 详细

批量ping测试脚本

时间:2014-10-22 18:28:47      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:linux ping icmp

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测试脚本

标签:linux ping icmp

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!