Example #1
0
 public function run()
 {
     $alarmConfig = new Model_Alarm_Log();
     $id = $this->getRequest()->getQuery('id');
     if ($id) {
         $configData = $alarmConfig->selectdata($id);
         $configData['0']['selectedWorkerAction'] = $alarmConfig->selectedWorkerAction($id);
     }
     $configData[0]['worker'] = $alarmConfig->getWorkers();
     $configData[0]['actions'] = $alarmConfig->getActions();
     $this->getView()->assign('L', isset($configData[0]) ? $configData[0] : array());
 }
Example #2
0
 public function run()
 {
     $this->triggerTable = Sys_Database::getTable('trigger');
     $this->alarmModel = $this->loadModel();
     if ($this->getRequest()->getPost('o') == 'delete') {
         $gid = $this->getRequest()->getPost('gid');
         $rlaid = $this->getRequest()->getPost('rlaid');
         $this->delete($gid, $rlaid);
     }
     if ($this->getRequest()->getQuery('o') == 'edit') {
         Yaf_Dispatcher::getInstance()->disableView();
         $this->initView();
         $configData = array();
         $id = $this->getRequest()->getQuery('id');
         $alarmConfig = new Model_Alarm_Log();
         if ($id) {
             $configDataTmp = $this->alarmModel->selectData($id, 1, 1, $this->triggerTable);
             $configData = $configDataTmp[0];
             $configData['selected'] = $this->alarmModel->getNames($configData['rlaid']);
         }
         $configData['logs'] = $alarmConfig->getLogs();
         $configData['worker'] = $alarmConfig->getWorkers();
         $configData['actions'] = $alarmConfig->getActions();
         $this->display('addtrigger', array('D' => $configData));
     }
     if ($this->getRequest()->getQuery('o') == 'add') {
         $this->add();
     }
     $page = $this->getRequest()->getQuery('p');
     $alarmList['page'] = $page ? $page : 1;
     $id = $this->getRequest()->getQuery('pluginid');
     $pid = $id ? $id : NULL;
     $limit = 20;
     $alarmList['list'] = $this->alarmModel->selectData($pid, ($alarmList['page'] - 1) * $limit, $limit, $this->triggerTable);
     if ($alarmList['list']) {
         foreach ($alarmList['list'] as $k => $v) {
             $r = $this->alarmModel->getNames($v['rlaid']);
             $alarmList['list'][$k]['log'] = isset($r['logid']) ? $r['logid'] . "-" . $r['service'] : '';
             $alarmList['list'][$k]['worker'] = isset($r['workerid']) ? $r['workerid'] . "-" . $r['workername'] : '';
             $alarmList['list'][$k]['action'] = isset($r['actionid']) ? $r['actionid'] . "-" . $r['actionname'] : '';
         }
     }
     $alarmNum = $this->alarmModel->selectData($pid, -1, -1, $this->triggerTable);
     $alarmList['num'] = $alarmNum['num'];
     $alarmList['pageCount'] = (int) ($alarmList['num'] / $limit) + 1;
     $alarmList['pageView'] = $this->page($alarmList['page'], $alarmList['pageCount']);
     $this->getView()->assign('alarmList', $alarmList);
 }
Example #3
0
 public function run()
 {
     $alarmConfig = new Model_Alarm_Log();
     $configData = $alarmConfig->selectdata();
     $alarmpath = '/root/ypp/conf/alarmconf/';
     $ips = array();
     foreach ($configData as $v) {
         if (in_array(long2ip($v['monitor_ip']), $ips)) {
             $conf = "<source>\r\n";
             $conf .= "type tail\r\n";
             $conf .= "path " . $v['monitor_logpath'] . "\r\n";
             $conf .= "pos_file /tmp/log.pos\r\n";
             $conf .= "tag mongo.1\r\n";
             $conf .= "format none\r\n";
             $conf .= "</source>\r\n";
             $num = file_put_contents($alarmpath . long2ip($v['monitor_ip']) . '.conf', $conf, FILE_APPEND);
         } else {
             array_push($ips, long2ip($v['monitor_ip']));
             $conf = "<match mongo.*.*>\r\n";
             $conf .= "type mongo\r\n";
             $conf .= "host " . long2ip($v['monitor_ip']) . "\r\n";
             $conf .= "port 27017\r\n";
             $conf .= "database lbnginxlog\r\n";
             $conf .= "collection test3\r\n";
             $conf .= "flush_interval 1s\r\n";
             $conf .= "</match>\r\n";
             $conf .= "<source>\r\n";
             $conf .= "type tail\r\n";
             $conf .= "path " . $v['monitor_logpath'] . "\r\n";
             $conf .= "pos_file /tmp/log.pos\r\n";
             $conf .= "tag mongo.1\r\n";
             $conf .= "format none\r\n";
             $conf .= "</source>\r\n";
             $num = file_put_contents($alarmpath . long2ip($v['monitor_ip']) . '.conf', $conf);
         }
     }
     if ($num) {
         static::output(1, '成功生成conf.ini文件', '字节数为:' . $num);
     } else {
         static::output(0, '生成conf.ini文件失败', array());
     }
 }