Topics

Get average server load

This should on as on

function __() {
	$os = strtolower(PHP_OS);
	if(strpos($os, "win") === false) {
		 if(file_exists("/proc/loadavg")) {
			  $ = file_get_contents("/proc/loadavg");
			  $ = explode(' ', $);
			  return $[0];
		 }elseif(function_exists("shell_exec")) {
			  $ = explode(' ', `uptime`);
			  return $[count($)-1];
		 }
	}elseif(class_exists("")) {
		$wmi =  COM("WinMgmts:\\\\.");
		$cpus = $wmi->ExecQuery(" * from Win32_Processor");
		
		$cpuload = 0;
		$i = 0;
		foreach($cpus as $){
			$cpuload += $->LoadPercentage;
			$i++;
		}
		$cpuload = round($cpuload / $i, 2);
		return "$cpuload";
	}
}