The Ping command is a useful tool that is used within the Terminal application (Applications > Utilities) and here at Amsys ServiceDesk we regularly use this tool to determine if a host (maybe mail server) is available.
The standard Ping command we would use to check if a host is…
ping
The returning output for a successful response from www.google.com should look something like this…
PING www.google.com (173.194.66.99): 56 data bytes
64 bytes from 173.194.66.99: icmp_seq=0 ttl=47 time=20.472 ms
64 bytes from 173.194.66.99: icmp_seq=1 ttl=47 time=21.449 ms
Recently I had to setup a simple Ping test for a customer to help determine dates and times when their internet connection was dropping.
We ran our test continuously over a weekend period and we setup two Terminal windows so that we could Ping two Hosts (Google and the BBC websites) so that if there was a dropout (Ping output would usually return “no route to host”) we could marry up the dates and times of the two Terminal windows to conclude when the connection dropped.
The Ping command for including date and time stamps would be…
ping www.google.com | perl -nle 'print scalar(localtime), " ", $_'
The returning output with date and time stamps should look something like this…
ping www.google.com | perl -nle 'print scalar(localtime), " ", $_'
Mon Jul 29 20:56:06 2013 PING www.google.com (173.194.66.105): 56 data bytes
Mon Jul 29 20:56:06 2013 64 bytes from 173.194.66.105: icmp_seq=0 ttl=48 time=18.885 ms
Mon Jul 29 20:56:07 2013 64 bytes from 173.194.66.105: icmp_seq=1 ttl=48 time=18.325 ms