Exemple #1
0
 public function run()
 {
     $model = new Model_ReportApi_Accesslog();
     $hosts = $model->getBusiness();
     $day = strtotime($this->getRequest()->getQuery('from', date('Y-m-d')));
     $where = " and `time`={$day} ";
     $where .= empty($hosts) ? '' : " AND `host_id` in ({$hosts})";
     $res = $model->rtcTopTen($where);
     //        print_r($res);exit;
     //        $result['name'] = 'rtcTopTen';
     $result = array();
     foreach ($res as $value) {
         $result['series'][] = array('ip' => long2ip($value['ip']), 'name' => ucwords(strtolower($model->ip2location($value['ip']))), 'second' => $value['total_request_time'], 'path' => $value['path'], 'host' => $value['host']);
     }
     //        print_r($result);exit;
     if (empty($res)) {
         static::output(0, 'no data', array());
     } else {
         static::output(1, 'RtcTopTen', $result);
     }
     //      测试数据
     //        $result['series'] = array(
     //            array('ip'     => '172.30.10.222',
     //            'name'   => 'china',
     //            'second' => '1123',
     //            'path' => '/root'
     //            ),
     //            array('ip'     => '192.40.30.222',
     //                'name'   => 'USA',
     //                'second' => '1589',
     //                'path' => '/usr/local'
     //            ),
     //        );
     //        static::output(1,'RtcTopTen',$result);
 }
Exemple #2
0
 public function run()
 {
     $model = new Model_ReportApi_Accesslog();
     $hosts = $model->getBusiness();
     $day = strtotime($this->getRequest()->getQuery('from', date('Y-m-d')));
     //        echo $this->getRequest()->getQuery('from', date('Y-m-d'));exit;
     $where = "WHERE `time`= {$day} ";
     $where .= empty($hosts) ? '' : " AND `host_id` in ({$hosts})";
     $res = $model->mapStatisticsTopTen($where);
     //        print_r($res);exit;
     $result = array();
     foreach ($res as $val) {
         $result['series'][] = array('code' => $val['country_code'], 'name' => $val['country_name'], 'num' => $val['num']);
     }
     if (empty($res)) {
         static::output(0, 'no data', array());
     } else {
         static::output(1, 'RgTopTen', $result);
     }
     //测试数据
     //        $result['series'] = array(
     //            array('code' =>425,
     //            'name' => 'china',
     //            'num'  => 123),
     //            array('code' =>435,
     //                'name' => 'USA',
     //                'num'  => 45),
     //        );
     //        static::output(1, 'RgTopTen',$result);
     //        return $result;
 }
Exemple #3
0
 public function run()
 {
     $model = new Model_ReportApi_Accesslog();
     $hosts = $model->getBusiness();
     $day = strtotime($this->getRequest()->getQuery('from', date('Y-m-d 00:00:00')));
     $where = "WHERE `time`= {$day}";
     $where .= empty($hosts) ? '' : " AND `host_id` in ({$hosts})";
     $res = $model->mapRequestTime($where);
     $country = $model->globalCountry();
     foreach ($country as $v) {
         $result['series'][$v['code']] = array('code' => $v['code'], 'avg_request_time' => 0, 'max_request_time' => 0, 'name' => $v['name']);
     }
     foreach ($res as $val) {
         $result['series'][$val['country_code']] = array('code' => $val['country_code'], 'avg_request_time' => number_format($val['total_request_time'] / $val['num'], 3), 'max_request_time' => $val['max_request_time'], 'name' => $val['country_name']);
     }
     static::output(1, 'ResponseTimeMap', $result);
 }
Exemple #4
0
 public function run()
 {
     $model = new Model_ReportApi_Accesslog();
     $hosts = $model->getBusiness();
     $from = strtotime($this->getRequest()->getQuery('from', date('Y-m-d')));
     $to = $from + 86400;
     //        echo $from;
     //        exit;
     $where = " AND `time`< {$to} AND time > {$from} AND status >= 400";
     //		$where          = " AND status != 200";
     $where .= empty($hosts) ? '' : " AND `host_id` in ({$hosts})";
     //        $result['name'] = 'errorTopTen';
     $result['series'] = $model->errorTopTen($where);
     //        print_r($model->errorTopTen($where)); exit;
     if ($result['series']) {
         static::output(1, 'ErrorTopTen', $result);
     } else {
         static::output(0, 'no data', array());
     }
 }
Exemple #5
0
 public function run()
 {
     $model = new Model_ReportApi_Accesslog();
     $hosts = $model->getBusiness();
     $from = strtotime($this->getRequest()->getQuery('from', date('Y-m-d 00:00:00')));
     $to = $from + 86400;
     $where = "WHERE `time` >= {$from}";
     if ($from && $from != strtotime(date('Y-m-d 00:00:00'))) {
         $where = "WHERE `time` >= {$from} AND `time`< {$to} ";
     }
     $codestr = implode(',', $this->code);
     $where .= " AND status in (" . $codestr . ")";
     $where .= empty($hosts) ? '' : " AND `host_id` in ({$hosts})";
     $res = $model->getErrorTrend($where);
     $data = $datatmp = array();
     $minute = $tmpminute = 0;
     foreach ($res as $val) {
         $status = $val['status'];
         $minute = $val['time'];
         isset($data[$minute][$status]['num']) ? $data[$minute][$status]['num'] += $val['num'] : ($data[$minute][$status]['num'] = $val['num']);
         $data[$minute][$status]['top'][$val['num']] = array($val['host'], $val['path'], $val['num']);
         if ($tmpminute != 0 and $tmpminute < $minute) {
             foreach ($this->code as $v) {
                 $num = isset($data[$tmpminute][$v]['num']) ? $data[$tmpminute][$v]['num'] : 0;
                 $t = isset($data[$tmpminute][$v]['top']) ? $data[$tmpminute][$v]['top'] : array();
                 krsort($t);
                 $top = array_slice($t, 0, 3);
                 $datatmp[$v][] = array("time" => $tmpminute, "num" => $num, "top" => $top);
                 unset($t, $top);
             }
         }
         $tmpminute = $minute;
     }
     $result['series'] = $datatmp;
     if ($data) {
         static::output(1, 'errorTrend', $result);
     } else {
         static::output(0, 'no data', array());
     }
     //return $result;
 }
Exemple #6
0
 public function run()
 {
     $model = new Model_ReportApi_Accesslog();
     $hosts = $model->getBusiness();
     $todayOnly = $this->getRequest()->getQuery("todayOnly", 0);
     $from = strtotime($this->getRequest()->getQuery('from', date('Y-m-d')));
     $current = strtotime(date('Y-m-d'));
     $record = $model->getAccessRecord();
     if ($from == $current) {
         $to = strtotime(date('Y-m-d H:i', $record));
     } else {
         $to = $from + 86400;
     }
     $yesterday = $from - 86400;
     $where = "WHERE `time`> {$from} AND `time` <= {$to} ";
     $where .= empty($hosts) ? '' : " AND `host_id` in ({$hosts})";
     $output = array();
     $result = $model->getAccessTrend($where);
     $today_array = array();
     foreach ($result as $value) {
         $today_array[] = array('time' => $value['time'], 'num' => $value['num']);
     }
     if ($todayOnly) {
         $output['series'] = array('toDay' => $today_array);
     } else {
         $yesterday_array = array();
         $yestoday_where = "WHERE `time` > {$yesterday} AND `time`<= {$from}";
         $yestoday_where .= empty($hosts) ? '' : " AND `host_id` in ({$hosts})";
         $yesterday_result = $model->getAccessTrend($yestoday_where);
         foreach ($yesterday_result as $value) {
             //此处+86400为前端方便显示两天对比的值
             $yesterday_array[] = array('time' => $value['time'] + 86400, 'num' => $value['num']);
         }
         $output['series'] = array('toDay' => $today_array, 'yestDay' => $yesterday_array);
     }
     //print_r($output);
     //return $output;
     //此处做判断数据是否有
     static::output(1, 'AccessTrend', $output);
 }