Here is a perl script tha should work (I have nothing over 400ms away)
Save it, mark it executable, and run it like
sudo ping.pl www.google.com
if you want to add a count to it, I can teach you how to do that.
Code:
use Net::Ping;
$host = $ARGV[0];
# High precision syntax (requires Time::HiRes)
$p = Net::Ping->new("icmp");
$p->hires();
($ret, $duration, $ip) = $p->ping($host, 5.5);
if (1000 * $duration >= 400){
printf("$host [ip: $ip] is alive (packet return time: %.2f ms)\n", 1000 * $duration)
}else{
#do nothing else
}
#printf("$host [ip: $ip] is alive (packet return time: %.2f ms)\n", 1000 * $duration)
if $ret;
$p->close();
It's way possible with bash, and awk, Im just not that good today, and perl makes it easier.
Bookmarks