Ejemplo n.º 1
0
 public function __construct()
 {
     $this->dao = new Ym_Dao('log');
     $this->monitorApps = Sys_Database::getTable('apps');
     $this->monitorHosts = Sys_Database::getTable('hosts');
     $this->monitorServices = Sys_Database::getTable('services');
 }
Ejemplo n.º 2
0
 /**
  * 更新记录时间
  * @param $recordName
  * @param $time
  * @return int
  */
 public function updateRecordTime($recordName, $time)
 {
     $data = array('time' => $time);
     $where = array('name' => $recordName);
     $result = $this->dao->update(Sys_Database::getTable('extract_record'), $data, $where);
     return $result;
 }
Ejemplo n.º 3
0
 public function __construct()
 {
     $this->dao = new Ym_Dao('log');
     $this->userBusinessTable = Sys_Database::getTable('user_business');
     $this->relationBusinessTable = Sys_Database::getTable('relation_business');
     $this->relationHostTable = Sys_Database::getTable('relation_host');
 }
Ejemplo n.º 4
0
 public function run()
 {
     $this->groupTable = Sys_Database::getTable('worker');
     $this->alarmModel = $this->loadModel();
     if ($this->getRequest()->getPost('o') == 'delete') {
         $gid = $this->getRequest()->getPost('gid');
         $this->delete($gid);
     }
     if ($this->getRequest()->getQuery('o') == 'edit') {
         Yaf_Dispatcher::getInstance()->disableView();
         $this->initView();
         $configData = array();
         $id = $this->getRequest()->getQuery('id');
         if ($id) {
             $configDataTmp = $this->alarmModel->selectData($id, 1, 1, $this->groupTable);
             $configData = $configDataTmp[0];
         }
         $this->display('addworker', 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->groupTable);
     $alarmNum = $this->alarmModel->selectData($pid, -1, -1, $this->groupTable);
     $alarmList['num'] = $alarmNum['num'];
     $alarmList['pageCount'] = (int) ($alarmList['num'] / $limit) + 1;
     $alarmList['pageView'] = $this->page($alarmList['page'], $alarmList['pageCount']);
     $this->getView()->assign('alarmList', $alarmList);
 }
Ejemplo n.º 5
0
 public function getList($uid)
 {
     $returns = null;
     $sql = sprintf("SELECT GROUP_CONCAT(`name`) as `business` FROM `%s` WHERE `id` IN(SELECT `bid` FROM `%s` WHERE `uid` = %d)", Sys_Database::getTable('relation_business'), Sys_Database::getTable('user_business'), $uid);
     $result = $this->dao->queryRow($sql, true);
     $returns = $result['business'];
     return $returns;
 }
Ejemplo n.º 6
0
 /**
  * 访问初始化
  */
 public function __construct()
 {
     $this->dao = new Ym_Dao('default');
     $this->monitorUserGroupsTable = Sys_Database::getTable('user_groups');
     $this->monitorUserTable = Sys_Database::getTable('user');
     $this->t = microtime(TRUE);
     //echo $this->t.PHP_EOL;
 }
Ejemplo n.º 7
0
 /**
  * 访问初始化
  */
 public function __construct()
 {
     $this->dao = new Ym_Dao('log');
     $this->monitorLogConfigTable = Sys_Database::getTable('monitor_logconfig');
     $this->monitorLogTypeTable = Sys_Database::getTable('monitor_logtype');
     $this->monitorLogAction = Sys_Database::getTable('relation_logconfig_actions');
     $this->monitorAction = Sys_Database::getTable('monitor_actions');
     $this->monitorWorker = Sys_Database::getTable('worker');
 }
Ejemplo n.º 8
0
 /**
  * 访问初始化
  */
 public function __construct()
 {
     $this->dao = new Ym_Dao('default');
     $this->monitorAlarmTable = Sys_Database::getTable('monitor_alarm');
     $this->monitorAlarmConfigTable = Sys_Database::getTable('monitor_alarmconfig');
     $this->monitorLogConfigTable = Sys_Database::getTable('monitor_logconfig');
     $this->datawareKeyTable = Sys_Database::getTable('dataware_key');
     $this->extractRecordTable = Sys_Database::getTable('extract_record');
 }
Ejemplo n.º 9
0
 public function getCount($hosts, $from, $to)
 {
     $returns = 0;
     $where = sprintf("`time` > %d AND `time` <= %d", $from, $to);
     $where .= empty($hosts) ? '' : " AND `times`.`host_id` in ({$hosts})";
     $query = "SELECT count(`count`) AS `count` FROM (SELECT count(*) AS `count` FROM `" . Sys_Database::getTable('dataware_times') . "` AS times LEFT JOIN `" . Sys_Database::getTable('relation_path') . "` AS path ON path = times.path_id WHERE {$where} GROUP BY `path_id` ) AS `data`";
     $res = $this->dao->query($query)->fetch(PDO::FETCH_ASSOC);
     $returns = $res['count'];
     return $returns;
 }
Ejemplo n.º 10
0
 public function getCount($type = 0)
 {
     $returns = 0;
     if (empty($type)) {
         $returns = $this->dao->count(Sys_Database::getTable('monitor_alarm'));
     } else {
         $returns = $this->dao->count(Sys_Database::getTable('monitor_alarm'), array("status" => $type));
     }
     return $returns;
 }
Ejemplo n.º 11
0
 public function __construct()
 {
     // setting session handler callback function
     session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc'));
     // get session max lifetime in config
     $this->lifeTime = ini_get('session.gc_maxlifetime');
     // get database dao object
     $this->dao = new Ym_Dao('log');
     $this->table = Sys_Database::getTable('system_session');
 }
Ejemplo n.º 12
0
 public function getErrorNumber($hosts, $from, $to, $status = null)
 {
     $returns = 0;
     $whereStatus = empty($status) ? "AND `status` >= 500" : "AND `status` IN ({$status})";
     $whereHost = empty($hosts) ? "" : " AND `host_id` in ({$hosts})";
     $where = sprintf("WHERE `time` > %d AND `time` <= %d %s %s", $from, $to, $whereStatus, $whereHost);
     $sql = sprintf("SELECT sum(`num`) AS num FROM `%s` %s", Sys_Database::getTable('dataware_status'), $where);
     $result = $this->dao->query($sql)->fetch(PDO::FETCH_ASSOC);
     $returns = $result['num'];
     return $returns;
 }
Ejemplo n.º 13
0
 public function getAppId()
 {
     $returns = array();
     $join = array('[>]' . Sys_Database::getTable('monitor_logconfig') => array('monitor_app' => 'id'));
     $column = array(Sys_Database::getTable('monitor_logconfig') . '.id', Sys_Database::getTable('monitor_logconfig') . '.monitor_app', Sys_Database::getTable('monitor_alarmconfig') . '.monitor_param');
     $where = array('AND' => array(Sys_Database::getTable('monitor_alarmconfig') . '.monitor_status' => 1, Sys_Database::getTable('monitor_alarmconfig') . '.monitor_api' => 'check_weblog_key'));
     $config = $this->dao->select(Sys_Database::getTable('monitor_alarmconfig'), $join, $column, $where);
     foreach ($config as $app) {
         $returns[$app['monitor_app']][$app['id']] = $app['monitor_param'];
     }
     return $returns;
 }
Ejemplo n.º 14
0
 /**
  * 访问初始化
  */
 public function __construct()
 {
     $this->dao = new Ym_Dao('default');
     $this->monitorAlarmTable = Sys_Database::getTable('monitor_alarm');
     $this->datawareKeyTable = Sys_Database::getTable('dataware_key');
     $this->extractRecordTable = Sys_Database::getTable('extract_record');
     $this->datawareTimesTable = Sys_Database::getTable('dataware_times');
     $this->datawareStatusTable = Sys_Database::getTable('dataware_status');
     $this->relationPathTable = Sys_Database::getTable('relation_path');
     $this->relationHostTable = Sys_Database::getTable('relation_host');
     $this->relationServerTable = Sys_Database::getTable('relation_server');
 }
Ejemplo n.º 15
0
 /**
  * 构造函数 防止重写
  */
 public final function __construct()
 {
     $this->datawareTimesTable = Sys_Database::getTable('dataware_times');
     $this->datawareIpTable = Sys_Database::getTable('dataware_ip');
     $this->datawareStatusTable = Sys_Database::getTable('dataware_status');
     $this->datawareCountryTable = Sys_Database::getTable('dataware_country');
     $this->relationCountryTable = Sys_Database::getTable('relation_country');
     $this->relationHostTable = Sys_Database::getTable('relation_host');
     $this->relationPathTable = Sys_Database::getTable('relation_path');
     $this->extractRecordTable = Sys_Database::getTable('extract_record');
     $this->relationBusinessTable = Sys_Database::getTable('relation_business');
     $this->userBusinessTable = Sys_Database::getTable('user_business');
 }
Ejemplo n.º 16
0
 public function getServerId($server)
 {
     $returns = null;
     $columns = array('id');
     $where = sprintf("WHERE `server` = '%s'", $server);
     $rowData = $this->dao->get(Sys_Database::getTable('relation_server'), $columns, $where);
     if ($rowData) {
         $returns = $rowData['id'];
     } else {
         $data = array('server' => $server);
         $returns = $this->dao->insert(Sys_Database::getTable('relation_server'), $data);
     }
     return $returns;
 }
Ejemplo n.º 17
0
 public function getOne($region)
 {
     $returns = null;
     $domain = isset($region['domain']) ? trim($region['domain']) : null;
     $where = '';
     if (empty($domain)) {
         return $returns;
     } else {
         $where .= "`domain` = '{$domain}'";
     }
     $where = empty($where) ? $where : "WHERE " . $where;
     $sql = "SELECT * FROM `" . Sys_Database::getTable('relation_region') . "` {$where}";
     $returns = $this->dao->queryRow($sql, false, true);
     return $returns;
 }
Ejemplo n.º 18
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);
 }
Ejemplo n.º 19
0
 public function getCount($hosts, $from, $to)
 {
     $returns = 0;
     $where = sprintf("`time` = %d ", $from);
     if (!empty($to)) {
         $day = ($to - $from) / 86400;
         for ($i = 1; $i <= $day; $i++) {
             $where .= " OR `time` = " . ($from + $i * 86400);
         }
     }
     $where .= empty($hosts) ? '' : " AND `size`.`host_id` in ({$hosts})";
     $query = "SELECT count(`count`) AS `count` FROM (SELECT count(*) as `count` FROM `" . Sys_Database::getTable('dataware_size') . "` AS size WHERE {$where} GROUP BY `path_id`) AS `data`";
     $res = $this->dao->query($query)->fetch(PDO::FETCH_ASSOC);
     $returns = $res['count'];
     return $returns;
 }
Ejemplo n.º 20
0
 public function getHostId($host)
 {
     $hostId = null;
     $host = explode(",", $host);
     $host = implode("','", $host);
     $host = empty($host) ? '' : "'" . $host . "'";
     $column = "id";
     $where = "WHERE `host` in (" . $host . ")";
     $result = $this->dao->select(Sys_Database::getTable('relation_host'), $column, $where);
     if ($result) {
         foreach ($result as $value) {
             $hostId .= $value . ",";
         }
         $hostId = rtrim($hostId, ',');
     }
     return $hostId;
 }
Ejemplo n.º 21
0
 /**
  * 访问初始化
  */
 public function __construct()
 {
     $this->dao = new Ym_Dao('log');
     $this->monitorAlarmConfigTable = Sys_Database::getTable('monitor_alarmconfig');
     $this->monitorLogConfigTable = Sys_Database::getTable('monitor_logconfig');
     $this->monitorRelationHostTable = Sys_Database::getTable('relation_host');
     $this->monitorRelationServerTable = Sys_Database::getTable('relation_server');
     $this->monitorRelationUGTable = Sys_Database::getTable('relation_user_group');
     $this->monitorUserGroupsTable = Sys_Database::getTable('user_groups');
     $this->monitorUserTable = Sys_Database::getTable('user');
     $this->monitorApps = Sys_Database::getTable('apps');
     $this->monitorHosts = Sys_Database::getTable('hosts');
     $this->monitorServices = Sys_Database::getTable('services');
     $this->workerTable = Sys_Database::getTable('worker');
     $this->triggerTable = Sys_Database::getTable('trigger');
     $this->monitorRelationLATable = Sys_Database::getTable('relation_log_action');
     $this->actionsTable = Sys_Database::getTable('monitor_actions');
 }
Ejemplo n.º 22
0
 public function run()
 {
     $this->groupTable = Sys_Database::getTable('user_groups');
     $this->monitorRelationUGTable = Sys_Database::getTable('relation_user_group');
     $this->alarmModel = $this->loadModel();
     if ($this->getRequest()->getPost('o') == 'delete') {
         $gid = $this->getRequest()->getPost('gid');
         $this->delete($gid);
     }
     if ($this->getRequest()->getQuery('o') == 'edit') {
         Yaf_Dispatcher::getInstance()->disableView();
         $this->initView();
         $configData = array();
         $id = $this->getRequest()->getQuery('id');
         if ($id) {
             $configData = $this->alarmModel->selectData($id, 1, 1, $this->groupTable);
             $configData[0]['user_id'] = $this->alarmModel->getUGIds(0, $id);
         }
         $configData[0]['ouser'] = $this->alarmModel->getMonitorUser();
         $this->display('groupsadd', array('D' => $configData[0]));
     }
     if ($this->getRequest()->getQuery('o') == 'add') {
         $this->add();
     }
     $page = $this->getRequest()->getQuery('p');
     $alarmList['page'] = $page ? $page : 1;
     $id = $this->getRequest()->getQuery('gid');
     $gid = $id ? $id : NULL;
     $limit = 20;
     $alarmList['list'] = $this->alarmModel->selectData($gid, ($alarmList['page'] - 1) * $limit, $limit, $this->groupTable);
     $alarmNum = $this->alarmModel->selectData($gid, -1, -1, $this->groupTable);
     $alarmList['num'] = $alarmNum['num'];
     foreach ($alarmList['list'] as $k => &$group) {
         $userStr = '';
         $users = $this->alarmModel->getUserNameByGid($group['id']);
         foreach ($users as $user) {
             $userStr .= $user['fullname'] . '-' . $user['aliasname'] . ' , ';
         }
         $alarmList['list'][$k]['users'] = rtrim($userStr, ' , ');
     }
     $alarmList['pageCount'] = (int) ($alarmList['num'] / $limit) + 1;
     $alarmList['pageView'] = $this->page($alarmList['page'], $alarmList['pageCount']);
     $this->getView()->assign('alarmList', $alarmList);
 }
Ejemplo n.º 23
0
 public function getMinute($flag, $hosts, $from, $to)
 {
     $returns = array();
     $column = '`time`,sum(`num`) AS `num`';
     $where = sprintf("WHERE `time` > %d AND `time` <= %d", $from, $to);
     $where .= empty($hosts) ? '' : " AND `" . Sys_Database::getTable('dataware_times') . "`.`host_id` in (" . $hosts . ")";
     $group = 'GROUP BY `time`';
     $order = '';
     switch ($flag) {
         case 'max':
             $order = 'ORDER BY `num` DESC';
             break;
         case 'min':
             $order = 'ORDER BY `num` ASC';
             break;
     }
     $query = sprintf("SELECT %s FROM `%s` %s %s %s ", $column, Sys_Database::getTable('dataware_times'), $where, $group, $order);
     $returns = $this->dao->query($query)->fetch(PDO::FETCH_ASSOC);
     return $returns;
 }
Ejemplo n.º 24
0
 public function run()
 {
     $this->groupTable = Sys_Database::getTable('monitor_actions');
     $this->alarmModel = $this->loadModel();
     if ($this->getRequest()->getPost('o') == 'delete') {
         $gid = $this->getRequest()->getPost('gid');
         $this->delete($gid);
     }
     if ($this->getRequest()->getQuery('o') == 'edit') {
         Yaf_Dispatcher::getInstance()->disableView();
         $this->initView();
         $configData = array();
         $id = $this->getRequest()->getQuery('id');
         if ($id) {
             $configData = $this->alarmModel->selectData($id, 1, 1, $this->groupTable);
             $configData = $configData[0];
             /*$selectedApps = $this->alarmModel->getApps($id);
               $configData['selectedApps'] = array();
               foreach($selectedApps as $k=>$v) {
                   $configData['selectedApps'][] = $v['logid'];
               }*/
         }
         $configData['appsAll'] = $this->alarmModel->getLogs();
         $configData['workersAll'] = $this->alarmModel->getWorkers();
         $this->display('addaction', 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('gid');
     $gid = $id ? $id : NULL;
     $limit = 20;
     $alarmList['list'] = $this->alarmModel->selectData($gid, ($alarmList['page'] - 1) * $limit, $limit, $this->groupTable);
     $alarmNum = $this->alarmModel->selectData($gid, -1, -1, $this->groupTable);
     $alarmList['num'] = $alarmNum['num'];
     $alarmList['pageCount'] = (int) ($alarmList['num'] / $limit) + 1;
     $alarmList['pageView'] = $this->page($alarmList['page'], $alarmList['pageCount']);
     $this->getView()->assign('alarmList', $alarmList);
 }
Ejemplo n.º 25
0
 public function run()
 {
     $this->userTable = Sys_Database::getTable('user');
     $this->relation_user_group = Sys_Database::getTable('relation_user_group');
     $this->alarmModel = $this->loadModel();
     if ($this->getRequest()->getPost('o') == 'delete') {
         $uid = $this->getRequest()->getPost('uid');
         $this->delete($uid);
     }
     if ($this->getRequest()->getQuery('o') == 'edit') {
         Yaf_Dispatcher::getInstance()->disableView();
         $this->initView();
         $configData = array();
         $id = $this->getRequest()->getQuery('id');
         if ($id) {
             $configData = $this->alarmModel->selectData($id, 1, 1, $this->userTable);
             $configData[0]['group_id'] = $this->alarmModel->getUGIds($id, 0);
         }
         //$configData[0]['oapp'] = $this->alarmModel->getMonitorApp();
         //$configData[0]['ourl'] = $this->alarmModel->getMonitorUrl();
         //$configData[0]['oservice'] = $this->alarmModel->getMonitorService();
         //var_dump($configData);exit;
         $configData[0]['ogroup'] = $this->alarmModel->getMonitorGroup();
         $this->display('addusers', array('D' => $configData[0]));
     }
     if ($this->getRequest()->getQuery('o') == 'add') {
         $this->add();
     }
     $page = $this->getRequest()->getQuery('p');
     $alarmList['page'] = $page ? $page : 1;
     $id = $this->getRequest()->getQuery('uid');
     $uid = $id ? $id : NULL;
     $limit = 20;
     $alarmList['list'] = $this->alarmModel->selectData($uid, ($alarmList['page'] - 1) * $limit, $limit, $this->userTable);
     $alarmNum = $this->alarmModel->selectData($uid, -1, -1, $this->userTable);
     $alarmList['num'] = $alarmNum['num'];
     $alarmList['pageCount'] = (int) ($alarmList['num'] / $limit) + 1;
     $alarmList['pageView'] = $this->page($alarmList['page'], $alarmList['pageCount']);
     $this->getView()->assign('alarmList', $alarmList);
 }
Ejemplo n.º 26
0
 public function getErrorTopTen($hosts, $from, $to, $status)
 {
     $returns = array();
     $where = "WHERE status.`time`> {$from} AND status.`time` <= {$to} ";
     $where .= empty($hosts) ? '' : " AND status.`host_id` in ({$hosts})";
     $where .= " AND status.status in (" . $status . ")";
     $sql = "SELECT `time`, `host`, `path`,`status`,sum(num) AS num FROM `" . Sys_Database::getTable('dataware_status') . "` AS `status` LEFT JOIN `" . Sys_Database::getTable('relation_path') . "` AS path ON status.`path_id` = path.`id` {$where} GROUP BY path.`path`,`status` ORDER BY `num` DESC LIMIT 10";
     $query = $this->dao->query($sql);
     $returns = $query->fetchAll(PDO::FETCH_ASSOC);
     return $returns;
 }
Ejemplo n.º 27
0
 public function __construct($logType)
 {
     parent::__construct($logType);
     $this->datawareCountryTable = Sys_Database::getTable('dataware_country');
 }
Ejemplo n.º 28
0
 public function __construct($logType)
 {
     parent::__construct($logType);
     $this->datawareSizeTable = Sys_Database::getTable('dataware_size');
 }
Ejemplo n.º 29
0
 public function __construct($logType)
 {
     parent::__construct($logType);
     $this->datawareTimesTable = Sys_Database::getTable('dataware_times');
 }
Ejemplo n.º 30
0
 public function __construct()
 {
     $this->userTable = Sys_Database::getTable('user');
 }