From 2391e7ae7827eaae7ff73f2377e89bbc70fc2848 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 --- .../include/functions_custom_graphs.php | 5 ++- pandora_console/include/functions_graph.php | 42 ++++++++++++++++++- pandora_console/include/graphs/fgraph.php | 6 +-- .../agentes/interface_traffic_graph_win.php | 3 +- 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/pandora_console/include/functions_custom_graphs.php b/pandora_console/include/functions_custom_graphs.php index 857e4c03eb..52e99a3251 100644 --- a/pandora_console/include/functions_custom_graphs.php +++ b/pandora_console/include/functions_custom_graphs.php @@ -164,7 +164,7 @@ function custom_graphs_print($id_graph, $height, $width, $period, $background_color = 'white', $modules_param = array(), $homeurl = '', $name_list = array(), $unit_list = array(), $show_last = true, $show_max = true, $show_min = true, $show_avg = true, $ttl = 1, - $dashboard = false, $vconsole = false, $percentil = null) { + $dashboard = false, $vconsole = false, $percentil = null, $from_interface = false) { global $config; @@ -245,7 +245,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 f747f2e9f4..f24f0bae51 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -994,7 +994,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; @@ -1833,6 +1833,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, @@ -1856,7 +1894,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 32a5204b7a..d755560db2 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, '', diff --git a/pandora_console/operation/agentes/interface_traffic_graph_win.php b/pandora_console/operation/agentes/interface_traffic_graph_win.php index 2e84a0b9c0..da2569f316 100644 --- a/pandora_console/operation/agentes/interface_traffic_graph_win.php +++ b/pandora_console/operation/agentes/interface_traffic_graph_win.php @@ -187,7 +187,8 @@ $interface_traffic_modules = array( 1, false, false, - (($show_percentil_95)? 95 : null)); + (($show_percentil_95)? 95 : null), + true); echo '';