Ejemplo n.º 1
0
 public function startAction()
 {
     $config = Yaf_Registry::get('monitor_config');
     $dataName = $config['loghandle'][$this->logType]['data'];
     $stepTime = intval($config['loghandle'][$this->logType]['step']);
     $logPersistentService = new Service_Log_Persistent();
     $logApp = $logPersistentService->getAppId();
     foreach ($logApp as $table => $appId) {
         $pid = pcntl_fork();
         if (!$pid) {
             $logDataService = new Service_Log_Data($this->logType, $dataName);
             $dataResult = $logDataService->getWeblog($table, $stepTime);
             if (!$dataResult) {
                 return false;
             }
             $etlModel = Model_Loghandle_Etl_Factory::create($this->logType, 'key');
             $extraData = array('logapp' => $logApp, 'data' => $dataResult, 'table' => $table);
             $transData = $etlModel->transform($extraData);
             $firstData = current($dataResult);
             $time = $firstData['time']->sec;
             $etlModel->load($transData, $time);
             exit;
         }
     }
     return false;
 }
Ejemplo n.º 2
0
 public function startAction()
 {
     $config = Yaf_Registry::get('monitor_config');
     $dataName = $config['loghandle'][$this->logType]['data'];
     $stepTime = intval($config['loghandle'][$this->logType]['step']);
     $modes = explode(',', $config['loghandle'][$this->logType]['mode']);
     $tables = explode(",", trim($config['mongo'][$this->logType]['tables']));
     $logDataService = new Service_Log_Data($this->logType, $dataName);
     $dataResult = $logDataService->getAccessLog($tables, $stepTime);
     if (!$dataResult) {
         return false;
     }
     $firstData = current($dataResult);
     $time = $firstData['time']->sec;
     $modeNum = count($modes);
     $loghandleEtlParserModel = new Model_Loghandle_Etl_Parser();
     $extractData = $loghandleEtlParserModel->extract($dataResult);
     for ($i = 0; $i < $modeNum; $i++) {
         $pid = pcntl_fork();
         $mode = $modes[$i];
         if (!$pid) {
             $etlModel = Model_Loghandle_Etl_Factory::create($this->logType, $mode);
             $transData = $etlModel->transform($extractData);
             $etlModel->load($transData, $time);
             exit;
         }
     }
     return false;
 }