20120824

Show ping summary in MacOS terminal

ping can be used for a lot of things. I do use it a lot to test reachability and how my internet access is behaving.

Usually you just execute ping in your terminal and then hit Ctrl+C to see the summary as follows:

[~] ➔ ping google.com
PING google.com (200.40.0.84): 56 data bytes
64 bytes from 200.40.0.84: icmp_seq=0 ttl=59 time=8.035 ms
64 bytes from 200.40.0.84: icmp_seq=1 ttl=59 time=8.088 ms
64 bytes from 200.40.0.84: icmp_seq=2 ttl=59 time=48.853 ms
64 bytes from 200.40.0.84: icmp_seq=3 ttl=59 time=16.623 ms
64 bytes from 200.40.0.84: icmp_seq=4 ttl=59 time=24.865 ms
^C
--- google.com ping statistics ---
5 packets transmitted, 5 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 8.035/21.293/48.853/15.128 ms
view raw gistfile1.sh hosted with ❤ by GitHub
Hitting Ctrl+C will send an interrupt signal (SIGINT) to the process, making it to terminate and show ing the summary.

Once in a while you need to check a long ping run but don't want to stop it (because of the final stats). The way of doing it, is to send a SIGINFO signal hitting Ctrl+T while the process runs.

[~] ➔ ping google.com
PING google.com (200.40.0.84): 56 data bytes
64 bytes from 200.40.0.84: icmp_seq=0 ttl=59 time=22.144 ms
64 bytes from 200.40.0.84: icmp_seq=1 ttl=59 time=8.602 ms
64 bytes from 200.40.0.84: icmp_seq=2 ttl=59 time=53.278 ms
64 bytes from 200.40.0.84: icmp_seq=3 ttl=59 time=11.416 ms
64 bytes from 200.40.0.84: icmp_seq=4 ttl=59 time=7.842 ms
64 bytes from 200.40.0.84: icmp_seq=5 ttl=59 time=14.848 ms
load: 0.86 cmd: ping 20845 running 0.00u 0.00s
6/6 packets received (100.0%) 7.842 min / 19.688 avg / 53.278 max
64 bytes from 200.40.0.84: icmp_seq=6 ttl=59 time=7.837 ms
64 bytes from 200.40.0.84: icmp_seq=7 ttl=59 time=7.209 ms
...
...
view raw gistfile1.sh hosted with ❤ by GitHub
Check line 9 and 10 in the previous example:
...
load: 0.86 cmd: ping 20845 running 0.00u 0.00s
6/6 packets received (100.0%) 7.842 min / 19.688 avg / 53.278 max
...
view raw gistfile1.sh hosted with ❤ by GitHub
and ping continues running!!!

References: Ping OS X Manual.

No hay comentarios.:

Publicar un comentario