final60 Posted January 6, 2009 Share Posted January 6, 2009 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 More sharing options...
timmah1 Posted January 6, 2009 Share Posted January 6, 2009 Last time I checked, this (ari1.ryzom.com) isn't an IP address Link to comment https://forums.phpfreaks.com/topic/139629-server-tracking-code/#findComment-730554 Share on other sites More sharing options...
xtopolis Posted January 6, 2009 Share Posted January 6, 2009 Start debugging your own code! Start with $uptime. echo it out, does it contain an expected value? Link to comment https://forums.phpfreaks.com/topic/139629-server-tracking-code/#findComment-730582 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.