Prettyping is a wrapper that simplifies working with the ping command line tool, thanks to a nicer, easier to read output. Ping is one of the oldest and also most commonly used utilities for network testing and troubleshooting. However, it’s not easy to integrate due to its output.
Ping Output
What ping does (sending ICMP echo requests and measuring latency by reading the ICMP reply) is very simple and hasn’t changed since ping was first introduced. Consequently, the output of the ping utility hasn’t changed either in a long long time. And for good reasons I believe. There might be slight variations in the ping output among different OS’s, but if you used ping 20 years ago, and you use it today you should see the output formatted exactly the same way:
netbeez$ ping google.com PING google.com (172.217.164.110): 56 data bytes 64 bytes from 172.217.164.110: icmp_seq=0 ttl=55 time=25.697 ms 64 bytes from 172.217.164.110: icmp_seq=1 ttl=55 time=32.927 ms 64 bytes from 172.217.164.110: icmp_seq=2 ttl=55 time=22.650 ms 64 bytes from 172.217.164.110: icmp_seq=3 ttl=55 time=22.359 ms 64 bytes from 172.217.164.110: icmp_seq=4 ttl=55 time=23.026 ms ^C --- google.com ping statistics --- 5 packets transmitted, 5 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 22.359/25.332/32.927/3.979 ms
Once you terminate the ping process with Ctrl+C you see a summary of the statistics on the bottom.
Shortcomings
In most cases the regular ping output is all you need. For example, if you are trying to see if a host is reachable or what is the latency to a host, you are probably perfectly content.
For something more advanced though, such as getting a distribution of the latency, or getting a visual representation of the latency over a period of time, you’d have to use a spreadsheet or write a script that does parses and processes ping’s output.
If you have tried to do this, as you can imagine, you are not the first one. There are several ping wrappers out there, and here we’ll talk about prettyping.
Installation
Prettyping is a bash script that parses the output of the ping that you are already familiar with, and “prettyfies” its output. To install, all you have to do, is download, and execute it, as follows:
netbeez$ curl https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping --output prettyping.sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 23396 100 23396 0 0 187k 0 --:--:-- --:--:-- --:--:-- 187k netbeez$ chmod +x prettyping.sh
If you want you can move prettyping.sh to a directory found in the $SOURCES
On MaOS you can install it with:
brew intall prettyping
Now you are ready to enjoy the pretty version of ping.
Prettyping supports all ping flags, and it also has a number of options that you can see with:
netbeez$ ./prettyping.sh --help Usage: prettyping.sh [prettyping parameters] <standard ping parameters> This script is a wrapper around the system's "ping" tool. It will substitute each ping response line by a colored character, giving a very compact overview of the ping responses. prettyping parameters: --[no]color Enable/disable color output. (default: enabled) --[no]multicolor Enable/disable multi-color unicode output. Has no effect if either color or unicode is disabled. (default: enabled) --[no]unicode Enable/disable unicode characters. (default: enabled) --[no]legend Enable/disable the latency legend. (default: enabled) --[no]terminal Force the output designed to a terminal. (default: auto) --last <n> Use the last "n" pings at the statistics line. (default: 60) --columns <n> Override auto-detection of terminal dimensions. --lines <n> Override auto-detection of terminal dimensions. --rttmin <n> Minimum RTT represented in the unicode graph. (default: auto) --rttmax <n> Maximum RTT represented in the unicode graph. (default: auto) --awkbin <exec> Override the awk interpreter. (default: awk) --pingbin <exec> Override the ping tool. (default: ping) -6 Shortcut for: --pingbin ping6 ping parameters handled by prettyping: -a Audible ping is not implemented yet. -f Flood mode is not allowed in prettyping. -q Quiet output is not allowed in prettyping. -R Record route mode is not allowed in prettyping. -v Verbose output seems to be the default mode in ping. All other parameters are passed directly to ping.
Prettyping
Here is how the output looks like when pinging in the baidu.com
As you may notice, prettyping keeps running until we hitCtrl+C
and in a few lines it represents the output of 342 ping tests. The regular ping would need around 342 lines for the same output!
In addition, prettyping splits the latency in buckets (gray, green, red) and shows the latency distribution.
On the first line after the distribution graph, it shows the failed tests over the total number of packets sent, the minimum, average, and maximum latency value, and the latency of the last ping tests performed.
The second line after the distribution graph, shows the same data as the first line, but now the statistics are calculated over the last minute.
The lost packets are displayed with a question mark for the ones that got lost.
The statistics are calculated in real-time.
Although the output of ping hasn’t changed in decades probably, utilities such as prettyping give a fresh look. All in all, it’s pretty straightforward to install and use.