0

Possible Duplicate:
Ping site and return result in PHP

I'm working on a control panel for my office that will ping a set of servers, about 12, and return either: Up(green dot), Slow(yellow dot), or Down (red dot)

Obviously Red would be determined by getting no response, and Green by returning a low ping time. Yellow I plan to have a threshold for the average of the last 5 ping returns.

Being as I'm not really familiar with PHP at all and am just doing this to give myself a heads up incase of any problems.

I have seen a guide on how to do a simple up/down on a single server, but nothing quite as deep as what I'm looking for. I'd love ANY help.

Thanks!

Community
  • 1
  • 1

1 Answers1

0
function ping($host, $port, $timeout) { 
    $tB = microtime(true); 
    $fP = fSockOpen($host, $port, $errno, $errstr, $timeout); 
    if (!$fP) { return "down"; } 
    $tA = microtime(true); 
    return round((($tA - $tB) * 1000), 0)." ms"; 
}
Gustav Westling
  • 633
  • 3
  • 9