1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- class arw_monitorControl extends SystemControl
- {
- public function __construct()
- {
- parent::__construct();
- }
- public function indexOp()
- {
- global $config;
- $servers = $config['server'];
- $ins = Cache::getInstance('cacheredis');
- $name = 'disk_monitor';
- $hash_data = $ins->hget($name, '');
- $result = [];
- $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);
- }
- }
- $result[$ip . "({$server_name})"] = $item;
- }
- Tpl::output('data', $result);
- Tpl::output('ago_time', $this->elapse_time($ago_time));
- Tpl::showpage('arw.monitor');
- }
- }
|