Jump to content
  • 0

Server Status


no1uno

Question

9 answers to this question

Recommended Posts

  • 0

Also, I found this script on a open-source control panel I used to to use. It showed the server uptime on my windows machine. Unfortunately I don't know much about PHP, but maybe someone can get it to work with the current WHMCS status script.

 

<? 
if (strpos(strtolower($_SERVER["SERVER_SOFTWARE"]), 'unix') || strpos(strtolower($_SERVER["SERVER_SOFTWARE"]), 'linux')) {
 $data = shell_exec('uptime');
 $uptime = explode(' up ', $data);
 $uptime = explode(',', $uptime[1]);
 $uptime = $uptime[0].', '.$uptime[1];

 echo $uptime;
}else{
if ($sysdrive <> '') {

   $test= filemtime($sysdrive.":/pagefile.sys");   // Path to your Swap File (adjust it if necessary)
   $up = time() - $test;
   $days = floor($up / 86400);
   $up -= ($days * 86400);
   $hours = floor($up / 3600);
   $up -= ($hours * 3600);
   $minutes = floor($up / 60);
   $up -= ($minutes * 60);
   $seconds = $up;
if (isset($getuptime)) {
$template_uptime = $days." d, ".$hours." h, ".$minutes." m and ".$seconds." s";
}else{
   echo $days." d, ".$hours." h, ".$minutes." m and ".$seconds." s";
}
}else{
	$template_uptime = 'Not Available';
}
}
?>

Link to comment
Share on other sites

  • 0

That script will not return a "load average" for a windows server. Such a thing doesn't even exist. However, the uptime code appears to be valid assuming you haven't renamed/moved your swap file.

 

The swap file gets recreated after every reboot. The script above checks the modification time of that file to determine what the servers uptime is.

 

If you're having trouble with it, I'm assuming its failing in locating the $sysdrive variable. You may need to hardcode the path to your swap file to resolve that. Further on that, that script looks like it was ripped out of another script. There are pieces missing, and the output format is not correct. Heres an example of a valid output:

 

3.09 0 Days 09:15:30 5.2.14 5.0.91 2.2.0

 

The format is "<LOAD> <UPTIME> <PHP_VER> <MYSQL_VER> <ZEND_VER?>"

 

This should be trivial to output (aside from the load) for anyone with basic PHP knowledge on a windows server.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated