Skip to content

Instantly share code, notes, and snippets.

@niko niko/lautfm-ping.php
Last active Nov 24, 2016

Embed
What would you like to do?
<?php
header('Content-Type: text/plain');
function ping($addr){
$starttime = microtime(true);
$file = fsockopen ($addr, 80, $errno, $errstr, 10);
$stoptime = microtime(true);
$status = 0;
if (!$file) $status = -1; // Site is down
else {
fclose($file);
$status = ($stoptime - $starttime) * 1000;
$status = floor($status);
}
return $status;
}
$addr = '31.7.184.137';
echo "lautfm_stream_ping{server=\"" . $_SERVER['SERVER_NAME'] . "\", addr=\"" . $addr . "\"} " . ping($addr) . "\n";
$addr = '81.95.11.211';
echo "lautfm_stream_ping{server=\"" . $_SERVER['SERVER_NAME'] . "\", addr=\"" . $addr . "\"} " . ping($addr) . "\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.