How to get the output of ping(bash) while it is running?
<p>I want to monitor round-trip time of my network, drawing the date using highcharts on linux</p><p>I know how to get the result of ping after it finished running. Like:</p><pre><br /><code>[root@localhost dev]# ping stackoverflow.com -c 5<br />PING stackoverflow.com (104.16.36.249) 56(84) bytes of data.<br />64 bytes from 104.16.36.249: icmp_seq=1 ttl=128 time=341 ms<br />64 bytes from 104.16.36.249: icmp_seq=2 ttl=128 time=351 ms<br />64 bytes from 104.16.36.249: icmp_seq=3 ttl=128 time=342 ms<br />64 bytes from 104.16.36.249: icmp_seq=4 ttl=128 time=294 ms<br />64 bytes from 104.16.36.249: icmp_seq=5 ttl=128 time=286 ms<br /><br />--- stackoverflow.com ping statistics ---<br />5 packets transmitted, 5 received, 0% packet loss, time 5622ms<br />rtt min/avg/max/mdev = 286.302/323.460/351.832/27.258 ms<br />[root@localhost dev]# <br /></code><br /></pre><p>I know how to get the info such as <code>rtt min/avg/max/mdev = 286.302/323.460/351.832/27.258 ms</code> after ping has finished.</p><p>Now I want to draw a <strong>Live</strong> chart using Ajax.</p><p>Is there a way to get the output of ping while it is running? I need the round-trip time.</p><pre><br /><code>[root@localhost dev]# ping stackoverflow.com <br />PING stackoverflow.com (104.16.36.249) 56(84) bytes of data.<br />64 bytes from 104.16.36.249: icmp_seq=1 ttl=128 time=359 ms<br />64 bytes from 104.16.36.249: icmp_seq=2 ttl=128 time=341 ms<br />64 bytes from 104.16.36.249: icmp_seq=3 ttl=128 time=348 ms<br />64 bytes from 104.16.36.249: icmp_seq=4 ttl=128 time=359 ms<br />64 bytes from 104.16.36.249: icmp_seq=5 ttl=128 time=357 ms<br />64 bytes from 104.16.36.249: icmp_seq=6 ttl=128 time=301 ms<br />64 bytes from 104.16.36.249: icmp_seq=7 ttl=128 time=299 ms<br /></code><br /></pre><p>I need time : <em>64 bytes from 104.16.36.249: icmp_seq=7 ttl=128 time=<strong>299</strong> ms</em></p><p>Please help with linux bash shell, js and php. Thank you.</p><br /><h2>Click here view more answers <a href="%20http://stackoverflow.com/questions/34525363/how-to-get-the-output-of-pingbash-while-it-is-running">http://ift.tt/1OYPIGE</a></h2>
Nhận xét
Đăng nhận xét