From fd21b281c7da59d221e5c4080f3ea0aabb39fe9a Mon Sep 17 00:00:00 2001 From: Arturo Gonzalez Date: Mon, 28 Nov 2016 10:53:05 +0100 Subject: [PATCH] Added threshold graph to interface monitors graph (Only when monitors have the same warning or critical min value). Ticket #4113 (cherry picked from commit 2391e7ae7827eaae7ff73f2377e89bbc70fc2848) Conflicts resolved: pandora_console/operation/agentes/interface_traffic_graph_win.php --- .../include/functions_custom_graphs.php | 3 +- pandora_console/include/functions_graph.php | 42 ++++++++++++++++++- pandora_console/include/graphs/fgraph.php | 6 +-- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php index 56bd46696b..f05428a3be 100644 --- a/pandora_console/include/functions_custom_graphs.php +++ b/pandora_console/include/functions_custom_graphs.php @@ -255,7 +255,8 @@ function custom_graphs_print($id_graph, $height, $width, $period, $labels, $dashboard, $vconsole, - $percentil); + $percentil, + $from_interface); if ($return) return $output; diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 2a8a55b49f..48c9f4f9d2 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -973,7 +973,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, $prediction_period = false, $background_color = 'white', $name_list = array(), $unit_list = array(), $show_last = true, $show_max = true, $show_min = true, $show_avg = true, $labels = array(), $dashboard = false, - $vconsole = false, $percentil = null) { + $vconsole = false, $percentil = null, $from_interface = false) { global $config; global $graphic_type; @@ -1707,6 +1707,44 @@ function graphic_combined_module ($module_list, $weight_list, $period, 'color' => COL_GRAPH13, 'alpha' => CHART_DEFAULT_ALPHA); + $yellow_threshold = 0; + $red_threshold = 0; + if ($from_interface) { + $compare_warning = 0; + $compare_critical = 0; + $do_it_warning = true; + $do_it_critical = true; + foreach ($module_list as $id_module) { + // Get module warning_min and critical_min + $warning_min = db_get_value('min_warning','tagente_modulo','id_agente_modulo',$id_module); + $critical_min = db_get_value('min_critical','tagente_modulo','id_agente_modulo',$id_module); + if ($compare_warning == 0) { + $compare_warning = $warning_min; + } + else { + if ($compare_warning != $warning_min) { + $do_it_warning = false; + } + } + if ($compare_critical == 0) { + $compare_critical = $critical_min; + } + else { + if ($compare_warning != $warning_min) { + $do_it_critical = false; + } + } + } + + if ($do_it_warning) { + $yellow_threshold = $compare_warning; + } + + if ($do_it_critical) { + $red_threshold = $compare_critical; + } + } + switch ($stacked) { case CUSTOM_GRAPH_AREA: return area_graph($flash_charts, $graph_values, $width, @@ -1730,7 +1768,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, ui_get_full_url("images/image_problem.opaque.png", false, false, false), $title, "", $water_mark, $config['fontpath'], $fixed_font_size, $unit, $ttl, $homeurl, $background_color, $dashboard, - $vconsole, $series_type, $percentil_result); + $vconsole, $series_type, $percentil_result, $yellow_threshold, $red_threshold); break; case CUSTOM_GRAPH_STACKED_LINE: return stacked_line_graph($flash_charts, $graph_values, diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 64f8b97f5f..b69ddcbcae 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -511,7 +511,7 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $yaxisname = "", $water_mark = "", $font = '', $font_size = '', $unit = '', $ttl = 1, $homeurl = '', $backgroundColor = 'white', $dashboard = false, $vconsole = false, $series_type = array(), - $percentil_values = array()) { + $percentil_values = array(), $yellow_threshold = 0, $red_threshold = 0) { include_once("functions_flot.php"); @@ -538,8 +538,8 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $water_mark_url, $series_type, array(), - 0, - 0, + $yellow_threshold, + $red_threshold, '', false, '',