Fixed threshold in interface graphs. Ticket #156

(cherry picked from commit d3f5a62814)

 Conflicts resolved:
	pandora_console/include/functions_graph.php
This commit is contained in:
Arturo Gonzalez 2017-01-17 14:29:42 +01:00
parent 0a584c3741
commit a39addc0ec
3 changed files with 141 additions and 45 deletions

View File

@ -1707,42 +1707,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;
}
}
@ -1753,7 +1824,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);
false, '', true, $background_color,$dashboard, $vconsole, 0, $percentil_result, $threshold_data);
break;
default:
case CUSTOM_GRAPH_STACKED_AREA:
@ -1769,7 +1840,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,

View File

@ -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) {
$dashboard = false, $vconsole = false, $agent_module_id = 0, $percentil_values = array(),
$threshold_data = array()) {
include_once('functions_flot.php');
@ -266,7 +267,14 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color,
$agent_module_id,
$font,
$font_size,
<<<<<<< HEAD
$xaxisname);
=======
$xaxisname,
$percentil_values,
$threshold_data
);
>>>>>>> d3f5a6281... Fixed threshold in interface graphs. Ticket #156
}
else {
$graph = array();
@ -511,7 +519,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");
@ -548,7 +557,8 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color,
$dashboard,
$vconsole,
false,
$percentil_values);
$percentil_values,
$threshold_data);
}
else {
$graph = array();

View File

@ -116,16 +116,18 @@ function flot_area_simple_graph($chart_data, $width, $height, $color,
$yellow_threshold = 0, $red_threshold = 0, $adapt_key= '',
$force_integer = false, $series_suffix_str = '', $menu = true,
$background_color = 'white', $dashboard = false, $vconsole = false,
$agent_module_id = 0, $font = '', $font_size = 7, $xaxisname = '') {
$agent_module_id = 0, $font = '', $font_size = 7, $xaxisname = '',
$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);
$agent_module_id, $font, $font_size, $xaxisname, $percentil_values,
$threshold_data);
}
function flot_line_stacked_graph($chart_data, $width, $height, $color,
@ -153,7 +155,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;
@ -162,7 +164,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,
@ -171,7 +174,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;
@ -202,19 +205,31 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend,
// Set some containers to legend, graph, timestamp tooltip, etc.
$return .= "<p id='legend_$graph_id' class='legend_graph' style='font-size:".$font_size."pt'></p>";
// 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) {