visual graph for critical and warning threshold

This commit is contained in:
daniel 2016-10-20 16:26:05 +02:00
parent 004299a475
commit 93341a60e1
5 changed files with 943 additions and 87 deletions

View File

@ -17,6 +17,8 @@
include_once("include/functions_modules.php");
include_once("include/functions_categories.php");
echo "<script type='text/javascript' src='include/javascript/d3.3.5.14.js'></script>" . "\n";
function prepend_table_simple ($row, $id = false) {
global $table_simple;
@ -119,9 +121,11 @@ $table_simple->class = 'databox';
$table_simple->data = array ();
$table_simple->colspan = array ();
$table_simple->style = array ();
$table_simple->style[0] = 'font-weight: bold; width: 26%;';
$table_simple->style[1] = 'width: 40%';
$table_simple->style[2] = 'font-weight: bold;';
$table_simple->style[0] = 'font-weight: bold; width: 15%;';
$table_simple->style[1] = 'width: 35%';
$table_simple->style[2] = 'font-weight: bold; width: 25%;';
$table_simple->style[3] = 'width: 25%';
#$table_simple->colspan[4][1] = 3;
$table_simple->colspan[5][1] = 3;
@ -151,7 +155,12 @@ if ($policy_link != 0) {
$disabled_enable = 1;
}
$table_simple->data[0][2] = __('Disabled');
$table_simple->data[0][3] = html_print_checkbox ("disabled", 1, $disabled, true, $disabled_enable);
$table_simple->data[0][2] .= html_print_checkbox ("disabled", 1, $disabled, true, $disabled_enable);
$table_simple->data[0][3] = __('Module group');
$table_simple->data[0][3] .= html_print_select_from_sql ('SELECT id_mg, name FROM tmodule_group ORDER BY name',
'id_module_group', $id_module_group, '', __('Not assigned'), '0', true, false, true, $disabledBecauseInPolicy);
$table_simple->data[1][0] = __('Type').' ' . ui_print_help_icon ('module_type', true);
$table_simple->data[1][0] .= html_print_input_hidden ('id_module_type_hidden', $id_module_type, true);
@ -220,27 +229,22 @@ else {
$table_simple->data[1][1] .= html_print_input_hidden('type_names',base64_encode(io_json_mb_encode($type_names_hash)),true);
}
$table_simple->data[1][2] = __('Module group');
$table_simple->data[1][3] = html_print_select_from_sql ('SELECT id_mg, name FROM tmodule_group ORDER BY name',
'id_module_group', $id_module_group, '', __('Not assigned'), '0',
true, false, true, $disabledBecauseInPolicy);
if($disabledBecauseInPolicy){
$table_simple->data[1][3] .= html_print_input_hidden ('id_module_group', $id_module_group, true);
}
$table_simple->data[2][0] = __('Dynamic Interval') .' ' . ui_print_help_icon ('warning_status', true);
$table_simple->data[2][0] = __('Dynamic Threshold Interval') .' ' . ui_print_help_icon ('dynamic_threshold', true);
$table_simple->data[2][1] = html_print_extended_select_for_time ('dynamic_interval', $dynamic_interval, '', 'None', '0', 10, true, 'width:150px',false);
$table_simple->data[2][2] = '<span><em>'.__('Dynamic Min. ').'</em>';
$table_simple->data[2][1] .= '<a onclick=advanced_option_dynamic()>' . html_print_image('images/cog.png', true, array('title' => __('Advanced options Dynamic Threshold'))) . '</a>';
$table_simple->data[2][2] = '<span><em>'.__('Dynamic Threshold Min. ').'</em>';
$table_simple->data[2][2] .= html_print_input_text ('dynamic_min', $dynamic_min, '', 10, 255, true);
$table_simple->data[2][2] .= '<br /><em>'.__('Dynamic Max.').'</em>';
$table_simple->data[2][2] .= '<br /><em>'.__('Dynamic Threshold Max.').'</em>';
$table_simple->data[2][2] .= html_print_input_text ('dynamic_max', $dynamic_max, '', 10, 255, true);
$table_simple->data[2][3] = '<span><em>'.__('Dynamic Two Tailed: ').'</em>';
$table_simple->data[2][3] = '<span><em>'.__('Dynamic Threshold Two Tailed: ').'</em>';
$table_simple->data[2][3] .= html_print_checkbox ("dynamic_two_tailed", 1, $dynamic_two_tailed, true);
$table_simple->data[3][0] = __('Warning status').' ' . ui_print_help_icon ('warning_status', true);
$table_simple->data[3][1] = '';
if (!modules_is_string_type($id_module_type) || $edit) {
$table_simple->data[3][1] .= '<span id="minmax_warning"><em>'.__('Min. ').'</em>';
$table_simple->data[3][1] .= html_print_input_text ('min_warning', $min_warning,
@ -254,52 +258,54 @@ if (modules_is_string_type($id_module_type) || $edit) {
$table_simple->data[3][1] .= html_print_input_text ('str_warning', $str_warning,
'', 10, 255, true, $disabledBecauseInPolicy).'</span>';
}
$table_simple->data[3][1] .= '<br /><em>'.__('Inverse interval').'</em>';
$table_simple->data[3][1] .= html_print_checkbox ("warning_inverse", 1,
$warning_inverse, true);
$table_simple->data[3][2] = __('Critical status').' ' . ui_print_help_icon ('critical_status', true);
$table_simple->data[3][3] = '';
$table_simple->data[3][2] = '<svg id="svg_dinamic" width="350" height="200" style="padding:40px; padding-left: 100px;"> </svg>';
$table_simple->colspan[3][2] = 2;
$table_simple->rowspan[3][2] = 3;
$table_simple->data[4][0] = __('Critical status').' ' . ui_print_help_icon ('critical_status', true);
if (!modules_is_string_type($id_module_type) || $edit) {
$table_simple->data[3][3] .= '<span id="minmax_critical"><em>'.__('Min. ').'</em>';
$table_simple->data[3][3] .= html_print_input_text ('min_critical', $min_critical,
$table_simple->data[4][1] .= '<span id="minmax_critical"><em>'.__('Min. ').'</em>';
$table_simple->data[4][1] .= html_print_input_text ('min_critical', $min_critical,
'', 10, 255, true, $disabledBecauseInPolicy);
$table_simple->data[3][3] .= '<br /><em>'.__('Max.').'</em>';
$table_simple->data[3][3] .= html_print_input_text ('max_critical', $max_critical,
$table_simple->data[4][1] .= '<br /><em>'.__('Max.').'</em>';
$table_simple->data[4][1] .= html_print_input_text ('max_critical', $max_critical,
'', 10, 255, true, $disabledBecauseInPolicy).'</span>';
}
if (modules_is_string_type($id_module_type) || $edit) {
$table_simple->data[3][3] .= '<span id="string_critical"><em>'.__('Str.').'</em>';
$table_simple->data[3][3] .= html_print_input_text ('str_critical', $str_critical,
$table_simple->data[4][1] .= '<span id="string_critical"><em>'.__('Str.').'</em>';
$table_simple->data[4][1] .= html_print_input_text ('str_critical', $str_critical,
'', 10, 255, true, $disabledBecauseInPolicy).'</span>';
}
$table_simple->data[3][3] .= '<br /><em>'.__('Inverse interval').'</em>';
$table_simple->data[3][3] .= html_print_checkbox ("critical_inverse", 1, $critical_inverse, true);
$table_simple->data[4][1] .= '<br /><em>'.__('Inverse interval').'</em>';
$table_simple->data[4][1] .= html_print_checkbox ("critical_inverse", 1, $critical_inverse, true);
/* FF stands for Flip-flop */
$table_simple->data[4][0] = __('FF threshold').' ' . ui_print_help_icon ('ff_threshold', true);
$table_simple->colspan[4][1] = 3;
$table_simple->data[5][0] = __('FF threshold').' ' . ui_print_help_icon ('ff_threshold', true);
$table_simple->colspan[5][1] = 3;
$table_simple->data[4][1] = html_print_radio_button ('each_ff', 0, '', $each_ff, true) . ' ' . __('All state changing') . ' : ';
$table_simple->data[4][1] .= html_print_input_text ('ff_event', $ff_event, '', 5
$table_simple->data[5][1] = html_print_radio_button ('each_ff', 0, '', $each_ff, true) . ' ' . __('All state changing') . ' : ';
$table_simple->data[5][1] .= html_print_input_text ('ff_event', $ff_event, '', 5
, 15, true, $disabledBecauseInPolicy) . '<br />';
$table_simple->data[4][1] .= html_print_radio_button ('each_ff', 1, '', $each_ff, true) . ' ' . __('Each state changing') . ' : ';
$table_simple->data[4][1] .= __('To normal');
$table_simple->data[4][1] .= html_print_input_text ('ff_event_normal', $ff_event_normal, '', 5, 15, true, $disabledBecauseInPolicy) . ' ';
$table_simple->data[4][1] .= __('To warning');
$table_simple->data[4][1] .= html_print_input_text ('ff_event_warning', $ff_event_warning, '', 5, 15, true, $disabledBecauseInPolicy) . ' ';
$table_simple->data[4][1] .= __('To critical');
$table_simple->data[4][1] .= html_print_input_text ('ff_event_critical', $ff_event_critical, '', 5, 15, true, $disabledBecauseInPolicy);
$table_simple->data[5][0] = __('Historical data');
$table_simple->data[5][1] .= html_print_radio_button ('each_ff', 1, '', $each_ff, true) . ' ' . __('Each state changing') . ' : ';
$table_simple->data[5][1] .= __('To normal');
$table_simple->data[5][1] .= html_print_input_text ('ff_event_normal', $ff_event_normal, '', 5, 15, true, $disabledBecauseInPolicy) . ' ';
$table_simple->data[5][1] .= __('To warning');
$table_simple->data[5][1] .= html_print_input_text ('ff_event_warning', $ff_event_warning, '', 5, 15, true, $disabledBecauseInPolicy) . ' ';
$table_simple->data[5][1] .= __('To critical');
$table_simple->data[5][1] .= html_print_input_text ('ff_event_critical', $ff_event_critical, '', 5, 15, true, $disabledBecauseInPolicy);
$table_simple->data[6][0] = __('Historical data');
if($disabledBecauseInPolicy) {
// If is disabled, we send a hidden in his place and print a false checkbox because HTML dont send disabled fields and could be disabled by error
$table_simple->data[5][1] = html_print_checkbox ("history_data_fake", 1, $history_data, true, $disabledBecauseInPolicy);
$table_simple->data[5][1] .= '<input type="hidden" name="history_data" value="'.(int)$history_data.'">';
$table_simple->data[6][1] = html_print_checkbox ("history_data_fake", 1, $history_data, true, $disabledBecauseInPolicy);
$table_simple->data[6][1] .= '<input type="hidden" name="history_data" value="'.(int)$history_data.'">';
}
else {
$table_simple->data[5][1] = html_print_checkbox ("history_data", 1, $history_data, true, $disabledBecauseInPolicy);
$table_simple->data[6][1] = html_print_checkbox ("history_data", 1, $history_data, true, $disabledBecauseInPolicy);
}
/* Advanced form part */
@ -807,14 +813,53 @@ $(document).ready (function () {
$("#submit-crtbutton").click (function () {
validate_post_process();
});
//Dynamic_interval;
disabled_status();
$('#dynamic_interval_select').change (function() {
disabled_status();
});
//Dynamic_options_advance;
$('#simple-2-2').hide();
$('#simple-2-3').hide();
//paint graph stutus critical and warning:
paint_graph_values();
$('#text-min_warning').on ('input', function() {
paint_graph_values();
if (isNaN($('#text-min_warning').val()) && !($('#text-min_warning').val() == "-")){
$('#text-min_warning').val(0);
}
});
$('#text-max_warning').on ('input', function() {
paint_graph_values();
if (isNaN($('#text-max_warning').val()) && !($('#text-max_warning').val() == "-")){
$('#text-max_warning').val(0);
}
});
$('#text-min_critical').on ('input', function() {
paint_graph_values();
if (isNaN($('#text-min_critical').val()) && !($('#text-min_critical').val() == "-")){
$('#text-min_critical').val(0);
}
});
$('#text-max_critical').on ('input', function() {
paint_graph_values();
if (isNaN($('#text-max_critical').val()) && !($('#text-max_critical').val() == "-")){
$('#text-max_critical').val(0);
}
});
$('#checkbox-warning_inverse').change (function() {
paint_graph_values();
});
$('#checkbox-critical_inverse').change (function() {
paint_graph_values();
});
});
//readonly and add class input
function disabled_status () {
if($('#dynamic_interval_select').val() != 0){
$('#text-min_warning').prop('readonly', true);
@ -837,7 +882,18 @@ function disabled_status () {
}
}
// Add a new module macro
//Dynamic_options_advance;
function advanced_option_dynamic() {
if($('#simple-2-2').is(":visible")){
$('#simple-2-2').hide();
$('#simple-2-3').hide();
} else {
$('#simple-2-2').show();
$('#simple-2-3').show();
}
}
//Add a new module macro
function add_macro () {
var macro_count = parseInt($("#hidden-module_macro_count").val());
var delete_icon = '<?php html_print_image ("images/cross.png", false) ?>';
@ -1064,6 +1120,312 @@ function validate_post_process() {
$("#text-post_process").val(new_post_process);
}
//function paint graph
function paint_graph_values(){
//Parse integrer
var min_w = parseInt($('#text-min_warning').val());
if(min_w == '0.00'){ min_w = 0; }
var max_w = parseInt($('#text-max_warning').val());
if(max_w == '0.00'){ max_w = 0; }
var min_c = parseInt($('#text-min_critical').val());
if(min_c =='0.00'){ min_c = 0; }
var max_c = parseInt($('#text-max_critical').val());
if(max_c =='0.00'){ max_c = 0; }
var inverse_w = $('input:checkbox[name=warning_inverse]:checked').val();
if(!inverse_w){ inverse_w = 0; }
var inverse_c = $('input:checkbox[name=critical_inverse]:checked').val();
if(!inverse_c){ inverse_c = 0; }
//inicialiced error
var error_w = 0;
var error_c = 0;
//if haven't error
if(max_w == 0 || max_w > min_w){
if(max_c == 0 || max_c > min_c){
paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, inverse_c, error_w, error_c);
} else {
error_c = 1;
paint_graph_status(0,0,0,0,0,0, error_w, error_c);
}
} else {
error_w = 1;
paint_graph_status(0,0,0,0,0,0, error_w, error_c);
}
}
//function use d3.js for paint graph
function paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, inverse_c, error_w, error_c) {
//Check if they are numbers
if(isNaN(min_w)){ min_w = 0; };
if(isNaN(max_w)){ max_w = 0; };
if(isNaN(min_c)){ min_c = 0; };
if(isNaN(max_c)){ max_c = 0; };
//messages legend
var legend_normal = '<?php echo __("Normal Status");?>';
var legend_warning = '<?php echo __("Warning Status");?>';
var legend_critical = '<?php echo __("Critical Status");?>';
//remove elements
d3.select("#svg_dinamic rect").remove();
$("#text-max_warning").removeClass("input_error");
$("#text-max_critical").removeClass("input_error");
//if haven't errors
if (error_w == 0 && error_c == 0){
//parse element
min_w = parseInt(min_w);
min_c = parseInt(min_c);
max_w = parseInt(max_w);
max_c = parseInt(max_c);
//inicialize var
var range_min = 0;
var range_max = 0;
var range_max_min = 0;
var range_max_min = 0;
//Find the lowest possible value
if(min_w < 0 || min_c < 0){
if(min_w < min_c){
range_min = min_w - 100;
} else {
range_min = min_c - 100;
}
} else if (min_w > 0 || min_c > 0) {
if(min_w > min_c){
range_max_min = min_w;
} else {
range_max_min = min_c;
}
} else {
if(min_w < min_c){
range_min = min_w - 100;
} else {
range_min = min_c - 100;
}
}
//Find the maximum possible value
if(max_w > max_c){
range_max = max_w + 100 + range_max_min;
} else {
range_max = max_c + 100 + range_max_min;
}
//Controls whether the maximum = 0 is infinite
if((max_w == 0 || max_w == 0.00) && min_w != 0){
max_w = range_max;
}
if((max_c == 0 || max_c == 0.00) && min_c != 0){
max_c = range_max;
}
//Scale according to the position
position = 200 / (range_max-range_min);
//axes
var yScale = d3.scale.linear()
.domain([range_min, range_max])
.range([100, -100]);
var yAxis = d3.svg.axis()
.orient("left")
.scale(yScale);
//create svg
var svg = d3.select("#svg_dinamic");
//delete elements
svg.selectAll("g").remove();
svg.selectAll("rect").remove();
svg.selectAll("text").remove();
svg.append("g")
.attr("transform", "translate(0, 100)")
.call(yAxis);
//legend Normal text
svg.append("text")
.attr("x", 0)
.attr("y", -20)
.attr("fill", 'black')
.style("font-family", "arial")
.style("font-weight", "bold")
.style("font-size", 10)
.html(legend_normal)
.style("text-anchor", "first");
//legend Normal rect
svg.append("rect")
.attr("id", "legend_normal")
.attr("x", 72)
.attr("y", -30)
.attr("width", 10)
.attr("height", 10)
.style("fill", "#82B92E");
//legend Warning text
svg.append("text")
.attr("x", 91)
.attr("y", -20)
.attr("fill", 'black')
.style("font-family", "arial")
.style("font-weight", "bold")
.style("font-size", 10)
.html(legend_warning)
.style("text-anchor", "first");
//legend Warning rect
svg.append("rect")
.attr("id", "legend_warning")
.attr("x", 168)
.attr("y", -30)
.attr("width", 10)
.attr("height", 10)
.style("fill", "#ffd731");
//legend Critical text
svg.append("text")
.attr("x", 187)
.attr("y", -20)
.attr("fill", 'black')
.style("font-family", "arial")
.style("font-weight", "bold")
.style("font-size", 10)
.html(legend_critical)
.style("text-anchor", "first");
//legend critical rect
svg.append("rect")
.attr("id", "legend_critical")
.attr("x", 258)
.attr("y", -30)
.attr("width", 10)
.attr("height", 10)
.style("fill", "#fc4444");
//styles for number and axes
svg.selectAll("g .domain")
.style("stroke-width", 2)
.style("fill", "none")
.style("stroke", "black");
svg.selectAll("g .tick text")
.style("font-size", "9pt")
.style("font-weight", "initial");
//estatus normal
svg.append("rect")
.attr("id", "warning_rect")
.attr("x", 3)
.attr("y", 0)
.attr("width", 300)
.attr("height", 200)
.style("fill", "#82B92E");
//controls the inverse warning
if(inverse_w == 0){
svg.append("rect").transition()
.duration(600)
.attr("id", "warning_rect")
.attr("x", 3)
.attr("y", ((range_max - min_w) * position) - ((max_w - min_w) * position))
.attr("width", 300)
.attr("height", ((max_w - min_w) * position))
.style("fill", "#ffd731");
}
else {
svg.append("rect").transition()
.duration(600)
.attr("id", "warning_rect")
.attr("x", 3)
.attr("y", 200 - ((min_w -range_min) * position))
.attr("width", 300)
.attr("height", (min_w -range_min) * position)
.style("fill", "#ffd731");
svg.append("rect").transition()
.duration(600)
.attr("id", "warning_inverse_rect")
.attr("x", 3)
.attr("y", 0)
.attr("width", 300)
.attr("height", ((range_max - min_w) * position) - ((max_w - min_w) * position))
.style("fill", "#ffd731");
}
//controls the inverse critical
if(inverse_c == 0){
svg.append("rect").transition()
.duration(600)
.attr("id", "critical_rect")
.attr("x", 3)
.attr("y", ((range_max - min_c) * position) - ((max_c - min_c) * position))
.attr("width", 300)
.attr("height", ((max_c - min_c) * position))
.style("fill", "#fc4444");
}
else {
svg.append("rect").transition()
.duration(600)
.attr("id", "critical_rect")
.attr("x", 3)
.attr("y", 200 - ((min_c -range_min) * position))
.attr("width", 300)
.attr("height", (min_c -range_min) * position)
.style("fill", "#fc4444");
svg.append("rect").transition()
.duration(600)
.attr("id", "critical_inverse_rect")
.attr("x", 3)
.attr("y", 0)
.attr("width", 300)
.attr("height", ((range_max - min_c) * position) - ((max_c - min_c) * position))
.style("fill", "#fc4444");
}
}
else {
var message_error_warning = '<?php echo __("Please introduce a maximum warning higher than the minimun warning") ?>';
var message_error_critical = '<?php echo __("Please introduce a maximum critical higher than the minimun critical") ?>';
d3.select("#svg_dinamic rect").remove();
//create svg
var svg = d3.select("#svg_dinamic");
svg.selectAll("g").remove();
svg.selectAll("rect").remove();
svg.selectAll("text").remove();
//message error warning
if (error_w == 1) {
$("#text-max_warning").addClass("input_error");
svg.append("text")
.attr("x", -90)
.attr("y", 10)
.attr("fill", 'black')
.style("font-family", "arial")
.style("font-weight", "bold")
.style("font-size", 14)
.style("fill", "red")
.html(message_error_warning)
.style("text-anchor", "first");
}
//message error critical
if (error_c == 1) {
$("#text-max_critical").addClass("input_error");
svg.append("text")
.attr("x", -90)
.attr("y", 105)
.attr("fill", 'black')
.style("font-family", "arial")
.style("font-weight", "bold")
.style("font-size", 14)
.style("fill", "red")
.html(message_error_critical)
.style("text-anchor", "first");
}
}
}
/* End of relationship javascript */
/* ]]> */

View File

@ -22,6 +22,8 @@ if (! check_acl ($config['id_user'], 0, "PM")) {
return;
}
echo "<script type='text/javascript' src='include/javascript/d3.3.5.14.js'></script>" . "\n";
function push_table_row ($row, $id = false) {
global $table;
@ -102,9 +104,10 @@ $table->data[2][1] = html_print_select (network_components_get_groups (),
$table->data[2][2] = __('Interval');
$table->data[2][3] = html_print_extended_select_for_time ('module_interval' , $module_interval, '', '', '0', false, true);
$table->data[3][0] = __('Dynamic Interval') .' ' . ui_print_help_icon ('warning_status', true);
$table->data[3][0] = __('Dynamic Interval') .' ' . ui_print_help_icon ('dynamic_threshold', true);
$table->data[3][1] = html_print_extended_select_for_time ('dynamic_interval', $dynamic_interval, '', 'None', '0', 10, true, 'width:150px',false);
$table->data[3][1] .= '<a onclick=advanced_option_dynamic()>' . html_print_image('images/cog.png', true, array('title' => __('Advanced options Dynamic Threshold'))) . '</a>';
$table->data[3][2] = '<span><em>'.__('Dynamic Min. ').'</em>';
$table->data[3][2] .= html_print_input_text ('dynamic_min', $dynamic_min, '', 10, 255, true);
$table->data[3][2] .= '<br /><em>'.__('Dynamic Max.').'</em>';
@ -125,59 +128,63 @@ $table->data[4][1] .= html_print_input_text ('str_warning', $str_warning,
$table->data[4][1] .= '<br /><em>'.__('Inverse interval').'</em>';
$table->data[4][1] .= html_print_checkbox ("warning_inverse", 1, $warning_inverse, true);
$table->data[4][2] = __('Critical status'). ' ' . ui_print_help_icon ('critical_status', true);
$table->data[4][3] = '<span id="minmax_critical"><em>'.__('Min.').'&nbsp;</em>&nbsp;';
$table->data[4][3] .= html_print_input_text ('min_critical', $min_critical,
$table->data[4][2] = '<svg id="svg_dinamic" width="350" height="200" style="padding:40px; padding-left: 100px;"> </svg>';
$table->colspan[4][2] = 2;
$table->rowspan[4][2] = 3;
$table->data[5][0] = __('Critical status'). ' ' . ui_print_help_icon ('critical_status', true);
$table->data[5][1] = '<span id="minmax_critical"><em>'.__('Min.').'&nbsp;</em>&nbsp;';
$table->data[5][1] .= html_print_input_text ('min_critical', $min_critical,
'', 5, 15, true);
$table->data[4][3] .= '<br /><em>'.__('Max.').'</em>&nbsp;';
$table->data[4][3] .= html_print_input_text ('max_critical', $max_critical,
$table->data[5][1] .= '<br /><em>'.__('Max.').'</em>&nbsp;';
$table->data[5][1] .= html_print_input_text ('max_critical', $max_critical,
'', 5, 15, true) . '</span>';
$table->data[4][3] .= '<span id="string_critical"><em>'.__('Str.').' </em>&nbsp;';
$table->data[4][3] .= html_print_input_text ('str_critical', $str_critical,
$table->data[5][1] .= '<span id="string_critical"><em>'.__('Str.').' </em>&nbsp;';
$table->data[5][1] .= html_print_input_text ('str_critical', $str_critical,
'', 5, 15, true) . '</span>';
$table->data[4][3] .= '<br /><em>'.__('Inverse interval').'</em>';
$table->data[4][3] .= html_print_checkbox ("critical_inverse", 1, $critical_inverse, true);
$table->data[5][1] .= '<br /><em>'.__('Inverse interval').'</em>';
$table->data[5][1] .= html_print_checkbox ("critical_inverse", 1, $critical_inverse, true);
$table->data[5][0] = __('FF threshold') . ' ' . ui_print_help_icon ('ff_threshold', true);
$table->colspan[5][1] = 3;
$table->data[5][1] = html_print_radio_button ('each_ff', 0, '', $each_ff, true) . ' ' . __('All state changing') . ' : ';
$table->data[5][1] .= html_print_input_text ('ff_event', $ff_event,
$table->data[6][0] = __('FF threshold') . ' ' . ui_print_help_icon ('ff_threshold', true);
$table->colspan[6][1] = 3;
$table->data[6][1] = html_print_radio_button ('each_ff', 0, '', $each_ff, true) . ' ' . __('All state changing') . ' : ';
$table->data[6][1] .= html_print_input_text ('ff_event', $ff_event,
'', 5, 15, true) . '<br />';
$table->data[5][1] .= html_print_radio_button ('each_ff', 1, '', $each_ff, true) . ' ' . __('Each state changing') . ' : ';
$table->data[5][1] .= __('To normal');
$table->data[5][1] .= html_print_input_text ('ff_event_normal', $ff_event_normal, '', 5, 15, true) . ' ';
$table->data[5][1] .= __('To warning');
$table->data[5][1] .= html_print_input_text ('ff_event_warning', $ff_event_warning, '', 5, 15, true) . ' ';
$table->data[5][1] .= __('To critical');
$table->data[5][1] .= html_print_input_text ('ff_event_critical', $ff_event_critical, '', 5, 15, true);
$table->data[6][1] .= html_print_radio_button ('each_ff', 1, '', $each_ff, true) . ' ' . __('Each state changing') . ' : ';
$table->data[6][1] .= __('To normal');
$table->data[6][1] .= html_print_input_text ('ff_event_normal', $ff_event_normal, '', 5, 15, true) . ' ';
$table->data[6][1] .= __('To warning');
$table->data[6][1] .= html_print_input_text ('ff_event_warning', $ff_event_warning, '', 5, 15, true) . ' ';
$table->data[6][1] .= __('To critical');
$table->data[6][1] .= html_print_input_text ('ff_event_critical', $ff_event_critical, '', 5, 15, true);
$table->data[6][0] = __('Historical data');
$table->data[6][1] = html_print_checkbox ("history_data", 1, $history_data, true);
$table->data[7][0] = __('Historical data');
$table->data[7][1] = html_print_checkbox ("history_data", 1, $history_data, true);
$table->data[7][0] = __('Min. Value');
$table->data[7][1] = html_print_input_text ('min', $min, '', 5, 15, true). ' ' . ui_print_help_tip (__('Any value below this number is discarted'), true);
$table->data[7][2] = __('Max. Value');
$table->data[7][3] = html_print_input_text ('max', $max, '', 5, 15, true) . ' ' . ui_print_help_tip (__('Any value over this number is discarted'), true);
$table->data[8][0] = __('Unit');
$table->data[8][1] = html_print_input_text ('unit', $unit, '', 12, 25, true);
$table->data[8][0] = __('Min. Value');
$table->data[8][1] = html_print_input_text ('min', $min, '', 5, 15, true). ' ' . ui_print_help_tip (__('Any value below this number is discarted'), true);
$table->data[8][2] = __('Max. Value');
$table->data[8][3] = html_print_input_text ('max', $max, '', 5, 15, true) . ' ' . ui_print_help_tip (__('Any value over this number is discarted'), true);
$table->data[9][0] = __('Unit');
$table->data[9][1] = html_print_input_text ('unit', $unit, '', 12, 25, true);
$table->data[8][2] = __('Throw unknown events');
$table->data[8][3] = html_print_checkbox('throw_unknown_events', 1,
$table->data[9][2] = __('Throw unknown events');
$table->data[9][3] = html_print_checkbox('throw_unknown_events', 1,
!network_components_is_disable_type_event($id, EVENTS_GOING_UNKNOWN), true);
$table->data[9][0] = __('Critical instructions'). ui_print_help_tip(__("Instructions when the status is critical"), true);
$table->data[9][1] = html_print_textarea ('critical_instructions', 2, 65, $critical_instructions, '', true);
$table->colspan[9][1] = 3;
$table->data[10][0] = __('Warning instructions'). ui_print_help_tip(__("Instructions when the status is warning"), true);
$table->data[10][1] = html_print_textarea ('warning_instructions', 2, 65, $warning_instructions, '', true);
$table->data[10][0] = __('Critical instructions'). ui_print_help_tip(__("Instructions when the status is critical"), true);
$table->data[10][1] = html_print_textarea ('critical_instructions', 2, 65, $critical_instructions, '', true);
$table->colspan[10][1] = 3;
$table->data[11][0] = __('Unknown instructions'). ui_print_help_tip(__("Instructions when the status is unknown"), true);
$table->data[11][1] = html_print_textarea ('unknown_instructions', 2, 65, $unknown_instructions, '', true);
$table->data[11][0] = __('Warning instructions'). ui_print_help_tip(__("Instructions when the status is warning"), true);
$table->data[11][1] = html_print_textarea ('warning_instructions', 2, 65, $warning_instructions, '', true);
$table->colspan[11][1] = 3;
$next_row = 12;
$table->data[12][0] = __('Unknown instructions'). ui_print_help_tip(__("Instructions when the status is unknown"), true);
$table->data[12][1] = html_print_textarea ('unknown_instructions', 2, 65, $unknown_instructions, '', true);
$table->colspan[12][1] = 3;
$next_row = 13;
if (check_acl ($config['id_user'], 0, "PM")) {
$table->data[$next_row][0] = __('Category');
@ -187,7 +194,7 @@ if (check_acl ($config['id_user'], 0, "PM")) {
}
else {
// Store in a hidden field if is not visible to avoid delete the value
$table->data[11][1] .= html_print_input_hidden ('id_category', $id_category, true);
$table->data[12][1] .= html_print_input_hidden ('id_category', $id_category, true);
}
$table->data[$next_row][0] = __('Tags');
@ -246,14 +253,54 @@ $next_row++;
$('#minmax_warning').hide();
}
});
$("#type").trigger('change');
//Dynamic_interval;
disabled_status();
$('#dynamic_interval_select').change (function() {
disabled_status();
});
$("#type").trigger('change');
//Dynamic_options_advance;
$('#network_component-3-2').hide();
$('#network_component-3-3').hide();
//paint graph stutus critical and warning:
paint_graph_values();
$('#text-min_warning').on ('input', function() {
paint_graph_values();
if (isNaN($('#text-min_warning').val()) && !($('#text-min_warning').val() == "-")){
$('#text-min_warning').val(0);
}
});
$('#text-max_warning').on ('input', function() {
paint_graph_values();
if (isNaN($('#text-max_warning').val()) && !($('#text-max_warning').val() == "-")){
$('#text-max_warning').val(0);
}
});
$('#text-min_critical').on ('input', function() {
paint_graph_values();
if (isNaN($('#text-min_critical').val()) && !($('#text-min_critical').val() == "-")){
$('#text-min_critical').val(0);
}
});
$('#text-max_critical').on ('input', function() {
paint_graph_values();
if (isNaN($('#text-max_critical').val()) && !($('#text-max_critical').val() == "-")){
$('#text-max_critical').val(0);
}
});
$('#checkbox-warning_inverse').change (function() {
paint_graph_values();
});
$('#checkbox-critical_inverse').change (function() {
paint_graph_values();
});
});
//readonly and add class input
function disabled_status () {
if($('#dynamic_interval_select').val() != 0){
$('#text-min_warning').prop('readonly', true);
@ -275,4 +322,321 @@ $next_row++;
$('#text-max_critical').removeClass('readonly');
}
}
//Dynamic_options_advance;
function advanced_option_dynamic() {
if($('#network_component-3-2').is(":visible")){
$('#network_component-3-2').hide();
$('#network_component-3-3').hide();
} else {
$('#network_component-3-2').show();
$('#network_component-3-3').show();
}
}
//function paint graph
function paint_graph_values(){
//Parse integrer
var min_w = parseInt($('#text-min_warning').val());
if(min_w == '0.00'){ min_w = 0; }
var max_w = parseInt($('#text-max_warning').val());
if(max_w == '0.00'){ max_w = 0; }
var min_c = parseInt($('#text-min_critical').val());
if(min_c =='0.00'){ min_c = 0; }
var max_c = parseInt($('#text-max_critical').val());
if(max_c =='0.00'){ max_c = 0; }
var inverse_w = $('input:checkbox[name=warning_inverse]:checked').val();
if(!inverse_w){ inverse_w = 0; }
var inverse_c = $('input:checkbox[name=critical_inverse]:checked').val();
if(!inverse_c){ inverse_c = 0; }
//inicialiced error
var error_w = 0;
var error_c = 0;
//if haven't error
if(max_w == 0 || max_w > min_w){
if(max_c == 0 || max_c > min_c){
paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, inverse_c, error_w, error_c);
} else {
error_c = 1;
paint_graph_status(0,0,0,0,0,0, error_w, error_c);
}
} else {
error_w = 1;
paint_graph_status(0,0,0,0,0,0, error_w, error_c);
}
}
//function use d3.js for paint graph
function paint_graph_status(min_w, max_w, min_c, max_c, inverse_w, inverse_c, error_w, error_c) {
//Check if they are numbers
if(isNaN(min_w)){ min_w = 0; };
if(isNaN(max_w)){ max_w = 0; };
if(isNaN(min_c)){ min_c = 0; };
if(isNaN(max_c)){ max_c = 0; };
//messages legend
var legend_normal = '<?php echo __("Normal Status");?>';
var legend_warning = '<?php echo __("Warning Status");?>';
var legend_critical = '<?php echo __("Critical Status");?>';
//remove elements
d3.select("#svg_dinamic rect").remove();
$("#text-max_warning").removeClass("input_error");
$("#text-max_critical").removeClass("input_error");
//if haven't errors
if (error_w == 0 && error_c == 0){
//parse element
min_w = parseInt(min_w);
min_c = parseInt(min_c);
max_w = parseInt(max_w);
max_c = parseInt(max_c);
//inicialize var
var range_min = 0;
var range_max = 0;
var range_max_min = 0;
var range_max_min = 0;
//Find the lowest possible value
if(min_w < 0 || min_c < 0){
if(min_w < min_c){
range_min = min_w - 100;
} else {
range_min = min_c - 100;
}
} else if (min_w > 0 || min_c > 0) {
if(min_w > min_c){
range_max_min = min_w;
} else {
range_max_min = min_c;
}
} else {
if(min_w < min_c){
range_min = min_w - 100;
} else {
range_min = min_c - 100;
}
}
//Find the maximum possible value
if(max_w > max_c){
range_max = max_w + 100 + range_max_min;
} else {
range_max = max_c + 100 + range_max_min;
}
//Controls whether the maximum = 0 is infinite
if((max_w == 0 || max_w == 0.00) && min_w != 0){
max_w = range_max;
}
if((max_c == 0 || max_c == 0.00) && min_c != 0){
max_c = range_max;
}
//Scale according to the position
position = 200 / (range_max-range_min);
//axes
var yScale = d3.scale.linear()
.domain([range_min, range_max])
.range([100, -100]);
var yAxis = d3.svg.axis()
.orient("left")
.scale(yScale);
//create svg
var svg = d3.select("#svg_dinamic");
//delete elements
svg.selectAll("g").remove();
svg.selectAll("rect").remove();
svg.selectAll("text").remove();
svg.append("g")
.attr("transform", "translate(0, 100)")
.call(yAxis);
//legend Normal text
svg.append("text")
.attr("x", 0)
.attr("y", -20)
.attr("fill", 'black')
.style("font-family", "arial")
.style("font-weight", "bold")
.style("font-size", 10)
.html(legend_normal)
.style("text-anchor", "first");
//legend Normal rect
svg.append("rect")
.attr("id", "legend_normal")
.attr("x", 72)
.attr("y", -30)
.attr("width", 10)
.attr("height", 10)
.style("fill", "#82B92E");
//legend Warning text
svg.append("text")
.attr("x", 91)
.attr("y", -20)
.attr("fill", 'black')
.style("font-family", "arial")
.style("font-weight", "bold")
.style("font-size", 10)
.html(legend_warning)
.style("text-anchor", "first");
//legend Warning rect
svg.append("rect")
.attr("id", "legend_warning")
.attr("x", 168)
.attr("y", -30)
.attr("width", 10)
.attr("height", 10)
.style("fill", "#ffd731");
//legend Critical text
svg.append("text")
.attr("x", 187)
.attr("y", -20)
.attr("fill", 'black')
.style("font-family", "arial")
.style("font-weight", "bold")
.style("font-size", 10)
.html(legend_critical)
.style("text-anchor", "first");
//legend critical rect
svg.append("rect")
.attr("id", "legend_critical")
.attr("x", 258)
.attr("y", -30)
.attr("width", 10)
.attr("height", 10)
.style("fill", "#fc4444");
//styles for number and axes
svg.selectAll("g .domain")
.style("stroke-width", 2)
.style("fill", "none")
.style("stroke", "black");
svg.selectAll("g .tick text")
.style("font-size", "9pt")
.style("font-weight", "initial");
//estatus normal
svg.append("rect")
.attr("id", "warning_rect")
.attr("x", 3)
.attr("y", 0)
.attr("width", 300)
.attr("height", 200)
.style("fill", "#82B92E");
//controls the inverse warning
if(inverse_w == 0){
svg.append("rect").transition()
.duration(600)
.attr("id", "warning_rect")
.attr("x", 3)
.attr("y", ((range_max - min_w) * position) - ((max_w - min_w) * position))
.attr("width", 300)
.attr("height", ((max_w - min_w) * position))
.style("fill", "#ffd731");
}
else {
svg.append("rect").transition()
.duration(600)
.attr("id", "warning_rect")
.attr("x", 3)
.attr("y", 200 - ((min_w -range_min) * position))
.attr("width", 300)
.attr("height", (min_w -range_min) * position)
.style("fill", "#ffd731");
svg.append("rect").transition()
.duration(600)
.attr("id", "warning_inverse_rect")
.attr("x", 3)
.attr("y", 0)
.attr("width", 300)
.attr("height", ((range_max - min_w) * position) - ((max_w - min_w) * position))
.style("fill", "#ffd731");
}
//controls the inverse critical
if(inverse_c == 0){
svg.append("rect").transition()
.duration(600)
.attr("id", "critical_rect")
.attr("x", 3)
.attr("y", ((range_max - min_c) * position) - ((max_c - min_c) * position))
.attr("width", 300)
.attr("height", ((max_c - min_c) * position))
.style("fill", "#fc4444");
}
else {
svg.append("rect").transition()
.duration(600)
.attr("id", "critical_rect")
.attr("x", 3)
.attr("y", 200 - ((min_c -range_min) * position))
.attr("width", 300)
.attr("height", (min_c -range_min) * position)
.style("fill", "#fc4444");
svg.append("rect").transition()
.duration(600)
.attr("id", "critical_inverse_rect")
.attr("x", 3)
.attr("y", 0)
.attr("width", 300)
.attr("height", ((range_max - min_c) * position) - ((max_c - min_c) * position))
.style("fill", "#fc4444");
}
}
else {
var message_error_warning = '<?php echo __("Please introduce a maximum warning higher than the minimun warning") ?>';
var message_error_critical = '<?php echo __("Please introduce a maximum critical higher than the minimun critical") ?>';
d3.select("#svg_dinamic rect").remove();
//create svg
var svg = d3.select("#svg_dinamic");
svg.selectAll("g").remove();
svg.selectAll("rect").remove();
svg.selectAll("text").remove();
//message error warning
if (error_w == 1) {
$("#text-max_warning").addClass("input_error");
svg.append("text")
.attr("x", -90)
.attr("y", 10)
.attr("fill", 'black')
.style("font-family", "arial")
.style("font-weight", "bold")
.style("font-size", 14)
.style("fill", "red")
.html(message_error_warning)
.style("text-anchor", "first");
}
//message error critical
if (error_c == 1) {
$("#text-max_critical").addClass("input_error");
svg.append("text")
.attr("x", -90)
.attr("y", 105)
.attr("fill", 'black')
.style("font-family", "arial")
.style("font-weight", "bold")
.style("font-size", 14)
.style("fill", "red")
.html(message_error_critical)
.style("text-anchor", "first");
}
}
}
</script>

View File

@ -0,0 +1,61 @@
<?php
/**
* @package Include/help/en
*/
?>
<h1>Dynamic threshold</h1>
<h2>Dynamic threshold Interval</h2>
<p>
Introduce a time period in the Dynamic Threshold Interval field and the module will return the data obtained during the interval. This allows Pandora to establish minimum thresholds of critical and warning status according to the server configuration.
<br><br>
The default setting will <b>only</b> give minimums, so if maximum = 0 it will read from the configured minimum to infinite.
<br><br>
<b>Example:</b><br>
warning status min = 5 and max = 0<br>
critical status min = 10 and max = 0<br>
With these parameters the module will record the following states:<br>
- Status normal from -infinite to 4.<br>
- Status warning from 5 to 9.<br>
- Status critical from 10 to infinite.
<br><br>
<b>Example 2:</b><br>
warning status min = 5 and max = 0 with inverse interval checked<br>
critical status min = 10 and max = 0 with inverse interval checked<br>
With these parameters the module will record the following states:<br>
- Status normal from 10 to infinite.<br>
- Status warning disabled.<br>
- Status critical from 10 to -infinite.
<br><br>
In these examples if the critical threshold coincides with the <b>warning threshold then status will always read as critical.</b>
</p>
<h2>Advanced options dynamic threshold</h2>
<b>Dynamic threshold Min. / Max.</b>
<p>
These fields permit percentage adjustments if it is necessary to extend or reduce dynamically-generated thresholds.
To reduce dynamically-generated thresholds introduce a negative percentage and to extend them introduce a positive percentage. This enables fine-tuning of threshold levels.
</p>
<b>Dynamic threshold Two Tailed:</b>
<p>
This field permits the use of both minimum and maximum ranges, given that the default setting only shows minimums.
</p>
<b>Example:</b><br>
warning status min = 5 and max = 10<br>
critical status min = 10 and max = 15<br>
These parameters mean the module will record the following states:<br>
- Status normal from -infinite to 4 and from 16 to infinite.<br>
- Status warning from 5 to 9.<br>
- Status critical from 10 to 15.
<br><br>
<b>Example 2:</b><br>
warning status min = 40 and max = 80 with inverse interval checked<br>
critical status min = 20 and max = 100 with inverse interval checked<br>
These parameters mean the module will record the following states:<br>
- Status normal from 41 to 79.<br>
- Status warning from 21 to 40 and from 80 to 99.<br>
- Status critical from -infinite to 20 and from 100 to infinite.
<br><br>
<b>For more information, please see the graph showing status according to the values which are introduced.</b>

View File

@ -0,0 +1,62 @@
<?php
/**
* @package Include/help/es
*/
?>
<h1>Dynamic threshold</h1>
<h2>Dynamic threshold Interval</h2>
<p>
Dynamic threshold interval permite introducir un intervalo de tiempo, mediante el cual durante el intervalo definido comprobara los datos que ha tenido el módulo según los resultados obtenidos establecerá los mínimos para los umbrales de critical y warning el intervalo de ejecución depende de la configuración del servidor.
<br><br>
Por defecto <b>Solo</b> dará los minimos con lo cual mientras el máximo es = 0 implica que va desde el minimo mostrado hasta el infinito.
<br><br>
<b>Ejemplo:</b><br>
warning status min = 5 y max = 0<br>
critical status min = 10 y max = 0<br>
Con estos datos nuestro módulo recogerá los siguientes estados:<br>
- Estado normal de -infinito a 4.<br>
- Estado warning de 5 a 9.<br>
- Estado critico de 10 a infinito.
<br><br>
<b>Ejemplo 2:</b><br>
warning status min = 5 y max = 0 con inverse interval seleccionado<br>
critical status min = 10 y max = 0 con inverse interval seleccionado<br>
Con estos datos nuestro módulo recogerá los siguientes estados:<br>
- Estado normal de 10 a infinito.<br>
- Estado warning no estaria nunca en warning.<br>
- Estado critico de 10 a -infinito.
<br><br>
En estos ejemplos hay que tener en cuenta que en caso de que el <b>umbral critical coincida con el umbral warning prevalece critical.</b>
</p>
<h2>Advanced options dynamic threshold</h2>
<b>Dynamic threshold Min. / Max.</b>
<p>
Con estos campos podemos ajustar con porcentajes si queremos ampliar o disminuir los rangos dados dinamicamente.
Si lo que queremos es disminuir los rangos dados dinamicamente introduciriamos porcentajes negativo si lo que queremos es ampliar ese rango estableceremos rangos positivos con lo cual podemos afinar mas aun nuestros umbrales
</p>
<b>Dynamic threshold Two Tailed:</b>
<p>
Con este campo podremos tambien definir si queremos ambos rangos tanto el minimo como el maximo ya que por defecto solo dara los minimos.
</p>
<b>Ejemplo:</b><br>
warning status min = 5 y max = 10<br>
critical status min = 10 y max = 15<br>
Con estos datos nuestro módulo recogerá los siguientes estados:<br>
- Estado normal de -infinito a 4 y de 16 a infinito.<br>
- Estado warning de 5 a 9.<br>
- Estado critico de 10 a 15.
<br><br>
<b>Ejemplo 2:</b><br>
warning status min = 40 y max = 80 con inverse interval seleccionado<br>
critical status min = 20 y max = 100 con inverse interval seleccionado<br>
Con estos datos nuestro módulo recogerá los siguientes estados:<br>
- Estado normal de 41 a 79.<br>
- Estado warning de 21 a 40 y de 80 a 99.<br>
- Estado critico de -infinito a 20 y de 100 a infinito.
<br><br>
<b>Para enterder estos ejemplos mejor utilizar la gráfica que te indicará como estaràn tus estados dependiendo los valores que introduzcas. </b>

View File

@ -1635,6 +1635,9 @@ input[type=image] {
border:0px;
background-color: transparent !important;
}
table#simple{
padding: 30px;
}
table#simple select#id_module_type,
table#alert_search select#id_agent,
table#alert_search select#id_group,
@ -3566,3 +3569,7 @@ color:#82b92e;font-family:Nunito;font-size:10pt;position:relative;top:6px;
.readonly{
background-color: #dedede !important;
}
.input_error {
border: 1px solid red;
}