From 264155530bd8b553f0e37e4419c3b4350b57d722 Mon Sep 17 00:00:00 2001 From: zarzuelo <zarzuelo@gmail.com> Date: Wed, 21 May 2014 14:04:27 +0000 Subject: [PATCH] 2014-05-21 Sergio Martin <sergio.martin@artica.es> * include/functions_graph.php: Fix unknown graphs in graphs with only negative values. Now the unknown graph is always positive Ticket: #569 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@9979 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 6 ++++++ pandora_console/include/functions_graph.php | 18 +++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 7a54b323e2..c10922f858 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,9 @@ +2014-05-21 Sergio Martin <sergio.martin@artica.es> + + * include/functions_graph.php: Fix unknown graphs in graphs + with only negative values. Now the unknown graph is always positive + Ticket: #569 + 2014-05-22 Vanessa Gil <vanessa.gil@artica.es> * godmode/servers/manage_recontask.php diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index b468249788..bfa23c0498 100755 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -237,8 +237,10 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i global $chart_extra_data; global $series_type; global $max_value; + global $min_value; $max_value = 0; + $min_value = null; $flash_chart = $config['flash_charts']; // Event iterator @@ -281,6 +283,10 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i $max_value = $interval_max; } + if ($min_value > $interval_max || $min_value == null) { + $min_value = $interval_max; + } + // Data in the interval if ($count > 0) { $total /= $count; @@ -473,6 +479,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, global $critical_min; global $graphic_type; global $max_value; + global $min_value; $chart = array(); @@ -626,7 +633,16 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, $graph_stats = get_statwin_graph_statistics($chart, $series_suffix); // Fix event and alert scale - $event_max = 2 + (float)$max_value * 1.05; + if ($max_value > 0) { + $event_max = 2 + (float)$max_value * 1.05; + } + else { + $event_max = abs(($max_value+$min_value)/2); + if ($event_max < 5) { + $event_max = 5; + } + } + foreach ($chart as $timestamp => $chart_data) { if ($show_events && $chart_data['event'.$series_suffix] > 0) { $chart[$timestamp]['event'.$series_suffix] = $event_max * 1.2;