Add function for returning system load via api

This commit is contained in:
Kyle Johnson 2014-11-21 19:49:03 +00:00
parent f935fa6ca6
commit 345f152181
1 changed files with 11 additions and 0 deletions

View File

@ -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')
));
}
}