|
@@ -9,31 +9,63 @@ class arw_monitorControl extends SystemControl
|
|
|
|
|
|
public function indexOp()
|
|
|
{
|
|
|
+ global $config;
|
|
|
+ $servers = $config['server'];
|
|
|
$ins = Cache::getInstance('cacheredis');
|
|
|
$name = 'disk_monitor';
|
|
|
$hash_data = $ins->hget($name, '');
|
|
|
$result = [];
|
|
|
- foreach ($hash_data as $ip => $str)
|
|
|
- {
|
|
|
- $str = str_replace('\t', "", $str);
|
|
|
- $str = ltrim($str,'#');
|
|
|
- $arrs = explode('#', $str);
|
|
|
- foreach ($arrs as $arr) {
|
|
|
- $data = explode(':', $arr);
|
|
|
- $key = ltrim($data[0],'_');
|
|
|
- $value = $data[1];
|
|
|
- if($key == 'cur_time') {
|
|
|
- $cur_time = explode('-',$value);
|
|
|
- $value = "$cur_time[0]-$cur_time[1]-$cur_time[2] $cur_time[3]:$cur_time[4]:$cur_time[5]";
|
|
|
- }else{
|
|
|
- $key = str_replace('_', "/", $key);
|
|
|
- $value = rtrim($value, '.');
|
|
|
+ $cur_time = time();
|
|
|
+ $ago_time = 0;
|
|
|
+
|
|
|
+ $time_check = function($stat_str, $cur_time) {
|
|
|
+ $value = explode('-', $stat_str);
|
|
|
+ $value = "$value[0]-$value[1]-$value[2] $value[3]:$value[4]:$value[5]";
|
|
|
+ $stat_time = strtotime($value);
|
|
|
+ if($stat_time == false) return false;
|
|
|
+
|
|
|
+ $check_seconds = 1800;
|
|
|
+ $diff_time = $cur_time - $stat_time;
|
|
|
+ if($diff_time > $check_seconds) {
|
|
|
+ return false;
|
|
|
+ }else{
|
|
|
+ return $diff_time;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ foreach ($servers as $ip => $server_name) {
|
|
|
+ $hash_str = $hash_data[$ip];
|
|
|
+ $item = [];
|
|
|
+ if (!empty($hash_str)) {
|
|
|
+ $hash_str = str_replace('\t', "", $hash_str);
|
|
|
+ $hash_str = ltrim($hash_str, '#');
|
|
|
+ $arrs = explode('#', $hash_str);
|
|
|
+ foreach ($arrs as $arr) {
|
|
|
+ $data = explode(':', $arr);
|
|
|
+ $key = ltrim($data[0], '_');
|
|
|
+ $value = $data[1];
|
|
|
+ if ($key == 'cur_time') {
|
|
|
+ $diff_time = $time_check($value, $cur_time);
|
|
|
+ if ($diff_time == false) {
|
|
|
+ $value = '定时更新未正常工作';
|
|
|
+ } else {
|
|
|
+ $ago_time = $diff_time;
|
|
|
+ }
|
|
|
+ } elseif (strpos($key, 'dev') !== false) {
|
|
|
+ $key = str_replace('_', "/", $key);
|
|
|
+ $value = explode(',', $value);
|
|
|
+ $value = "{$value[1]}/{$value[0]}";
|
|
|
+ } else {
|
|
|
+ $key = str_replace('_', "/", $key);
|
|
|
+ $value = rtrim($value, '.');
|
|
|
+ }
|
|
|
+ $item[$key] = $value;
|
|
|
+ ksort($item);
|
|
|
}
|
|
|
- $item[$key] = $value;
|
|
|
}
|
|
|
- $result[$ip] = $item;
|
|
|
+ $result[$ip . "({$server_name})"] = $item;
|
|
|
}
|
|
|
Tpl::output('data', $result);
|
|
|
+ Tpl::output('ago_time', $this->elapse_time($ago_time));
|
|
|
Tpl::showpage('arw.monitor');
|
|
|
}
|
|
|
}
|