Add function for returning system load via api
This commit is contained in:
parent
f935fa6ca6
commit
345f152181
|
@ -22,4 +22,15 @@ class HostController extends AppController {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getLoad() {
|
||||||
|
$uptime = shell_exec( 'uptime' );
|
||||||
|
$load = '';
|
||||||
|
if ( preg_match( '/load average: ([\d.]+)/', $uptime, $matches ) )
|
||||||
|
$load = $matches[1];
|
||||||
|
|
||||||
|
$this->set(array(
|
||||||
|
'load' => $load,
|
||||||
|
'_serialize' => array('load')
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue