diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 6014f63cb6..b0d4cfd18f 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -1832,42 +1832,113 @@ function graphic_combined_module ($module_list, $weight_list, $period, 'color' => COL_GRAPH13, 'alpha' => CHART_DEFAULT_ALPHA); - $yellow_threshold = 0; - $red_threshold = 0; + $threshold_data = array(); + 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_max and critical_max - $warning_max = db_get_value('max_warning','tagente_modulo','id_agente_modulo',$id_module); - $critical_max = db_get_value('max_critical','tagente_modulo','id_agente_modulo',$id_module); - - if ($compare_warning == 0) { - $compare_warning = $warning_max; + $yellow_threshold = 0; + $red_threshold = 0; + + $yellow_up = 0; + $red_up = 0; + + $yellow_inverse = 0; + $red_inverse = 0; + + $compare_warning = false; + $compare_critical = false; + + $do_it_warning_min = true; + $do_it_critical_min = true; + + $do_it_warning_max = true; + $do_it_critical_max = true; + + $do_it_warning_inverse = true; + $do_it_critical_inverse = true; + foreach ($module_list as $index => $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 ($index == 0) { + $compare_warning = $warning_min; } else { - if ($compare_warning != $warning_max) { - $do_it_warning = false; + if ($compare_warning != $warning_min) { + $do_it_warning_min = false; } } - if ($compare_critical == 0) { - $compare_critical = $critical_max; + + if ($index == 0) { + $compare_critical = $critical_min; } else { - if ($compare_warning != $critical_max) { - $do_it_critical = false; + if ($compare_critical != $critical_min) { + $do_it_critical_min = false; } } } - if ($do_it_warning) { + if ($do_it_warning_min || $do_it_critical_min) { + foreach ($module_list as $index => $id_module) { + $warning_max = db_get_value('max_warning','tagente_modulo','id_agente_modulo',$id_module); + $critical_max = db_get_value('max_critical','tagente_modulo','id_agente_modulo',$id_module); + + if ($index == 0) { + $yellow_up = $warning_max; + } + else { + if ($yellow_up != $warning_max) { + $do_it_warning_max = false; + } + } + + if ($index == 0) { + $red_up = $critical_max; + } + else { + if ($red_up != $critical_max) { + $do_it_critical_max = false; + } + } + } + } + + if ($do_it_warning_min || $do_it_critical_min) { + foreach ($module_list as $index => $id_module) { + $warning_inverse = db_get_value('warning_inverse','tagente_modulo','id_agente_modulo',$id_module); + $critical_inverse = db_get_value('critical_inverse','tagente_modulo','id_agente_modulo',$id_module); + + if ($index == 0) { + $yellow_inverse = $warning_inverse; + } + else { + if ($yellow_inverse != $warning_inverse) { + $do_it_warning_inverse = false; + } + } + + if ($index == 0) { + $red_inverse = $critical_inverse; + } + else { + if ($red_inverse != $critical_inverse) { + $do_it_critical_inverse = false; + } + } + } + } + + if ($do_it_warning_min && $do_it_warning_max && $do_it_warning_inverse) { $yellow_threshold = $compare_warning; + $threshold_data['yellow_up'] = $yellow_up; + $threshold_data['yellow_inverse'] = (bool)$yellow_inverse; } - if ($do_it_critical) { + if ($do_it_critical_min && $do_it_critical_max && $do_it_critical_inverse) { $red_threshold = $compare_critical; + $threshold_data['red_up'] = $red_up; + $threshold_data['red_inverse'] = (bool)$red_inverse; } } @@ -1878,7 +1949,7 @@ function graphic_combined_module ($module_list, $weight_list, $period, ui_get_full_url("images/image_problem.opaque.png", false, false, false), $title, "", $homeurl, $water_mark, $config['fontpath'], $fixed_font_size, $unit, $ttl, array(), array(), $yellow_threshold, $red_threshold, '', - false, '', true, $background_color,$dashboard, $vconsole, 0, $percentil_result); + false, '', true, $background_color,$dashboard, $vconsole, 0, $percentil_result, $threshold_data); break; default: case CUSTOM_GRAPH_STACKED_AREA: @@ -1894,7 +1965,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, $yellow_threshold, $red_threshold); + $vconsole, $series_type, $percentil_result, $yellow_threshold, $red_threshold, $threshold_data); 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 39f836d910..ffff68d41c 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -219,7 +219,8 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $chart_extra_data = array(), $yellow_threshold = 0, $red_threshold = 0, $adapt_key = '', $force_integer = false, $series_suffix_str = '', $menu = true, $backgroundColor = 'white', - $dashboard = false, $vconsole = false, $agent_module_id = 0, $percentil_values = array()) { + $dashboard = false, $vconsole = false, $agent_module_id = 0, $percentil_values = array(), + $threshold_data = array()) { include_once('functions_flot.php'); @@ -267,7 +268,8 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $font, $font_size, $xaxisname, - $percentil_values + $percentil_values, + $threshold_data ); } else { @@ -513,7 +515,8 @@ 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(), $yellow_threshold = 0, $red_threshold = 0) { + $percentil_values = array(), $yellow_threshold = 0, $red_threshold = 0, + $threshold_data = array()) { include_once("functions_flot.php"); @@ -550,7 +553,8 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $dashboard, $vconsole, false, - $percentil_values); + $percentil_values, + $threshold_data); } else { $graph = array(); diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 337789d307..b12e4b35fb 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -119,16 +119,17 @@ function flot_area_simple_graph($chart_data, $width, $height, $color, $force_integer = false, $series_suffix_str = '', $menu = true, $background_color = 'white', $dashboard = false, $vconsole = false, $agent_module_id = 0, $font = '', $font_size = 7, $xaxisname = '', - $percentil_values = array()) { + $percentil_values = array(), $threshold_data = array()) { global $config; - + return flot_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, 'area_simple', $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key, $force_integer, $series_suffix_str, $menu, $background_color, $dashboard, $vconsole, - $agent_module_id, $font, $font_size, $xaxisname, $percentil_values); + $agent_module_id, $font, $font_size, $xaxisname, $percentil_values, + $threshold_data); } function flot_line_stacked_graph($chart_data, $width, $height, $color, @@ -156,7 +157,7 @@ function flot_line_simple_graph($chart_data, $width, $height, $color, $red_threshold = 0, $adapt_key= '', $force_integer = false, $series_suffix_str = '', $menu = true, $background_color = 'white', $dashboard = false, $vconsole = false, $agent_module_id = 0, - $percentil_values = array()) { + $percentil_values = array(), $threshold_data = array()) { global $config; @@ -165,7 +166,8 @@ function flot_line_simple_graph($chart_data, $width, $height, $color, $water_mark, $serie_types, $chart_extra_data, $yellow_threshold, $red_threshold, $adapt_key, $force_integer, $series_suffix_str, $menu, $background_color, $dashboard, $vconsole, - $agent_module_id, $font, $font_size, '', $percentil_values); + $agent_module_id, $font, $font_size, '', $percentil_values, + $threshold_data); } function flot_area_graph($chart_data, $width, $height, $color, $legend, @@ -174,7 +176,7 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, $force_integer, $series_suffix_str = '', $menu = true, $background_color = 'white', $dashboard = false, $vconsole = false, $agent_module_id = 0, $font = '', $font_size = 7, $xaxisname = '', - $percentil_values = array()) { + $percentil_values = array(), $threshold_data = array()) { global $config; @@ -205,19 +207,31 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend, // Set some containers to legend, graph, timestamp tooltip, etc. $return .= "

"; - - // Get other required module datas to draw warning and critical - if ($agent_module_id == 0) { - $yellow_up = 0; - $red_up = 0; - $yellow_inverse = false; - $red_inverse = false; - } else { - $module_data = db_get_row_sql ('SELECT * FROM tagente_modulo WHERE id_agente_modulo = ' . $agent_module_id); - $yellow_up = $module_data['max_warning']; - $red_up = $module_data['max_critical']; - $yellow_inverse = !($module_data['warning_inverse'] == 0); - $red_inverse = !($module_data['critical_inverse'] == 0); + if (!empty($threshold_data)) { + html_debug($threshold_data, true); + html_debug($yellow_threshold, true); + $yellow_up = $threshold_data['yellow_up']; + $red_up = $threshold_data['red_up']; + $yellow_inverse = $threshold_data['yellow_inverse']; + $red_inverse = $threshold_data['red_inverse']; + } + else { + // Get other required module datas to draw warning and critical + if ($agent_module_id == 0) { + $yellow_up = 0; + $red_up = 0; + $yellow_inverse = false; + $red_inverse = false; + } else { + $module_data = db_get_row_sql ('SELECT * FROM tagente_modulo WHERE id_agente_modulo = ' . $agent_module_id); + $yellow_up = $module_data['max_warning']; + $red_up = $module_data['max_critical']; + $yellow_inverse = !($module_data['warning_inverse'] == 0); + $red_inverse = !($module_data['critical_inverse'] == 0); + html_debug($yellow_up, true); + html_debug($yellow_threshold, true); + html_debug($yellow_inverse, true); + } } if ($menu) {