I’ve been in some situations where I’d like to add timestamp to
pings. There could be loads of reasons as to why you’d like to do this,
but I used it to check if there where specific times of the day that had
higher latency on my internet-connection at home.
If you’re only interested in pings that gets valid replies, the following should work on most systems;
If you’re interested in all types of replies (unreachable, no route to host, etc), the following should work on most systems;
If you’re only interested in pings that gets valid replies, the following should work on most systems;
ping google.com | awk '/^[0-9]+ bytes from / { "date" | getline pong; close("date"); print pong":",$0; }' |
ping google.com | while read pong; do echo "$(date): $pong"; done
Comments