function filterAlarmNodes()
{
$category = $this->params["url"]['category'];
$nodesInfo = $this->_getHostsInfo();
$clusterName = $this->Cluster->getClusterName();
$clusterView = $this->health->clusterView($nodesInfo, $clusterName);
$all_hosts = $this->machines->getAllDisplayNames();
//var_dump($clusterView);
$data = array();
foreach ($clusterView as $key => $entry) {
if (!preg_match('/[0-9\.]/', $key))
continue;
$_this = $this;
$callback = function ($category, $key, $entry) use($_this){
return call_user_func(array($_this, '_filterNodes'), $category, $key, $entry);
};
if (($desc = $callback($category, $key, $entry)) != false) {
$data[] = array(
'nodename' => $all_hosts[$this->machines->getHostByIP($key)]['dispname'],
'ip' => $key,
'desc' => $desc
);
}
}
$info = array('code' => 'success', 'data' => $data);
return $this->_jsonView($info);
}
璇ユ柟娉曚富瑕佺敤鏉ョ瓫閫夐泦緹や腑璀﹀憡鐘舵佺殑鑺傜偣錛屾牴鎹紶鍏ョ殑鍙傛暟category錛岃繑鍥炰笉鍚岀殑緇撴灉闆嗭紝渚嬪CPU娓╁害榪囬珮鐨勶紝CPU鍒╃敤鐜囪繃楂樼殑絳夌瓑錛涚敱浜庢瘡涓猚ategory閲囩敤鐨勭瓫閫夌畻娉曚笉鍚岋紝鍥犳瀹氫箟浜嗕竴涓猚allback鏂規硶錛岃鏂規硶璋冪敤$this鐨刜filterNodes鏂規硶鏍規嵁category緇х畫榪涜鏂規硶鍒嗘淳銆傚畾涔塩allback灞忚斀浜嗕笉鍚岀瓫閫夋柟娉曠殑宸紓錛屽閮ㄨ皟鐢ㄦ帴鍙e緇堜竴鑷淬?br />
function _filterNodes($category, $key, $entry)
{
switch ($category){
case "cpu_temp_alarm":
return $this->_filterNodesForCpuTemp($key, $entry);
case "cpu_usage_alarm":
return $this->_filterNodesForCpuUsage($key, $entry);
default:
break;
}
}
_filterNodesForCpuTemp鏂規硶寰堢畝鍗曪紝鏍規嵁褰撳墠鑺傜偣閲囬泦鐨勫悇涓猰eter鐨勫?鍖呭惈鍦?entry涓?錛岃繑鍥炶鑺傜偣鏄惁闇瑕佸寘鍚湪絳涢夌粨鏋滈泦涓紙false涓轟笉鍖呭惈錛夈傚湪闂寘鍜宑allback浣跨敤涓紝鏈変袱涓湴鏂歸渶瑕佹敞鎰忥細
- _filterNodes涓嶈兘瀹氫箟涓簆rivate錛屽惁鍒欏洖鎶ラ敊銆?/li>
- $this涓嶈兘鐩存帴鍏坲se($this)錛岀劧鍚庡湪鍥炶皟涓嬌鐢?php浼氭姤閿?錛涢渶瑕佸厛鎶?this璧嬪肩粰涓涓彉閲?鏈緥涓槸$_this)錛岀劧鍚庡啀use($_this)錛岀劧鍚庡湪鍥炶皟鏂規硶涓嬌鐢?/li>

]]>