Google+ Linux How-To: Text-based horizontal visualization of ping round-trip delay time using bash oneliner | Hukkinen eduskuntaan (248. Helsinki) | Blog
Log in or Sign Up

Linux How-To: Text-based horizontal visualization of ping round-trip delay time using bash oneliner

1 8.8.2013, elo vk 32, 3.57
Kirjoittaja: HUKKINEN

Linux How-To: Text-based horizontal visualization of ping round-trip delay time using bash oneliner

I've been thinking converting the time, from a command line ping, to a number of characters (in the style of a horizontal bar). This could be enough for visualizing the ping round-trip-time, that roughly describes YOUR internet connectivity.

Thanks to a question on diasp.eu, I did it. Here's the oneliner. Run it in terminal window (bash should be default):

echo Calibrating meter baseline to minimum round trip time...; min=`ping -c 6 8.8.4.4 2>&1 | tail -1 | cut -d'/' -f4 | cut -d' ' -f3 |cut -d'.' -f1`; echo "Calibrated. Meter 0 is now $min ms. One ms increase is shown as one D."; while [ ! `sleep $frequency` ]; do ms=`ping 8.8.4.4 -c 1 2>&1 |cut -d'=' -f4| egrep ' ms'|cut -d' ' -f1|cut -d'.' -f1`; T="`echo $ms`-$min"; while [ `echo $T|bc` -gt 0 ]; do OUTPUT="$OUTPUT"D; T=$((T-1)); done; echo "$OUTPUT: $ms ms ($min)"; OUTPUT=""; done

Usage

You can reset the meter refresh delay 3 above. That means, it sends one ping every 3 seconds. It uses Google name server 8.8.4.4 (only). If ping improves after starting, the initial calibration is out of place, thus, the one-liner should be restarted.

Here's the output

Calibrating meter baseline to minimum round trip time...
Calibrated. Meter 0 is now 56 ms. One ms increase is shown as one D.
DDDDDDDDDDD: 67 ms (56)
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD: 93 ms (56)
DDDDDDDDDDDDDDDDDDDDDDDDDDDDD: 85 ms (56)
DDDD: 60 ms (56)
: 56 ms (56)
DDDDDDDDDDDDDDDDD: 73 ms (56)
DDDDD: 61 ms (56)
DDDDDDDDDDDDDDDDD: 73 ms (56)
DDDDDDDD: 64 ms (56)
DDDDDDDDDDDDDDDDDDDDDDDDDDDDD: 85 ms (56)
DDDDDDDDDD: 66 ms (56)
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD: 105 ms (56)
^C