ping一堆機器的二種方法(shell或fping)

來源:互聯網
上載者:User

標籤:shell fping

cat ip.sh#!/bin/bash#--------------------------------------------------  #Created:2015-04-28#Author:jimmygong#Mail:[email protected]#Function:ping#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%" $pinglog > $pinglog2 2>&1}pingfcexit 0==================================說明============================================bash ip.sh執行結果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 極限檢測。大量且快速地送網路封包給一台機器看它的回應。-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 位元組數指定發送的資料位元組數預設值是56加上8位元組的ICMP頭一共是64ICMP資料位元組。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 數目在發送指定數目的包後停止。-c countStop after sending count ECHO_REQUEST packets. With deadline option, ping waits for count ECHO_REPLY packets, until the timeout expires.-q 不顯示任何傳送封包的資訊只顯示最後的結果。-q Quiet output.  Nothing is displayed except the summary lines at startup time and when finished.二、需要安裝fping命令(apt-get -y install fping --force-yes或yum -y install fping)fping - sends ICMP ECHO_REQUEST packets to network hostsfping -ef /root/iplist.txt >ping.log 2>&1==================================說明============================================執行結果cat ping.log10.1.1.101 is alive (0.66 ms)10.1.1.102 is alive (1.22 ms)10.1.1.104 is alive (1.28 ms)10.1.1.105 is alive (1.26 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

本文出自 “7928217” 部落格,請務必保留此出處http://7938217.blog.51cto.com/7928217/1639753

ping一堆機器的二種方法(shell或fping)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.