cat ip.sh#!/bin/bash#-------------------------------------------------- #Created: 2015-04-28# Author:jimmygong#mail:[email protected] #Function:p ing#version:1.0#--------------------------------------- -----------set -o nounsetipfile=~/iplist.txtpinglog=~/ping.logpinglog2=~/ping.log2[[ -e $ ipfile ]] | | exit 1[[ -e $pinglog ]] && ' > $pinglog ' function pingfc () {touch $pinglogi =1while read iplinedo ( packet= ' ping -s 100 -f -c 10 -q $ipline |awk /transmitted/|awk ' {print $6} ' echo ' $ipline $packet >> $pinglog ) & [[ $i%10 -eq 0 ]] && waitdone < $ipfilewaitgrep -v " 0%" & NBsp; $pinglog > $pinglog 2 2>&1}pingfcexit 0================================== Description = = = ========================================bash ip.sh Execution Results cat ping.log10.1.1.101 0%10.1.1.102 0%10.1.1.104 0%10.1.1.105 0%10.1.1.103 100%cat iplist.txt10.1.1.10110.1.1.10210.1.1.10310.1.1.10410.1.1.105-f limit detection. A large and fast network packet is sent to a machine to see its response. -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 howmany 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.-s bytes Specifies that the number of bytes sent is a preset value of 56 plus 8 bytes of ICMP header is a total of 64ICMP bytes of data. specifies the number of data bytes to be sent. the Default is 56, which translates into 64 icmp data bytes when combined with the 8 bytes of ICMP header data.-c The number is stopped after the specified number of packets have been sent. -c countstop after sending count echo_request packets. with deadline option, ping waits for count ECHO_REPLY packets, until the timeout expires.-q does not display information for any transmittal packets, only the final result is displayed. -q quiet output. nothing is displayed except the summary Lines at startup time and when finished. Two, need to install fping command (APT-GET&NBSP;-Y&NBsp;install fping --force-yes or yum -y install fping) fping - sends icmp ECHO_REQUEST packets to network hostsfping -ef /root/iplist.txt > ping.log 2>&1================================== Description ============================================ Execution Results cat ping.log10.1.1.101 is alive (0.66 ms) 10.1.1.102 is alive (1.22 &NBSP;MS) 10.1.1.104 is alive (1.28 ms) 10.1.1.105 is alive (1.26&NBSP;MS) 10.1.1.103 is unreachablecat iplist.txt10.1.1.10110.1.1.10210.1.1.10310.1.1.10410.1.1.105-f Read list of targets from a file.-e Show elapsed ( Round-trip) time of packets
This article is from the "7928217" blog, please be sure to keep this source http://7938217.blog.51cto.com/7928217/1639753
Two ways to ping a heap of machines (shell or fping)