While travelling it’s sometimes useful to know how your connection is doing. When nothing is loading, or connections timing out, getting a quick snapshot of the connection health will tell you how bad it is, and give you an idea of how soon you will be up and running agian.

Here’s a one-liner that works on most Unix based systems:

ping -i5 | grep --line-buffered -o -E -e "time=.*$" -e "timeout"

Here we use ping to send an ICMP request to Google’s DNS server every 5 seconds. By piping standard out to grep with the --line-buffered option we can grep the continuous output stream and, by using -o, showing only the matches.

Here’s what it looks like:

time=602.919 ms
time=604.434 ms
time=1233.740 ms
time=150.504 ms

To make it easier to access, we can create a small script in ~/bin:

touch ~/bin/travelping
chmod +x ~/bin/travelping

And add the contents:

ping -i5 | grep --line-buffered -o -E -e "time=.*$" -e "timeout"

From the command line we can now run:

$ travelping
time=743.092 ms
time=1784.171 ms
time=1430.412 ms
time=497.880 ms

If you’re using tmux or iTerm2, it fits neatly in one corner of your screen. Here together with htop in iTerm2:


You can download the script from GitHub.