2014-11-16 08:21:55 +08:00
|
|
|
<?php
|
|
|
|
App::uses('AppController', 'Controller');
|
|
|
|
|
|
|
|
class HostController extends AppController {
|
|
|
|
|
|
|
|
public $components = array('RequestHandler');
|
|
|
|
|
|
|
|
public function daemonCheck($daemon=false, $args=false) {
|
|
|
|
$string = "`which zmdc.pl` check";
|
|
|
|
if ( $daemon )
|
|
|
|
{
|
|
|
|
$string .= " $daemon";
|
|
|
|
if ( $args )
|
|
|
|
$string .= " $args";
|
|
|
|
}
|
|
|
|
$result = exec( $string );
|
|
|
|
$result = preg_match( '/running/', $result );
|
|
|
|
|
|
|
|
$this->set(array(
|
|
|
|
'result' => $result,
|
|
|
|
'_serialize' => array('result')
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2014-11-22 03:49:03 +08:00
|
|
|
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')
|
|
|
|
));
|
|
|
|
}
|
2014-11-16 08:21:55 +08:00
|
|
|
}
|