From 26a9477ef3a9d419f84fc2510c6592128590ea26 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Wed, 5 Dec 2012 11:41:52 +0000 Subject: [PATCH] 2012-12-05 Sergio Martin * include/functions_graph.php: Fix a statistics bug on compared graphs merged from 4.0.x git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7228 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 5 ++++ pandora_console/include/functions_graph.php | 31 ++++++++++++--------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 2d69b8af55..9294b9fd15 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,8 @@ +2012-12-05 Sergio Martin + + * include/functions_graph.php: Fix a statistics bug on + compared graphs merged from 4.0.x + 2012-12-04 Sergio Martin * extensions/dbmanager.php diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 85ed6e0a1b..af209966ea 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -84,7 +84,7 @@ function get_graph_statistics ($chart_array) { return $stats; } -function get_statwin_graph_statistics ($chart_array) { +function get_statwin_graph_statistics ($chart_array, $series_suffix = '') { /// IMPORTANT! /// @@ -104,6 +104,12 @@ function get_statwin_graph_statistics ($chart_array) { $stats['max'] = array ("avg" => 0, "min" => null, "max" => null, "last" => 0); foreach ($chart_array as $item) { + if($series_suffix != '') { + $item['sum'] = $item['sum'.$series_suffix]; + $item['min'] = $item['min'.$series_suffix]; + $item['max'] = $item['max'.$series_suffix]; + } + //Get stats for normal grap if (isset($item['sum']) && $item['sum']) { //Sum all values later divide by the number of elements @@ -118,11 +124,10 @@ function get_statwin_graph_statistics ($chart_array) { //Get maximum if ($stats['sum']['max'] == null) { - $stats['sum']['max'] = $item['sum']; - } else if ($item['sum'] > $stats['sum']['max']) { - $stats['sum']['max'] = $item['sum']; - } - + $stats['sum']['max'] = $item['sum']; + } else if ($item['sum'] > $stats['sum']['max']) { + $stats['sum']['max'] = $item['sum']; + } } //Get stats for min graph @@ -602,7 +607,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, return $chart; } - $graph_stats = get_statwin_graph_statistics($chart); + $graph_stats = get_statwin_graph_statistics($chart, $series_suffix); // Fix event and alert scale $event_max = 2 + (float)$max_value * 1.05; @@ -2451,14 +2456,14 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, } else { $chart[$timestamp]['sum'.$series_suffix] = $total; - $chart[$timestamp + 1] = array ('sum' => 0, + $chart[$timestamp + 1] = array ('sum'.$series_suffix => 0, //'count' => 0, //'timestamp_bottom' => $timestamp, //'timestamp_top' => $timestamp + $interval, - 'min' => 0, - 'max' => 0, - 'event' => $event_value, - 'alert' => $alert_value); + 'min'.$series_suffix => 0, + 'max'.$series_suffix => 0, + 'event'.$series_suffix => $event_value, + 'alert'.$series_suffix => $alert_value); } $previous_data = 0; } @@ -2495,7 +2500,7 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events, } // Get min, max and avg (less efficient but centralized for all modules and reports) - $graph_stats = get_statwin_graph_statistics($chart); + $graph_stats = get_statwin_graph_statistics($chart, $series_suffix); // Fix event and alert scale foreach ($chart as $timestamp => $chart_data) {