Last active
November 24, 2016 13:46
-
-
Save niko/b1e4c7c65cbdf4104458ec8ca45bd074 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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