@
tms 0-0 那个用的是php的opc自带的一个,内存和CPU监控的话
function get_load () {
$load = file_get_contents('/proc/loadavg');
$load = explode(' ', trim($load));
return array(
'one'=>$load[0],
'five'=>$load[1],
'ten'=>$load[2],
'running'=>$load[3],
'last-proc'=>$load[4]
);
}
function get_memory () {
$memory = file_get_contents('/proc/meminfo');
$mem = array();
foreach (explode("\n", $memory) as $line) {
$line = trim($line);
if (!$line) {
continue;
}
$pos = strpos($line, ':');
if ($pos === false) {
continue;
}
$k = substr($line, 0, $pos);
$v = trim(substr($line, $pos + 1));
if (strpos($v, 'kB') !== false) {
$v = (double)preg_replace('#([^0-9]+)#', '', $v);
if ($v > 0) {
$v = $v * 1024;
}
}
$mem[$k] = $v;
}
$mem=array();
$mem['MemUse'] = 100 * (1 - ($mem['MemFree'] / $mem['MemTotal']));
$mem['SwapUse'] = ($mem['SwapFree'] / $mem['SwapTotal']);
return $mem;
}
用这两个函数吧