<?

// configuration here
$disk = "/dev/sda1";

// Setup output array
$output = array();

// Uptime
// - CPU
exec("uptime |awk -F'average:' '{ print $2}'",$output);
$cpuusage = $output[0];

// Diskspace
exec("df -h",$output);
$diskspace = "";
foreach($output as $line)
{
        $cols = split(" ",$line);
	$getper = false;
        foreach($cols as $c) 
	{ 
		if(trim($c) != "") 
		{
			//echo "\n\t\t<td>".$c."</td>"; 
			if(trim($c) == $disk) $getper = true;
			$perpos = stripos($c, "%"); // echo "<br />$c - $perpos - $getper";
			if(trim($perpos) == "2" && $getper) $diskspace = $c;
		}		
	}
}

// Something else




foreach($output as $line)
{
	//echo $line . "<br />";
}




?>
<p>CPU: <?=$cpuusage;?>
<br />Diskspace: <?=$diskspace;?>
</p>

