View Single Post
  #2  
Old 23rd July 2008, 04:54
nasul9 nasul9 is offline
Member
 
Join Date: Jun 2008
Romania
Posts: 1
Default Re: [REQ] Server load mod
Add in index.php on tbdev.net(netmaniack's edition)1.6
Code:
<h2>Server load</h2><table width=100% border=1 cellspacing=0 cellpadding=10><tr><td align="center"><table class="main" border="0" width="402" height="15"><tbody><tr><td style="padding: 0px; background-image: url(./pic/loadbarbg.gif); background-repeat: repeat-x;"><?$perc = get_server_load();$percent = min(100, $perc);if ($percent <= 70) $pic = "loadbargreen.gif";elseif ($percent <= 90) $pic = "loadbaryellow.gif";else $pic = "loadbarred.gif";$width = $percent * 4;print("<img height=15 width=$width src=./pic/$pic alt='$percent%'></td></tr>");  ?></tbody></table></td></td></tr></table></td></tr></table>
Add in global.php on tbdev.net(netmaniack's edition)1.6
Code:
function get_server_load($windows = 0) {if(class_exists("COM")) {  $wmi = new COM("WinMgmts:\\\\.");  $cpus = $wmi->InstancesOf("Win32_Processor");  $i = 1;      // Use the while loop on PHP 4 and foreach on PHP 5     //while ($cpu = $cpus->Next()) {   foreach($cpus as $cpu) {    $cpu_stats += $cpu->LoadPercentage;    $i++;   }  return round($cpu_stats/2); // remove /2 for single processor systems}}
Reply With Quote