Skip to content

Instantly share code, notes, and snippets.

@Kaweechelchen
Last active January 27, 2016 19:54
Show Gist options
  • Save Kaweechelchen/35c67650769c570d92c9 to your computer and use it in GitHub Desktop.
Save Kaweechelchen/35c67650769c570d92c9 to your computer and use it in GitHub Desktop.
script to get the ping time to a domain host
<?php
$domain = 'http://mona.lu';
echo getPingTime($domain);
function getPingTime($domain) {
$domain = parse_url($domain, PHP_URL_HOST);
exec("ping -c 1 " . $domain . " | head -n 2 | tail -n 1 | awk '{print $7}'", $ping_time);
return $ping_time[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment