public function execute() { $type = $this->getRequest()->getQuery('type'); $status = $this->getRequest()->getQuery('status'); $page = $this->getRequest()->getQuery('page', 1); $host = $this->getRequest()->getQuery('host'); $path = $this->getRequest()->getQuery('path'); $from = strtotime($this->getRequest()->getQuery('from', date('Y-m-d'))); $to = strtotime($this->getRequest()->getQuery('to')); $to = empty($to) ? $from + 86400 : $to; $output = array(); $condition = array(); if (empty($type)) { return false; } if (!empty($status)) { $condition['status'] = $status; } $systemHostService = new Service_System_Host(); $analyticsAccessService = new Service_Analytics_Access(); $hostPathID = array(); foreach (explode(',', $host) as $h) { $hosts = $systemHostService->getHostPathId($h, $path); if ($hosts) { $hostPathID[] = array($hosts[0]['host_id'], $hosts[0]['path_id']); } } $output = $analyticsAccessService->getList($type, $hostPathID, $path, $from, $to, $page, $condition); Sys_Common::output(true, '', $output); }
function execute() { $output = array(); $hosts = trim($this->getRequest()->getQuery('host')); $monitorDataNodeService = new Model_Alarm_DataNode(); $output['series'] = $monitorDataNodeService->getNodeData($hosts); Sys_Common::output(true, '', $output); }
function execute() { $output = array(); //$hosts = trim($this->getRequest()->getQuery('host')); $monitorDataNodeService = new Model_Alarm_DataNode(); $output['series'][] = array('name' => 'click', 'data' => $monitorDataNodeService->getHourClick('click')); $output['series'][] = array('name' => 'conv', 'data' => $monitorDataNodeService->getHourClick('conv')); Sys_Common::output(true, '', $output); }
public function regionAction() { $domain = $this->getRequest()->getQuery('domain'); $region = array("domain" => $domain); $list = $this->regionService->getAllRegion(); $one = $this->regionService->getRegion($region); $output = array('list' => $list, 'self' => $one); Sys_Common::output(true, '', $output); }
function execute() { $type = $this->getRequest()->getQuery("type"); $type = explode(",", $type); $output = array(); $series = array(); $monitorAlarmService = new Service_Monitor_Alarm(); foreach ($type as $value) { $series[$value] = $monitorAlarmService->getCount($value); } $output['series'] = $series; Sys_Common::output(true, '', $output); }
public function execute() { $type = $this->getRequest()->getQuery('type', 'click'); $hosts = trim($this->getRequest()->getQuery('host')); $from = strtotime($this->getRequest()->getQuery('from', date('Y-m-d'))); //$to = strtotime($this->getRequest()->getQuery('to')); $output = array(); $this->o = new Model_Alarm_DataNode(); //$analyticsAccessService = new Service_Analytics_Access(); //$systemHostService = new Service_System_Host(); //$hosts = $systemHostService->getHostId($hosts); //$timeZero = strtotime(date('Y-m-d 00:00:00',time())); $c = time(); //if ($type=='conv') $c=time()-1800; $a = $b = $cache = array(); $tag = date('Y-m-d', $from); if ($hosts) { $tag = $tag . '_' . str_replace(',', '_', $hosts); } $cacheFile = "/tmp/" . $type . "_" . $tag; if (file_exists($cacheFile)) { //if (0) { $cacheData = unserialize(file_get_contents($cacheFile)); $t = $from = $cacheData['t']; for ($i = 1; $i <= ($c - $from) / 60; $i++) { $a[] = array("x" => $t * 1000, "y" => $this->getNumByMinute($t, $hosts, $type)); $t += 60; } $a = array_merge($cacheData['a'], $a); $b = $cacheData['b']; } else { $t = $from; for ($i = 1; $i <= ($c - $from) / 60; $i++) { $a[] = array("x" => $t * 1000, "y" => $this->getNumByMinute($t, $hosts, $type)); $t += 60; } $cache['a'] = $a; $cache['t'] = $t; $t = $from; for ($i = 1; $i <= 1440; $i++) { $b[] = array("x" => $t * 1000, "y" => $this->getNumByMinute($t - 86400, $hosts, $type)); //rand(800,1100)); $t += 60; } $cache['b'] = $b; file_put_contents($cacheFile, serialize($cache)); } $output['series'] = array(array("name" => date('Y-m-d', time()), "data" => $a), array("name" => date('Y-m-d', strtotime('-1 day')), "data" => $b)); //$analyticsAccessService->getAccessTrend($hosts, $from, $to); Sys_Common::output(true, '', $output); }
public function execute() { $hosts = trim($this->getRequest()->getQuery('host')); $from = strtotime($this->getRequest()->getQuery('from', date('Y-m-d'))); $to = strtotime($this->getRequest()->getQuery('to')); $output = array(); if (empty($to)) { $to = $from + 86400; } $analyticsAccessService = new Service_Analytics_Access(); $systemHostService = new Service_System_Host(); $hosts = $systemHostService->getHostId($hosts); $output['series'] = $analyticsAccessService->getErrorTopTen($hosts, $from, $to); Sys_Common::output(true, '', $output); }
public function execute() { $index = $this->getRequest()->getQuery("index"); //$host = $this->getRequest()->getQuery('host'); //$path = $this->getRequest()->getQuery('path'); $o = new Model_Alarm_DataNode(); $from = strtotime($this->getRequest()->getQuery('from', date('Y-m-d'))); $to = strtotime($this->getRequest()->getQuery('to')); $to = empty($to) ? $from + 86400 : $to; $output = array(); $r = $o->getClickNum($from, $to); $d = $o->getConvNum($from, $to); $output['series']['pv'] = $r ? $r['num'] : 0; $output['series']['error'] = $d ? $d['num'] : 0; Sys_Common::output(true, '', $output); }
public function configAction() { $type = $this->getRequest()->getQuery('type'); $hosts = trim($this->getRequest()->getQuery('host')); $from = strtotime($this->getRequest()->getQuery('from', date('Y-m-d'))); $to = strtotime($this->getRequest()->getQuery('to')); if (empty($to)) { $to = $from + 86400; $from = $from - 86400; } $output = null; $serviceChartConfig = new Service_Chart_Config(); $systemHostService = new Service_System_Host(); $hosts = $systemHostService->getHostId($hosts); $option = array('from' => $from, 'to' => $to); $output = $serviceChartConfig->get($type, $hosts, $option); Sys_Common::output(true, '', $output); }
public function execute() { $hosts = trim($this->getRequest()->getQuery('host')); $from = strtotime($this->getRequest()->getQuery('from', date('Y-m-d'))); $to = strtotime($this->getRequest()->getQuery('to')); $to = empty($to) ? $to : $from + 86400; $output = array(); $analyticsAccessService = new Service_Analytics_Access(); //$systemHostService = new Service_System_Host(); //$logPersistentService = new Service_Log_Persistent(); // $recordTime = $logPersistentService->getRecordTime('accesslog'); /*if (empty($to) || $to - $from = 86400) { $to = $recordTime - 60; }*/ $output['series'] = $analyticsAccessService->getErrorTrend($hosts, $from, $to); /*array(502=>array( array("time"=>1418601900,"num"=>10,"top"=>array(array('credit.gamelala.com','/hascredit/cache/getAppCredit',1))), array("time"=>1418605900,"num"=>13,"top"=>array(array('credit.gamelala.com','/hascredit/cache/getAppCredit',1))), ));*/ //$analyticsAccessService->getErrorTrend($hosts, $from, $to); Sys_Common::output(true, '', $output); }
public function onlineAction() { $output = null; $uid = $this->getRequest()->getQuery('uid'); $serviceUserOnline = new Service_User_Online(); if (array_key_exists('refresh', $this->params)) { if (empty($uid)) { return false; } $output = $serviceUserOnline->refresh($uid); if ($output) { Sys_Common::output(true, 'refresh success', $output); } else { Sys_Common::output(false, 'refresh failed', $output); } } else { if (array_key_exists('total', $this->params)) { $output = $serviceUserOnline->getTotal(); Sys_Common::output(true, '', $output); } } return false; }
public function execute() { //$this->config = Yaf_Registry::get('monitor_config'); //$this->getMongoObj(); //$this->getCollections(); $hosts = trim($this->getRequest()->getQuery('host')); $time = isset($_GET['current_time']) ? $_GET['current_time'] : time() - 1; $step = isset($_GET['limit']) ? $_GET['limit'] : 60; $q = isset($_GET['q']) ? $_GET['q'] : 1; $startTime = 0; $this->o = new Model_Alarm_DataNode(); /*if ($q <= 1) { $lastTime = $this->getLastTime(); $time = $lastTime - $step - 1; $r = $this->getDataFromMongo($time, $step); } else { $r = $this->getDataFromMongo($time, $step-1); }*/ //if ($r === FALSE) Sys_Common::output(true, 'need try again!'); if ($q <= 1) { $start = $time - 70; } else { $start = $time; } $r = $this->getDataFromMysql($start, $step, $hosts); if ($r === FALSE) { Sys_Common::output(true, 'need try again!'); } $outdata = array('name' => 'access_dynamic', 'series' => null, 'next_time' => null); for ($i = $start; $i < $start + $step; $i++) { $data_tmp['time'] = $i; $data_tmp['num'] = isset($this->D[$i]) ? $this->D[$i]['num'] : 0; $outdata['series'][] = $data_tmp; } $outdata['next_time'] = $i; Sys_Common::output(true, 'OK!', $outdata); }
public function execute() { $index = $this->getRequest()->getQuery("index"); $host = $this->getRequest()->getQuery('host'); $path = $this->getRequest()->getQuery('path'); $to = $hostList = $hostLists = $_path = $re = $hostIds = NULL; $o = new Model_Alarm_DataNode(); // Get the host's ids if ($host) { $theHost = explode(',', $host); foreach ($theHost as $h) { if (is_numeric($h)) { $hid = $o->getHostName($h); $h = $hid['host']; } $hostList .= "'" . $h . "',"; } $hostIds = $o->getHostId(rtrim($hostList, ',')); //foreach($host_ids as $v) { // $hostLists .= "'".$v['host_id']."',"; //} if ($path) { foreach ($theHost as $h) { $re[] = $o->getPathId($h, $path); } $hostIds = $re; } //$_path = isset($path_id['path_id']) ? $path_id['path_id'] : NULL ; } $from = strtotime($this->getRequest()->getQuery('from', date('Y-m-d'))); $to = strtotime($this->getRequest()->getQuery('to')); $output = array(); $startId = $o->getTimeId($from); $endId = $to ? $o->getTimeId($to) : $to; $startId = isset($startId['id']) ? $startId['id'] : 0; $endId = isset($endId['id']) ? $endId['id'] : 0; $index_tmp = explode(",", $index); $indexes = $index_tmp ? $index_tmp : array('pv', 'error'); $peakTMP = $troughTMP = array(); if (in_array('peak', $indexes)) { foreach ($theHost as $h) { $hostIdArr = $o->getHostId("'" . $h . "'"); if (empty($path)) { $key = $from . '_' . $hostIdArr[0]['host_id'] . '_0'; } else { $pathArr = $o->getPathId($h, $path); $key = $from . '_' . $pathArr['host_id'] . '_' . $pathArr['path_id']; //echo 123; //var_dump($pathArr); } //echo $key;echo $path; $dataJSON = $o->getIndexFromCached($key); //var_dump($dataJSON); if ($dataJSON) { $dataCache = json_decode($dataJSON['value'], TRUE); isset($data['sum']) ? $data['sum'] += $dataCache['sum'] : ($data['sum'] = $dataCache['sum']); isset($data['error']) ? $data['error'] += $dataCache['error'] : ($data['error'] = $dataCache['error']); $peakTMP[] = $dataCache['peak']; $troughTMP[] = $dataCache['trough']; } } switch (count($theHost)) { case 1: $peak = array('time' => $peakTMP[0][1], 'num' => $peakTMP[0][0]); $trough = array('time' => $troughTMP[0][1], 'num' => $troughTMP[0][0]); break; case 2: $peakMAX = isset($peakTMP[0], $peakTMP[1]) ? max($peakTMP[0], $peakTMP[1]) : (isset($peakTMP[0]) ? $peakTMP[0] : 0); $troughMIN = isset($troughTMP[0], $troughTMP[1]) ? min($troughTMP[0], $troughTMP[1]) : (isset($troughTMP[0]) ? $troughTMP[0] : 0); $peak = array('time' => $peakMAX[1], 'num' => $peakMAX[0]); $trough = array('time' => $troughMIN[1], 'num' => $troughMIN[0]); break; case 3: $peakMAX = max($peakTMP[0], $peakTMP[1], $peakTMP[2]); $troughMIN = min($troughTMP[0], $troughTMP[1], $peakTMP[2]); $peak = array('time' => $peakMAX[1], 'num' => $peakMAX[0]); $trough = array('time' => $troughMIN[1], 'num' => $troughMIN[0]); break; default: $peak = array('time' => 0, 'num' => 0); $trough = array('time' => 0, 'num' => 0); break; } $output['series']['pv'] = isset($data['sum']) ? $data['sum'] : 0; $output['series']['error'] = isset($data['error']) ? $data['error'] : 0; $output['series']['peak'] = $peak; $output['series']['trough'] = $trough; Sys_Common::output(true, '', $output); exit; } if (in_array('pv', $indexes)) { if ($host) { $r = $o->getIndex($startId, $endId, $hostIds); } else { $r = $o->getIndex($from, $to, $hostIds); } $output['series']['pv'] = isset($r['num']) ? $r['num'] : 0; } if (in_array('error', $indexes)) { $d = $o->getIndexError($startId, $endId, $hostIds); $output['series']['error'] = isset($d['num']) ? $d['num'] : 0; } /*if (in_array('peak',$indexes)) { $max = $o->getIndexPeak($startId, $endId, $hostIds,'max'); $output['series']['peak'] = isset($max['num']) ? array('time'=>$max['time'],'num'=>$max['num']) : 0;//array('time'=>1429501793,'num'=>99);// } if (in_array('trough',$indexes)) { $min = $o->getIndexPeak($startId, $endId, $hostIds,'min'); $output['series']['trough'] = isset($min['num']) ? array('time'=>$min['time'],'num'=>$min['num']) : 0;//array('time'=>1429501793,'num'=>99);// }*/ Sys_Common::output(true, '', $output); }