add treshold pdf pandora_enterprise#1419

This commit is contained in:
Daniel Barbero Martin 2022-05-18 17:17:31 +02:00
parent 4ae4f6b7bd
commit d0a04177c0
8 changed files with 54 additions and 21 deletions

View File

@ -135,6 +135,7 @@ $current_month = true;
// Only avg is selected by default for the simple graphs. // Only avg is selected by default for the simple graphs.
$fullscale = false; $fullscale = false;
$percentil = false; $percentil = false;
$image_threshold = false;
$time_compare_overlapped = false; $time_compare_overlapped = false;
// Added for events items. // Added for events items.
@ -307,6 +308,7 @@ switch ($action) {
case 'simple_graph': case 'simple_graph':
$fullscale = isset($style['fullscale']) ? (bool) $style['fullscale'] : 0; $fullscale = isset($style['fullscale']) ? (bool) $style['fullscale'] : 0;
$percentil = isset($style['percentil']) ? (bool) $style['percentil'] : 0; $percentil = isset($style['percentil']) ? (bool) $style['percentil'] : 0;
$image_threshold = (isset($style['image_threshold']) === true) ? (bool) $style['image_threshold'] : false;
$graph_render = $item['graph_render']; $graph_render = $item['graph_render'];
// The break hasn't be forgotten. // The break hasn't be forgotten.
case 'simple_baseline_graph': case 'simple_baseline_graph':
@ -2501,6 +2503,23 @@ $class = 'databox filters';
</td> </td>
</tr> </tr>
<tr id="row_image_threshold" class="datos">
<td class="bolder">
<?php
echo __('Show threshold');
?>
</td>
<td>
<?php
html_print_checkbox_switch(
'image_threshold',
1,
$image_threshold
);
?>
</td>
</tr>
<tr id="row_time_compare_overlapped" class="datos"> <tr id="row_time_compare_overlapped" class="datos">
<td class="bolder"> <td class="bolder">
<?php <?php
@ -5945,6 +5964,7 @@ function chooseType() {
$("#row_show_graph").hide(); $("#row_show_graph").hide();
$("#row_max_min_avg").hide(); $("#row_max_min_avg").hide();
$("#row_fullscale").hide(); $("#row_fullscale").hide();
$("#row_image_threshold").hide();
$("#row_graph_render").hide(); $("#row_graph_render").hide();
$("#row_macros_definition").hide(); $("#row_macros_definition").hide();
$("#row_render_definition").hide(); $("#row_render_definition").hide();
@ -6077,6 +6097,7 @@ function chooseType() {
case 'simple_graph': case 'simple_graph':
$("#row_time_compare_overlapped").show(); $("#row_time_compare_overlapped").show();
$("#row_fullscale").show(); $("#row_fullscale").show();
$("#row_image_threshold").show();
$("#row_graph_render").show(); $("#row_graph_render").show();
$("#row_percentil").show(); $("#row_percentil").show();

View File

@ -2249,6 +2249,9 @@ switch ($action) {
$style['fullscale'] = (int) get_parameter( $style['fullscale'] = (int) get_parameter(
'fullscale' 'fullscale'
); );
$style['image_threshold'] = (int) get_parameter(
'image_threshold'
);
if ($label != '') { if ($label != '') {
$style['label'] = $label; $style['label'] = $label;
} else { } else {
@ -2994,6 +2997,9 @@ switch ($action) {
$style['fullscale'] = (int) get_parameter( $style['fullscale'] = (int) get_parameter(
'fullscale' 'fullscale'
); );
$style['image_threshold'] = (int) get_parameter(
'image_threshold'
);
if ($label != '') { if ($label != '') {
$style['label'] = $label; $style['label'] = $label;
} else { } else {

View File

@ -410,7 +410,7 @@ if (check_login()) {
$table_modules->head = []; $table_modules->head = [];
$table_modules->head[0] = __('Module name'); $table_modules->head[0] = __('Module name');
$table_modules->head[1] = __('Data'); $table_modules->head[1] = __('Data');
$table_modules->head[2] = __('Treshold'); $table_modules->head[2] = __('Threshold');
$table_modules->head[3] = __('Current interval'); $table_modules->head[3] = __('Current interval');
$table_modules->head[4] = __('Timestamp'); $table_modules->head[4] = __('Timestamp');
$table_modules->head[5] = __('Status'); $table_modules->head[5] = __('Status');

View File

@ -1181,7 +1181,7 @@ class AgentWizard extends HTML
$table->head[1] = '<b>'.__('Server').'</b>'; $table->head[1] = '<b>'.__('Server').'</b>';
$table->head[2] = '<b>'.__('Type').'</b>'; $table->head[2] = '<b>'.__('Type').'</b>';
$table->head[3] = '<b>'.__('Description').'</b>'; $table->head[3] = '<b>'.__('Description').'</b>';
$table->head[4] = '<b>'.__('Treshold').'</b>'; $table->head[4] = '<b>'.__('Threshold').'</b>';
$table->data = []; $table->data = [];

View File

@ -14855,7 +14855,7 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4)
'type_graph' => $config['type_module_charts'], 'type_graph' => $config['type_module_charts'],
'fullscale' => false, 'fullscale' => false,
'return_img_base_64' => true, 'return_img_base_64' => true,
'image_treshold' => $graph_threshold, 'image_threshold' => $graph_threshold,
'graph_font_size' => $graph_font_size, 'graph_font_size' => $graph_font_size,
]; ];

View File

@ -626,7 +626,7 @@ function grafico_modulo_sparse_data(
* 'show_legend' => true, * 'show_legend' => true,
* 'show_overview' => true, * 'show_overview' => true,
* 'return_img_base_64' => false, * 'return_img_base_64' => false,
* 'image_treshold' => false, * 'image_threshold' => false,
* 'graph_combined' => false, * 'graph_combined' => false,
* 'graph_render' => 0, * 'graph_render' => 0,
* 'zoom' => 1, * 'zoom' => 1,
@ -782,8 +782,8 @@ function grafico_modulo_sparse($params)
$params['return_img_base_64'] = false; $params['return_img_base_64'] = false;
} }
if (isset($params['image_treshold']) === false) { if (isset($params['image_threshold']) === false) {
$params['image_treshold'] = false; $params['image_threshold'] = false;
} }
if (isset($params['graph_combined']) === false) { if (isset($params['graph_combined']) === false) {
@ -1305,8 +1305,8 @@ function graphic_combined_module(
$params['return_img_base_64'] = false; $params['return_img_base_64'] = false;
} }
if (isset($params['image_treshold']) === false) { if (isset($params['image_threshold']) === false) {
$params['image_treshold'] = false; $params['image_threshold'] = false;
} }
if (isset($params['show_unknown']) === false) { if (isset($params['show_unknown']) === false) {

View File

@ -10157,6 +10157,11 @@ function reporting_simple_graph(
$fullscale = (bool) $content['style']['fullscale']; $fullscale = (bool) $content['style']['fullscale'];
} }
$image_threshold = false;
if (isset($content['style']['image_threshold'])) {
$image_threshold = (bool) $content['style']['image_threshold'];
}
$return['chart'] = ''; $return['chart'] = '';
// Get chart. // Get chart.
@ -10211,6 +10216,7 @@ function reporting_simple_graph(
'backgroundColor' => 'transparent', 'backgroundColor' => 'transparent',
'return_img_base_64' => true, 'return_img_base_64' => true,
'graph_render' => $content['graph_render'], 'graph_render' => $content['graph_render'],
'image_threshold' => $image_threshold,
]; ];
if ($only_image === false) { if ($only_image === false) {

View File

@ -1003,7 +1003,7 @@ function pandoraFlotArea(
var max_x = date_array["final_date"] * 1000; var max_x = date_array["final_date"] * 1000;
var type = parseInt(params.stacked); var type = parseInt(params.stacked);
var show_legend = params.show_legend; var show_legend = params.show_legend;
var image_treshold = params.image_treshold; var image_threshold = params.image_threshold;
var short_data = params.short_data != "" ? params.short_data : 3; var short_data = params.short_data != "" ? params.short_data : 3;
var grid_color = params.grid_color; var grid_color = params.grid_color;
var background_color = params.backgroundColor; var background_color = params.backgroundColor;
@ -2198,7 +2198,7 @@ function pandoraFlotArea(
} }
if (thresholded) { if (thresholded) {
var data_base_treshold = add_threshold( var data_base_threshold = add_threshold(
data_base, data_base,
threshold_data, threshold_data,
ranges.yaxis.from, ranges.yaxis.from,
@ -2211,7 +2211,7 @@ function pandoraFlotArea(
plot = $.plot( plot = $.plot(
$("#" + graph_id), $("#" + graph_id),
data_base_treshold, data_base_threshold,
$.extend(true, {}, options, { $.extend(true, {}, options, {
grid: { grid: {
borderWidth: 1, borderWidth: 1,
@ -2597,7 +2597,7 @@ function pandoraFlotArea(
$("#overview_" + graph_id).bind("mouseout", resetInteractivity); $("#overview_" + graph_id).bind("mouseout", resetInteractivity);
} }
if (image_treshold) { if (image_threshold) {
var y_recal = plot.getAxes().yaxis.max; var y_recal = plot.getAxes().yaxis.max;
if (!thresholded) { if (!thresholded) {
// Recalculate the y axis // Recalculate the y axis
@ -2611,7 +2611,7 @@ function pandoraFlotArea(
); );
} }
var datas_treshold = add_threshold( var datas_threshold = add_threshold(
data_base, data_base,
threshold_data, threshold_data,
plot.getAxes().yaxis.min, plot.getAxes().yaxis.min,
@ -2624,7 +2624,7 @@ function pandoraFlotArea(
plot = $.plot( plot = $.plot(
$("#" + graph_id), $("#" + graph_id),
datas_treshold, datas_threshold,
$.extend(true, {}, options, { $.extend(true, {}, options, {
yaxis: { yaxis: {
max: y_recal.max max: y_recal.max
@ -2758,7 +2758,7 @@ function pandoraFlotArea(
); );
} }
datas_treshold = add_threshold( datas_threshold = add_threshold(
data_base, data_base,
threshold_data, threshold_data,
plot.getAxes().yaxis.min, plot.getAxes().yaxis.min,
@ -2771,7 +2771,7 @@ function pandoraFlotArea(
plot = $.plot( plot = $.plot(
$("#" + graph_id), $("#" + graph_id),
datas_treshold, datas_threshold,
$.extend(true, {}, options, { $.extend(true, {}, options, {
yaxis: { yaxis: {
min: max_draw["min"], min: max_draw["min"],
@ -3115,7 +3115,7 @@ function axis_thresholded(
return y; return y;
} }
//add treshold //add threshold
function add_threshold( function add_threshold(
data_base, data_base,
threshold_data, threshold_data,
@ -3235,13 +3235,13 @@ function add_threshold(
} }
}); });
var extreme_treshold_array = []; var extreme_threshold_array = [];
var i = 0; var i = 0;
var flag = true; var flag = true;
$.each(threshold_array, function(index, value) { $.each(threshold_array, function(index, value) {
flag = true; flag = true;
extreme_treshold_array[i] = { extreme_threshold_array[i] = {
below: value["max"], below: value["max"],
color: value["color"] color: value["color"]
}; };
@ -3252,7 +3252,7 @@ function add_threshold(
} }
}); });
if (flag) { if (flag) {
extreme_treshold_array[i] = { extreme_threshold_array[i] = {
below: value["min"], below: value["min"],
color: datas[0].color color: datas[0].color
}; };
@ -3260,7 +3260,7 @@ function add_threshold(
} }
}); });
datas[0].threshold = extreme_treshold_array; datas[0].threshold = extreme_threshold_array;
return datas; return datas;
} }