Ping replacement that shows real time

You can add timestamps using perl like this:

ping 127.0.0.1 | perl -pe 'BEGIN {use POSIX;} print strftime("%Y-%m-%d %H:%M:%S ", localtime)'

Here's a bash solution :)

$ ping localhost | while read line ; do echo -e "$(date)\t $line" ; done
Tue Nov  3 04:46:26 MSK 2009     PING localhost (127.0.0.1) 56(84) bytes of data.
Tue Nov  3 04:46:26 MSK 2009     64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.033 ms
Tue Nov  3 04:46:27 MSK 2009     64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.040 ms
Tue Nov  3 04:46:28 MSK 2009     64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.046 ms
Tue Nov  3 04:46:29 MSK 2009     64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.046 ms

Now, let's make the date command produce a bit more nice output:

$ ping localhost | while read line ; do echo -e "$(date +%H:%I:%S)\t $line" ; done
04:04:13         PING localhost (127.0.0.1) 56(84) bytes of data.
04:04:13         64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.044 ms
04:04:14         64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.039 ms
04:04:15         64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.042 ms

Cheers!


A "heavier" option that we use to do regular checking of latency and packet loss is Smokeping. Not only does it give you a little more information in an easier to read format, but you can also do things like HTTP and DNS checks instead of relying on ICMP. Many firewalls and routers will de-prioritize ICMP resulting in false latency measurements.

Smokeping

Tags:

Ping