Added percentile 95º in the stat win of module. TICKET: #2613
This commit is contained in:
parent
5bd2a74910
commit
63498fdbf7
|
@ -435,4 +435,8 @@ define("PAGINATION_BLOCKS_LIMIT", 15);
|
|||
/* CHARTS */
|
||||
define("CHART_DEFAULT_WIDTH", 150);
|
||||
define("CHART_DEFAULT_HEIGHT", 110);
|
||||
|
||||
/* Statwin */
|
||||
define("STATWIN_DEFAULT_CHART_WIDTH", 555);
|
||||
define("STATWIN_DEFAULT_CHART_HEIGHT", 245);
|
||||
?>
|
||||
|
|
|
@ -2471,4 +2471,18 @@ function extract_column ($array, $column) {
|
|||
}, $array);
|
||||
}
|
||||
|
||||
|
||||
function get_percentile($percentile, $array) {
|
||||
sort($array);
|
||||
$index = ($percentile / 100) * count($array);
|
||||
|
||||
if (floor($index) == $index) {
|
||||
$result = ($array[$index-1] + $array[$index]) / 2;
|
||||
}
|
||||
else {
|
||||
$result = $array[floor($index)];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
?>
|
|
@ -230,7 +230,8 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
|
|||
$data, $data_i, $previous_data, $resolution, $interval, $period, $datelimit,
|
||||
$projection, $avg_only = false, $uncompressed_module = false,
|
||||
$show_events = false, $show_alerts = false, $show_unknown = false, $baseline = false,
|
||||
$baseline_data = array(), $events = array(), $series_suffix = '', $start_unknown = false) {
|
||||
$baseline_data = array(), $events = array(), $series_suffix = '', $start_unknown = false,
|
||||
$percentil = null) {
|
||||
|
||||
global $config;
|
||||
global $chart_extra_data;
|
||||
|
@ -460,6 +461,18 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
|
|||
$chart_extra_data[count($chart)-1]['alerts'] = implode(',',$alert_ids);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!is_null($percentil)) {
|
||||
$avg = array_map(function($item) { return $item['sum'];}, $chart);
|
||||
|
||||
$percentil_result = get_percentile($percentil, $avg);
|
||||
|
||||
//Fill the data of chart
|
||||
array_walk($chart, function(&$item) use ($percentil_result, $series_suffix) {
|
||||
$item['percentil' . $series_suffix] = $percentil_result; });
|
||||
$series_type['percentil' . $series_suffix] = 'line';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -468,7 +481,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
|
|||
$show_alerts = false, $avg_only = 0, $date = 0, $unit = '',
|
||||
$baseline = 0, $return_data = 0, $show_title = true, $projection = false,
|
||||
$adapt_key = '', $compare = false, $series_suffix = '', $series_suffix_str = '',
|
||||
$show_unknown = false) {
|
||||
$show_unknown = false, $percentil = null) {
|
||||
|
||||
global $config;
|
||||
global $chart;
|
||||
|
@ -550,13 +563,15 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
|
|||
$data = array ();
|
||||
}
|
||||
|
||||
// Uncompressed module data
|
||||
if ($uncompressed_module) {
|
||||
$min_necessary = 1;
|
||||
|
||||
// Compressed module data
|
||||
if ($uncompressed_module) {
|
||||
// Uncompressed module data
|
||||
|
||||
$min_necessary = 1;
|
||||
}
|
||||
else {
|
||||
// Compressed module data
|
||||
|
||||
// Get previous data
|
||||
$previous_data = modules_get_previous_data ($agent_module_id, $datelimit);
|
||||
if ($previous_data !== false) {
|
||||
|
@ -626,7 +641,10 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
|
|||
$data, $data_i, $previous_data, $resolution, $interval, $period, $datelimit,
|
||||
$projection, $avg_only, $uncompressed_module,
|
||||
$show_events, $show_alerts, $show_unknown, $baseline,
|
||||
$baseline_data, $events, $series_suffix, $start_unknown);
|
||||
$baseline_data, $events, $series_suffix, $start_unknown,
|
||||
$percentil);
|
||||
|
||||
|
||||
|
||||
// Return chart data and don't draw
|
||||
if ($return_data == 1) {
|
||||
|
@ -661,20 +679,27 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
|
|||
// Only show caption if graph is not small
|
||||
if ($width > MIN_WIDTH_CAPTION && $height > MIN_HEIGHT)
|
||||
//Flash chart
|
||||
$caption = __('Max. Value') . $series_suffix_str . ': ' . $graph_stats['sum']['max'] . ' ' . __('Avg. Value').$series_suffix_str . ': ' . $graph_stats['sum']['avg'] . ' ' . __('Min. Value').$series_suffix_str . ': ' . $graph_stats['sum']['min'] . ' ' . __('Units. Value').$series_suffix_str . ': ' . $unit;
|
||||
$caption =
|
||||
__('Max. Value') . $series_suffix_str . ': ' . $graph_stats['sum']['max'] . ' ' .
|
||||
__('Avg. Value') . $series_suffix_str . ': ' . $graph_stats['sum']['avg'] . ' ' .
|
||||
__('Min. Value') . $series_suffix_str . ': ' . $graph_stats['sum']['min'] . ' ' .
|
||||
__('Units. Value') . $series_suffix_str . ': ' . $unit;
|
||||
else
|
||||
$caption = array();
|
||||
|
||||
///////
|
||||
// Color commented not to restrict serie colors
|
||||
if ($show_events) {
|
||||
$color['event'.$series_suffix] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
|
||||
$color['event' . $series_suffix] =
|
||||
array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
|
||||
}
|
||||
if ($show_alerts) {
|
||||
$color['alert'.$series_suffix] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
|
||||
$color['alert' . $series_suffix] =
|
||||
array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
|
||||
}
|
||||
if ($show_unknown) {
|
||||
$color['unknown'.$series_suffix] = array('border' => '#999999', 'color' => '#999999', 'alpha' => 50);
|
||||
$color['unknown' . $series_suffix] =
|
||||
array('border' => '#999999', 'color' => '#999999', 'alpha' => 50);
|
||||
}
|
||||
$color['max'.$series_suffix] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
|
||||
$color['sum'.$series_suffix] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
|
||||
|
@ -708,6 +733,14 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
|
|||
$legend['unknown'.$series_suffix] = __('Unknown').$series_suffix_str;
|
||||
$chart_extra_data['legend_unknown'] = $legend['unknown'.$series_suffix_str];
|
||||
}
|
||||
|
||||
if (!is_null($percentil)) {
|
||||
$first_data = reset($chart);
|
||||
$percentil_value = format_for_graph($first_data['percentil'], 2);
|
||||
|
||||
$legend['percentil'.$series_suffix] = __('Percentile %dº', $percentil) .$series_suffix_str . " (" . $percentil_value . " " . $unit . ") ";
|
||||
$chart_extra_data['legend_percentil'] = $legend['percentil'.$series_suffix_str];
|
||||
}
|
||||
}
|
||||
|
||||
function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
||||
|
@ -716,7 +749,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
$unit = '', $baseline = 0, $return_data = 0, $show_title = true,
|
||||
$only_image = false, $homeurl = '', $ttl = 1, $projection = false,
|
||||
$adapt_key = '', $compare = false, $show_unknown = false,
|
||||
$menu = true, $backgroundColor = 'white') {
|
||||
$menu = true, $backgroundColor = 'white', $percentil = null) {
|
||||
|
||||
global $config;
|
||||
global $graphic_type;
|
||||
|
@ -747,7 +780,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
$show_alerts, $avg_only, $date-$period, $unit, $baseline,
|
||||
$return_data, $show_title, $projection, $adapt_key,
|
||||
$compare, $series_suffix, $series_suffix_str,
|
||||
$show_unknown);
|
||||
$show_unknown, $percentil);
|
||||
|
||||
|
||||
|
||||
switch ($compare) {
|
||||
case 'separated':
|
||||
|
@ -773,13 +808,16 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Build the data of the current period
|
||||
$data_returned = grafico_modulo_sparse_data ($agent_module_id,
|
||||
$period, $show_events,
|
||||
$width, $height , $title, $unit_name,
|
||||
$show_alerts, $avg_only,
|
||||
$date, $unit, $baseline, $return_data, $show_title,
|
||||
$projection, $adapt_key, $compare, '', '', $show_unknown);
|
||||
$projection, $adapt_key, $compare, '', '', $show_unknown,
|
||||
$percentil);
|
||||
|
||||
|
||||
if ($return_data) {
|
||||
return $data_returned;
|
||||
|
|
|
@ -214,6 +214,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color,
|
|||
$red_threshold = 0, $adapt_key = '', $force_integer = false,
|
||||
$series_suffix_str = '', $menu = true, $backgroundColor = 'white') {
|
||||
|
||||
|
||||
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
|
||||
|
||||
// ATTENTION: The min size is in constants.php
|
||||
|
|
|
@ -607,10 +607,16 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
|
|||
});
|
||||
|
||||
switch (serie_types[i]) {
|
||||
case 'area':
|
||||
line_show = true;
|
||||
points_show = false;
|
||||
filled = true;
|
||||
break;
|
||||
case 'line':
|
||||
default:
|
||||
line_show = true;
|
||||
points_show = false;
|
||||
filled = false;
|
||||
break;
|
||||
case 'points':
|
||||
line_show = false;
|
||||
|
|
|
@ -161,6 +161,7 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend,
|
|||
|
||||
global $config;
|
||||
|
||||
|
||||
include_javascript_dependencies_flot_graph();
|
||||
|
||||
$font_size = '7';
|
||||
|
@ -269,13 +270,25 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend,
|
|||
foreach($values as $key => $value) {
|
||||
$jsvar = "data_" . $graph_id . "_" . $key;
|
||||
|
||||
|
||||
if (!isset($serie_types[$key])) {
|
||||
switch ($type) {
|
||||
case 'line_simple':
|
||||
case 'line_stacked':
|
||||
$serie_types2[$jsvar] = 'line';
|
||||
break;
|
||||
case 'area_simple':
|
||||
case 'area_stacked':
|
||||
default:
|
||||
$serie_types2[$jsvar] = 'area';
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$serie_types2[$jsvar] = $serie_types[$key];
|
||||
}
|
||||
|
||||
|
||||
if ($serie_types2[$jsvar] == 'points' && $value == 0) {
|
||||
$data[$jsvar][] = 'null';
|
||||
}
|
||||
|
@ -384,32 +397,32 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend,
|
|||
$return .= "<script type='text/javascript'>";
|
||||
$return .= "//<![CDATA[\n";
|
||||
$return .= "pandoraFlotArea(" .
|
||||
"'$graph_id', " .
|
||||
"'$values', " .
|
||||
"'$labels', " .
|
||||
"'$labels_long', " .
|
||||
"'$legend', " .
|
||||
"'$colors', " .
|
||||
"'$type', " .
|
||||
"'$serie_types', " .
|
||||
"$watermark, " .
|
||||
"$width, " .
|
||||
"$max_x, " .
|
||||
"'" . $homeurl . "', " .
|
||||
"'$unit', " .
|
||||
"$font_size, " .
|
||||
"$menu, " .
|
||||
"'$events', " .
|
||||
"'$event_ids', " .
|
||||
"'$legend_events', " .
|
||||
"'$alerts', " .
|
||||
"'$alert_ids', " .
|
||||
"'$legend_alerts', " .
|
||||
"'$yellow_threshold', " .
|
||||
"'$red_threshold', " .
|
||||
"$force_integer, " .
|
||||
"'$separator', " .
|
||||
"'$separator2', " .
|
||||
"'$graph_id', \n" .
|
||||
"'$values', \n" .
|
||||
"'$labels', \n" .
|
||||
"'$labels_long', \n" .
|
||||
"'$legend', \n" .
|
||||
"'$colors', \n" .
|
||||
"'$type', \n" .
|
||||
"'$serie_types', \n" .
|
||||
"$watermark, \n" .
|
||||
"$width, \n" .
|
||||
"$max_x, \n" .
|
||||
"'" . $homeurl . "', \n" .
|
||||
"'$unit', \n" .
|
||||
"$font_size, \n" .
|
||||
"$menu, \n" .
|
||||
"'$events', \n" .
|
||||
"'$event_ids', \n" .
|
||||
"'$legend_events', \n" .
|
||||
"'$alerts', \n" .
|
||||
"'$alert_ids', \n" .
|
||||
"'$legend_alerts', \n" .
|
||||
"'$yellow_threshold', \n" .
|
||||
"'$red_threshold', \n" .
|
||||
"$force_integer, \n" .
|
||||
"'$separator', \n" .
|
||||
"'$separator2', \n" .
|
||||
"'$series_suffix_str');";
|
||||
$return .= "\n//]]>";
|
||||
$return .= "</script>";
|
||||
|
|
|
@ -116,7 +116,8 @@ $id = get_parameter('id');
|
|||
// ACL
|
||||
$permission = false;
|
||||
$agent_group = (int) agents_get_agent_group($agent_id);
|
||||
$strict_user = (bool) db_get_value("strict_acl", "tusuario", "id_user", $config['id_user']);
|
||||
$strict_user = (bool) db_get_value("strict_acl", "tusuario",
|
||||
"id_user", $config['id_user']);
|
||||
|
||||
if (!empty($agent_group)) {
|
||||
if ($strict_user) {
|
||||
|
@ -140,8 +141,8 @@ $id = get_parameter('id');
|
|||
}
|
||||
$period = get_parameter ("period", SECONDS_1DAY);
|
||||
$id = get_parameter ("id", 0);
|
||||
$width = get_parameter ("width", 555);
|
||||
$height = get_parameter ("height", 245);
|
||||
$width = get_parameter ("width", STATWIN_DEFAULT_CHART_WIDTH);
|
||||
$height = get_parameter ("height", STATWIN_DEFAULT_CHART_HEIGHT);
|
||||
$label = get_parameter ("label", "");
|
||||
$start_date = get_parameter ("start_date", date("Y/m/d"));
|
||||
$start_time = get_parameter ("start_time", date("H:i:s"));
|
||||
|
@ -150,6 +151,7 @@ $id = get_parameter('id');
|
|||
$zoom = get_parameter ("zoom", 1);
|
||||
$baseline = get_parameter ("baseline", 0);
|
||||
$show_events_graph = get_parameter ("show_events_graph", 0);
|
||||
$show_percentil_95 = get_parameter ("show_percentil_95", 0);
|
||||
$time_compare_separated = get_parameter ("time_compare_separated", 0);
|
||||
$time_compare_overlapped = get_parameter ("time_compare_overlapped", 0);
|
||||
$unknown_graph = get_parameter_checkbox ("unknown_graph", 1);
|
||||
|
@ -190,33 +192,46 @@ $id = get_parameter('id');
|
|||
|
||||
switch ($graph_type) {
|
||||
case 'boolean':
|
||||
echo grafico_modulo_boolean ($id, $period, $draw_events, $width, $height,
|
||||
$label, $unit, $draw_alerts, $avg_only, false, $date, false, $urlImage, 'adapter_'.$graph_type, $time_compare, $unknown_graph);
|
||||
echo grafico_modulo_boolean ($id, $period, $draw_events,
|
||||
$width, $height, $label, $unit, $draw_alerts,
|
||||
$avg_only, false, $date, false, $urlImage,
|
||||
'adapter_' . $graph_type, $time_compare,
|
||||
$unknown_graph);
|
||||
echo '<br>';
|
||||
if ($show_events_graph)
|
||||
echo graphic_module_events($id, $width, $height,
|
||||
$period, $config['homeurl'], $zoom, 'adapted_'.$graph_type, $date);
|
||||
$period, $config['homeurl'], $zoom,
|
||||
'adapted_' . $graph_type, $date);
|
||||
break;
|
||||
case 'sparse':
|
||||
echo grafico_modulo_sparse ($id, $period, $draw_events, $width, $height,
|
||||
$label, $unit, $draw_alerts, $avg_only, false, $date, $unit, $baseline,
|
||||
0, true, false, $urlImage, 1, false, 'adapter_'.$graph_type, $time_compare, $unknown_graph);
|
||||
echo grafico_modulo_sparse ($id, $period, $draw_events,
|
||||
$width, $height, $label, $unit, $draw_alerts,
|
||||
$avg_only, false, $date, $unit, $baseline, 0, true,
|
||||
false, $urlImage, 1, false,
|
||||
'adapter_' . $graph_type, $time_compare,
|
||||
$unknown_graph, true, 'white',
|
||||
(($show_percentil_95)? 95 : null));
|
||||
echo '<br>';
|
||||
if ($show_events_graph)
|
||||
echo graphic_module_events($id, $width, $height,
|
||||
$period, $config['homeurl'], $zoom, 'adapted_'.$graph_type, $date);
|
||||
$period, $config['homeurl'], $zoom,
|
||||
'adapted_' . $graph_type, $date);
|
||||
break;
|
||||
case 'string':
|
||||
echo grafico_modulo_string ($id, $period, $draw_events, $width, $height,
|
||||
$label, null, $draw_alerts, 1, false, $date, false, $urlImage, 'adapter_'.$graph_type);
|
||||
echo grafico_modulo_string ($id, $period, $draw_events,
|
||||
$width, $height, $label, null, $draw_alerts, 1,
|
||||
false, $date, false, $urlImage,
|
||||
'adapter_' . $graph_type);
|
||||
echo '<br>';
|
||||
if ($show_events_graph)
|
||||
echo graphic_module_events($id, $width, $height,
|
||||
$period, $config['homeurl'], $zoom, 'adapted_'.$graph_type, $date);
|
||||
$period, $config['homeurl'], $zoom,
|
||||
'adapted_' . $graph_type, $date);
|
||||
break;
|
||||
case 'log4x':
|
||||
echo grafico_modulo_log4x ($id, $period, $draw_events, $width, $height,
|
||||
$label, $unit, $draw_alerts, 1, $pure, $date);
|
||||
echo grafico_modulo_log4x ($id, $period, $draw_events,
|
||||
$width, $height, $label, $unit, $draw_alerts, 1,
|
||||
$pure, $date);
|
||||
echo '<br>';
|
||||
if ($show_events_graph)
|
||||
echo graphic_module_events($id, $width, $height,
|
||||
|
@ -339,10 +354,15 @@ $id = get_parameter('id');
|
|||
$table->data[] = $data;
|
||||
$table->rowclass[] = '';
|
||||
|
||||
|
||||
switch ($graph_type) {
|
||||
case 'boolean':
|
||||
case 'sparse':
|
||||
$data = array();
|
||||
$data[0] = __('Show percentil 95º');
|
||||
$data[1] = html_print_checkbox ("show_percentil_95", 1, (bool) $show_percentil_95, true);
|
||||
$table->data[] = $data;
|
||||
$table->rowclass[] ='';
|
||||
|
||||
$data = array();
|
||||
$data[0] = __('Time compare (Overlapped)');
|
||||
$data[1] = html_print_checkbox ("time_compare_overlapped", 1, (bool) $time_compare_overlapped, true);
|
||||
|
|
Loading…
Reference in New Issue