How to get the output of ping(bash) while it is running?

I want to monitor round-trip time of my network, drawing the date using highcharts on linux

I know how to get the result of ping after it finished running. Like:

[root@localhost dev]# ping stackoverflow.com -c 5
PING stackoverflow.com (104.16.36.249) 56(84) bytes of data.
64 bytes from 104.16.36.249: icmp_seq=1 ttl=128 time=341 ms
64 bytes from 104.16.36.249: icmp_seq=2 ttl=128 time=351 ms
64 bytes from 104.16.36.249: icmp_seq=3 ttl=128 time=342 ms
64 bytes from 104.16.36.249: icmp_seq=4 ttl=128 time=294 ms
64 bytes from 104.16.36.249: icmp_seq=5 ttl=128 time=286 ms

--- stackoverflow.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 5622ms
rtt min/avg/max/mdev = 286.302/323.460/351.832/27.258 ms
[root@localhost dev]# 

I know how to get the info such as rtt min/avg/max/mdev = 286.302/323.460/351.832/27.258 ms after ping has finished.

Now I want to draw a Live chart using Ajax.

Is there a way to get the output of ping while it is running? I need the round-trip time.

[root@localhost dev]# ping stackoverflow.com       
PING stackoverflow.com (104.16.36.249) 56(84) bytes of data.
64 bytes from 104.16.36.249: icmp_seq=1 ttl=128 time=359 ms
64 bytes from 104.16.36.249: icmp_seq=2 ttl=128 time=341 ms
64 bytes from 104.16.36.249: icmp_seq=3 ttl=128 time=348 ms
64 bytes from 104.16.36.249: icmp_seq=4 ttl=128 time=359 ms
64 bytes from 104.16.36.249: icmp_seq=5 ttl=128 time=357 ms
64 bytes from 104.16.36.249: icmp_seq=6 ttl=128 time=301 ms
64 bytes from 104.16.36.249: icmp_seq=7 ttl=128 time=299 ms

I need time : 64 bytes from 104.16.36.249: icmp_seq=7 ttl=128 time=299 ms

Please help with linux bash shell, js and php. Thank you.


Click here view more answers http://ift.tt/1OYPIGE