Ping replacement that shows real time

Is there a ping replacement that will display the system's date/time in addition to the round trip time and sequence number? I would prefer a tool that runs on Linux, but if there is a cli tool I can run on Windows that would be good too.

There is a system which users are reporting is intermittently pausing. This doesn't seem to happen at any consistent time. I haven't been able to get the reporting user to tell when it happened with enough specificity to be able to correlate the pause to any logs.

One of the techs left a ping running against the host for a day. The round trip time got pretty large at one point in time. I am trying to figure out when exactly this happens so I can narrow down which log entries I should be looking at, and possibly correlate this pause with other data I might be able to collect with performance logs, device logs and so on.

64 bytes from 10.2.4.241: icmp_seq=1825 ttl=64 time=0.321 ms
64 bytes from 10.2.4.241: icmp_seq=1826 ttl=64 time=0.371 ms
64 bytes from 10.2.4.241: icmp_seq=1827 ttl=64 time=13937.638 ms
64 bytes from 10.2.4.241: icmp_seq=1828 ttl=64 time=12937.526 ms
64 bytes from 10.2.4.241: icmp_seq=1829 ttl=64 time=11937.392 ms
64 bytes from 10.2.4.241: icmp_seq=1830 ttl=64 time=10937.275 ms
...
64 bytes from 10.2.4.241: icmp_seq=1840 ttl=64 time=936.073 ms
64 bytes from 10.2.4.241: icmp_seq=1841 ttl=64 time=0.410 ms

Solution 1:

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)'

Solution 2:

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!