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.
时间: 2024-10-15 03:09:50