MACHINE_THAT_GOES_PING
Given that my first UNIX experience was on Linux, I’ve gotten used to the way certain commands work. When I switched from Linux to OpenIndiana (an Illumos-based distro), I had to get used to the fact that some commands worked slightly (or in some case extremely) differently. One such command is ping.
On Linux, invoking ping without any arguments, I would get the very familiar output:
linux$ ping powerdns.com PING powerdns.com (82.94.213.34) 56(84) bytes of data. 64 bytes from xs.powerdns.com (82.94.213.34): icmp_req=1 ttl=55 time=98.0 ms 64 bytes from xs.powerdns.com (82.94.213.34): icmp_req=2 ttl=55 time=99.2 ms 64 bytes from xs.powerdns.com (82.94.213.34): icmp_req=3 ttl=55 time=100 ms ^C --- powerdns.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2002ms rtt min/avg/max/mdev = 98.044/99.170/100.188/0.950 ms
I was very surprised when I first ran ping on an OpenIndiana box since it outputted something very different:
oi$ ping powerdns.com powerdns.com is alive
No statistics! Just a boolean indicating “has the host responded to a single ping.” When I run ping, I want to see the statistics—that’s why I run ping to begin with. The manpage helpfully points out that I can get statistics by using the -s option:
oi$ ping -s powerdns.com PING powerdns.com: 56 data bytes 64 bytes from xs.powerdns.com (82.94.213.34): icmp_seq=0. time=98.955 ms 64 bytes from xs.powerdns.com (82.94.213.34): icmp_seq=1. time=99.597 ms 64 bytes from xs.powerdns.com (82.94.213.34): icmp_seq=2. time=99.546 ms ^C ----powerdns.com PING Statistics---- 3 packets transmitted, 3 packets received, 0% packet loss round-trip (ms) min/avg/max/stddev = 98.955/99.366/99.597/0.357
For the past few years, I’ve just been getting used to adding -s. It was a little annoying, but it wasn’t the end of the world because I don’t use ping that much and when I do, the two extra characters don’t matter.
Recently, I was looking through the source for Illumos’s ping when I discovered that statistics can be enabled not just by the -s option but also with the MACHINE_THAT_GOES_PING environment variable!
A quick test later, I added the variable to my environment scripts and never looked back.
This is what is looks like:
oi$ export MACHINE_THAT_GOES_PING=1 oi$ ping powerdns.com PING powerdns.com: 56 data bytes 64 bytes from xs.powerdns.com (82.94.213.34): icmp_seq=0. time=98.704 ms 64 bytes from xs.powerdns.com (82.94.213.34): icmp_seq=1. time=99.062 ms 64 bytes from xs.powerdns.com (82.94.213.34): icmp_seq=2. time=99.156 ms ^C ----powerdns.com PING Statistics---- 3 packets transmitted, 3 packets received, 0% packet loss round-trip (ms) min/avg/max/stddev = 98.704/98.974/99.156/0.239
In conclusion, if you are a Linux refugee and you miss the way ping worked on Linux, just add MACHINE_THAT_GOES_PING to your environment and don’t look back.