|
@@ -12,17 +12,21 @@ function main($module, $interface, $date, $offset)
|
|
|
$all_st_str .= $st_str;
|
|
$all_st_str .= $st_str;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- $data = formatSt($all_st_str, $date);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ $code_map = array();
|
|
|
|
|
+ $data = formatSt($all_st_str, $date, $code_map);
|
|
|
$interface_name = '整体';
|
|
$interface_name = '整体';
|
|
|
$success_series_data = $fail_series_data = $success_time_series_data = $fail_time_series_data = array();
|
|
$success_series_data = $fail_series_data = $success_time_series_data = $fail_time_series_data = array();
|
|
|
|
|
+ $total_count = $fail_count = 0;
|
|
|
foreach($data as $time_point=>$item)
|
|
foreach($data as $time_point=>$item)
|
|
|
{
|
|
{
|
|
|
if($item['total_count'])
|
|
if($item['total_count'])
|
|
|
{
|
|
{
|
|
|
$success_series_data[] = "[".($time_point*1000).",{$item['total_count']}]";
|
|
$success_series_data[] = "[".($time_point*1000).",{$item['total_count']}]";
|
|
|
|
|
+ $total_count += $item['total_count'];
|
|
|
}
|
|
}
|
|
|
$fail_series_data[] = "[".($time_point*1000).",{$item['fail_count']}]";
|
|
$fail_series_data[] = "[".($time_point*1000).",{$item['fail_count']}]";
|
|
|
|
|
+ $fail_count += $item['fail_count'];
|
|
|
if($item['total_avg_time'])
|
|
if($item['total_avg_time'])
|
|
|
{
|
|
{
|
|
|
$success_time_series_data[] = "[".($time_point*1000).",{$item['total_avg_time']}]";
|
|
$success_time_series_data[] = "[".($time_point*1000).",{$item['total_avg_time']}]";
|
|
@@ -33,6 +37,86 @@ function main($module, $interface, $date, $offset)
|
|
|
$fail_series_data = implode(',', $fail_series_data);
|
|
$fail_series_data = implode(',', $fail_series_data);
|
|
|
$success_time_series_data = implode(',', $success_time_series_data);
|
|
$success_time_series_data = implode(',', $success_time_series_data);
|
|
|
$fail_time_series_data = implode(',', $fail_time_series_data);
|
|
$fail_time_series_data = implode(',', $fail_time_series_data);
|
|
|
|
|
+
|
|
|
|
|
+ // 总体成功率
|
|
|
|
|
+ $global_rate = $total_count ? round((($total_count - $fail_count)/$total_count)*100, 4) : 100;
|
|
|
|
|
+ // 返回码分布
|
|
|
|
|
+ $code_pie_data = '';
|
|
|
|
|
+ $code_pie_array = array();
|
|
|
|
|
+ if(is_array($code_map))
|
|
|
|
|
+ {
|
|
|
|
|
+ $total_item_count = array_sum($code_map);
|
|
|
|
|
+ foreach($code_map as $code=>$count)
|
|
|
|
|
+ {
|
|
|
|
|
+ $code_pie_array[] = "[\"$code\", ".round($count*100/$total_item_count, 4)."]";
|
|
|
|
|
+ }
|
|
|
|
|
+ $code_pie_data = implode(',', $code_pie_array);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ unset($_GET['start_time'], $_GET['end_time'], $_GET['date']);
|
|
|
|
|
+ $query = http_build_query($_GET);
|
|
|
|
|
+
|
|
|
|
|
+ $table_data = '';
|
|
|
|
|
+ if($data)
|
|
|
|
|
+ {
|
|
|
|
|
+ $first_line = true;
|
|
|
|
|
+ foreach($data as $item)
|
|
|
|
|
+ {
|
|
|
|
|
+ if($first_line)
|
|
|
|
|
+ {
|
|
|
|
|
+ $first_line = false;
|
|
|
|
|
+ if($item['total_count'] == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $html_class = 'class="danger"';
|
|
|
|
|
+ if($item['total_count'] == 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ $html_class = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ elseif($item['precent']>=99.99)
|
|
|
|
|
+ {
|
|
|
|
|
+ $html_class = 'class="success"';
|
|
|
|
|
+ }
|
|
|
|
|
+ elseif($item['precent']>=99)
|
|
|
|
|
+ {
|
|
|
|
|
+ $html_class = '';
|
|
|
|
|
+ }
|
|
|
|
|
+ elseif($item['precent']>=98)
|
|
|
|
|
+ {
|
|
|
|
|
+ $html_class = 'class="warning"';
|
|
|
|
|
+ }
|
|
|
|
|
+ $table_data .= "\n<tr $html_class>
|
|
|
|
|
+ <td>{$item['time']}</td>
|
|
|
|
|
+ <td>{$item['total_count']}</td>
|
|
|
|
|
+ <td> {$item['total_avg_time']}</td>
|
|
|
|
|
+ <td>{$item['suc_count']}</td>
|
|
|
|
|
+ <td>{$item['suc_avg_time']}</td>
|
|
|
|
|
+ <td>".($item['fail_count']>0?("<a href='/?fn=log&$query&start_time=".strtotime($item['time'])."&end_time=".(strtotime($item['time'])+300)."'>{$item['fail_count']}</a>"):$item['fail_count'])."</td>
|
|
|
|
|
+ <td>{$item['fail_avg_time']}</td>
|
|
|
|
|
+ <td>{$item['precent']}%</td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ ";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // date btn
|
|
|
|
|
+ $date_btn_str = '';
|
|
|
|
|
+ for($i=13;$i>=1;$i--)
|
|
|
|
|
+ {
|
|
|
|
|
+ $the_time = strtotime("-$i day");
|
|
|
|
|
+ $the_date = date('Y-m-d',$the_time);
|
|
|
|
|
+ $html_the_date = $date == $the_date ? "<b>$the_date</b>" : $the_date;
|
|
|
|
|
+ $date_btn_str .= '<a href="/?date='."$the_date&$query".'" class="btn '.$html_class.'" type="button">'.$html_the_date.'</a>';
|
|
|
|
|
+ if($i == 7)
|
|
|
|
|
+ {
|
|
|
|
|
+ $date_btn_str .= '</br>';
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $the_date = date('Y-m-d');
|
|
|
|
|
+ $html_the_date = $date == $the_date ? "<b>$the_date</b>" : $the_date;
|
|
|
|
|
+ $date_btn_str .= '<a href="/?date='."$the_date&$query".'" class="btn" type="button">'.$html_the_date.'</a>';
|
|
|
|
|
|
|
|
include ST_ROOT . '/Views/header.tpl.php';
|
|
include ST_ROOT . '/Views/header.tpl.php';
|
|
|
include ST_ROOT . '/Views/main.tpl.php';
|
|
include ST_ROOT . '/Views/main.tpl.php';
|
|
@@ -73,10 +157,10 @@ function multiRequestStAndModules($module, $interface, $date)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function formatSt($str, $date)
|
|
|
|
|
|
|
+function formatSt($str, $date, &$code_map)
|
|
|
{
|
|
{
|
|
|
// time:[suc_count:xx,suc_cost_time:xx,fail_count:xx,fail_cost_time:xx]
|
|
// time:[suc_count:xx,suc_cost_time:xx,fail_count:xx,fail_cost_time:xx]
|
|
|
- $st_data = array();
|
|
|
|
|
|
|
+ $st_data = $code_map = array();
|
|
|
$st_explode = explode("\n", $str);
|
|
$st_explode = explode("\n", $str);
|
|
|
// 汇总计算
|
|
// 汇总计算
|
|
|
foreach($st_explode as $line)
|
|
foreach($st_explode as $line)
|
|
@@ -93,6 +177,7 @@ function formatSt($str, $date)
|
|
|
$suc_cost_time = $line_data[3];
|
|
$suc_cost_time = $line_data[3];
|
|
|
$fail_count = $line_data[4];
|
|
$fail_count = $line_data[4];
|
|
|
$fail_cost_time = $line_data[5];
|
|
$fail_cost_time = $line_data[5];
|
|
|
|
|
+ $tmp_code_map = json_decode($line_data[6], true);
|
|
|
if(!isset($st_data[$time_line]))
|
|
if(!isset($st_data[$time_line]))
|
|
|
{
|
|
{
|
|
|
$st_data[$time_line] = array('suc_count'=>0, 'suc_cost_time'=>0, 'fail_count'=>0, 'fail_cost_time'=>0);
|
|
$st_data[$time_line] = array('suc_count'=>0, 'suc_cost_time'=>0, 'fail_count'=>0, 'fail_cost_time'=>0);
|
|
@@ -101,6 +186,18 @@ function formatSt($str, $date)
|
|
|
$st_data[$time_line]['suc_cost_time'] += $suc_cost_time;
|
|
$st_data[$time_line]['suc_cost_time'] += $suc_cost_time;
|
|
|
$st_data[$time_line]['fail_count'] += $fail_count;
|
|
$st_data[$time_line]['fail_count'] += $fail_count;
|
|
|
$st_data[$time_line]['fail_cost_time'] += $fail_cost_time;
|
|
$st_data[$time_line]['fail_cost_time'] += $fail_cost_time;
|
|
|
|
|
+
|
|
|
|
|
+ if(is_array($tmp_code_map))
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach($tmp_code_map as $code=>$count)
|
|
|
|
|
+ {
|
|
|
|
|
+ if(!isset($code_map[$code]))
|
|
|
|
|
+ {
|
|
|
|
|
+ $code_map[$code] = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ $code_map[$code] += $count;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
// 按照时间排序
|
|
// 按照时间排序
|
|
|
ksort($st_data);
|
|
ksort($st_data);
|