Jump to content

server tracking code


final60

Recommended Posts

Heya

Ive found this php code that tracks server uptime and tried to apply the server id like to track, but it read 0 days 0 mins 0 secs, when i know the server has been up for a few days straight.

 

The server ip address is ari1.ryzom.com.

 


<?php
$uptime = @exec('uptime');
preg_match("/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/",
$uptime,$avgs);
$uptime = explode(' up ', $uptime);

$uptime = explode(',', 
$uptime[1]);

if (strpos($uptime[0],"day")===false){
  if (strpos($uptime[0],"min")===false){
    $days = 0;
    list($hours, $minutes) = explode(':',trim($uptime[0]));
  }
  
else{
    $days = $hours = 0;
    $minutes = (int)$uptime[0];
  }
}

else{
  $days = (int)$uptime[0];
  list($hours, $minutes) = explode(':',trim($uptime[1]));
}



$hours = (int)$hours;
$minutes = (int)$minutes;

$server = gethostbyaddr ($_SERVER['ari1.ryzom.com']);

echo "Uptime" <b>$server</b>: 
$days days, $hours hours and $minutes minutes";

if ($_SERVER['HTTP_HOST']!="www.esoftpro.com"){
echo "<br /><br /><div style=\"font-size:8pt\">Provided by <a href=\"http://www.esoftpro.com\">esoftpro.com</a></div>";
}
?>

 

Any help much appreciated

Link to comment
https://forums.phpfreaks.com/topic/139629-server-tracking-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.