From e33fadb8eb151bb104c9198fc765ed05743d4bbe Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 18 Apr 2023 09:31:22 +0200 Subject: [PATCH] #10974 Warning threshold Inverse Interval and Critical threshold Inverse Interval set --- .../godmode/agentes/configurar_agente.php | 29 ++++++++++++++++--- .../agentes/module_manager_editor_common.php | 14 ++++----- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index f5a9278a68..e8dce4d9b2 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1519,10 +1519,31 @@ if ($update_module === true || $create_module === true) { $critical_instructions = (string) get_parameter('critical_instructions'); $warning_instructions = (string) get_parameter('warning_instructions'); $unknown_instructions = (string) get_parameter('unknown_instructions'); - $critical_inverse = (int) get_parameter('critical_inverse'); - $warning_inverse = (int) get_parameter('warning_inverse'); - $percentage_critical = (int) get_parameter('percentage_critical'); - $percentage_warning = (int) get_parameter('percentage_warning'); + // Warning thresholds + $warning_threshold_check_type = get_parameter('warning_thresholds_checks'); + if ($warning_threshold_check_type === 'normal_warning') { + $percentage_warning = 0; + $warning_inverse = 0; + } else if ($warning_threshold_check_type === 'warning_inverse') { + $warning_inverse = (int) get_parameter('warning_inverse_string_sent'); + $percentage_warning = 0; + } else { + $percentage_warning = (int) get_parameter('warning_inverse_string_sent'); + $warning_inverse = 0; + } + + // Critical thresholds + $critical_threshold_check_type = get_parameter('critical_thresholds_checks'); + if ($critical_threshold_check_type === 'normal_critical') { + $percentage_critical = 0; + $critical_inverse = 0; + } else if ($critical_threshold_check_type === 'critical_inverse') { + $critical_inverse = (int) get_parameter('critical_inverse_string_sent'); + $percentage_critical = 0; + } else { + $percentage_critical = (int) get_parameter('critical_inverse_string_sent'); + $critical_inverse = 0; + } $id_category = (int) get_parameter('id_category'); diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index f80313287a..2c4f3777cb 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -473,9 +473,9 @@ $tableBasicThresholds->data['warning_threshold'][1] .= html_print_input_text( $tableBasicThresholds->data['switch_warning_threshold'][0] .= html_print_switch_radio_button( [ - html_print_radio_button_extended('warning_thresholds_checks', 'normal_warning', __('Normal'), ($percentage_warning && $warning_inverse) === false, false, '', '', true, false, '', 'radius-normal_warning'), - html_print_radio_button_extended('warning_thresholds_checks', 'warning_inverse', __('Inverse interval'), $warning_inverse, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-warning_inverse'), - html_print_radio_button_extended('warning_thresholds_checks', 'percentage_warning', __('Percentage'), $percentage_warning, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-percentage_warning'), + html_print_radio_button_extended('warning_thresholds_checks', 'normal_warning', __('Normal'), ($percentage_warning && $warning_inverse) ? false : 'normal_warning', false, '', '', true, false, '', 'radius-normal_warning'), + html_print_radio_button_extended('warning_thresholds_checks', 'warning_inverse', __('Inverse interval'), ($warning_inverse) ? 'warning_inverse' : false, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-warning_inverse'), + html_print_radio_button_extended('warning_thresholds_checks', 'percentage_warning', __('Percentage'), ($percentage_warning) ? 'percentage_warning' : false, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-percentage_warning'), ], [ 'class' => 'margin-top-10' ], true @@ -556,9 +556,9 @@ $tableBasicThresholds->data['critical_threshold'][1] .= html_print_input_text( $tableBasicThresholds->data['switch_critical_threshold'][0] .= html_print_switch_radio_button( [ - html_print_radio_button_extended('critical_thresholds_checks', 'normal_critical', __('Normal'), ($percentage_critical && $critical_inverse) === false, false, '', '', true, false, '', 'radius-normal_critical'), - html_print_radio_button_extended('critical_thresholds_checks', 'critical_inverse', __('Inverse interval'), $critical_inverse, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-critical_inverse'), - html_print_radio_button_extended('critical_thresholds_checks', 'percentage_critical', __('Percentage'), $percentage_critical, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-percentage_critical'), + html_print_radio_button_extended('critical_thresholds_checks', 'normal_critical', __('Normal'), ($percentage_critical && $critical_inverse) ? false : 'normal_critical', false, '', '', true, false, '', 'radius-normal_critical'), + html_print_radio_button_extended('critical_thresholds_checks', 'critical_inverse', __('Inverse interval'), ($critical_inverse) ? 'critical_inverse' : false, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-critical_inverse'), + html_print_radio_button_extended('critical_thresholds_checks', 'percentage_critical', __('Percentage'), ($percentage_critical) ? 'percentage_critical' : false, $disabledBecauseInPolicy, '', '', true, false, '', 'radius-percentage_critical'), ], [ 'class' => 'margin-top-10' ], true @@ -1978,7 +1978,7 @@ $(document).ready (function () { } }); - + });