From 4dd931f2772491f3d0adfd053e85093de573f594 Mon Sep 17 00:00:00 2001 From: Calvo Date: Wed, 24 Nov 2021 11:33:36 +0100 Subject: [PATCH] Modules percentage threshold form --- pandora_console/extras/mr/51.sql | 16 + .../pandoradb_migrate_5.1_to_6.0.mysql.sql | 20 + .../godmode/agentes/agent_template.php | 2 + .../godmode/agentes/configurar_agente.php | 6 + .../godmode/agentes/module_manager.php | 2 + .../godmode/agentes/module_manager_editor.php | 8 + .../agentes/module_manager_editor_common.php | 16 + .../godmode/massive/massive_edit_modules.php | 49 +++ .../modules/manage_network_components.php | 7 + .../manage_network_components_form.php | 6 + .../manage_network_components_form_common.php | 14 + .../manage_network_components_form_wizard.php | 5 + .../include/class/AgentWizard.class.php | 383 +++++++++++------- .../include/functions_network_components.php | 2 + .../include/functions_snmp_browser.php | 6 + .../include/javascript/pandora_modules.js | 21 + pandora_console/include/styles/wizard.css | 6 + pandora_console/pandoradb.sql | 8 + 18 files changed, 434 insertions(+), 143 deletions(-) create mode 100644 pandora_console/extras/mr/51.sql diff --git a/pandora_console/extras/mr/51.sql b/pandora_console/extras/mr/51.sql new file mode 100644 index 0000000000..7449c0abc2 --- /dev/null +++ b/pandora_console/extras/mr/51.sql @@ -0,0 +1,16 @@ +START TRANSACTION; + +ALTER TABLE `tagente_modulo` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0; +ALTER TABLE `tagente_modulo` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0; +ALTER TABLE `tnetwork_component` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0; +ALTER TABLE `tnetwork_component` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0; +ALTER TABLE `tlocal_component` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0; +ALTER TABLE `tlocal_component` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0; +ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0; +ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0; + + + + + +COMMIT; \ No newline at end of file diff --git a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql index 99ccb20643..579cf37b51 100644 --- a/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_5.1_to_6.0.mysql.sql @@ -172,6 +172,8 @@ ALTER TABLE tagente_modulo ADD COLUMN `dynamic_min` bigint(20) default '0'; ALTER TABLE tagente_modulo ADD COLUMN `prediction_sample_window` int(10) default 0; ALTER TABLE tagente_modulo ADD COLUMN `prediction_samples` int(4) default 0; ALTER TABLE tagente_modulo ADD COLUMN `prediction_threshold` int(4) default 0; +ALTER TABLE tagente_modulo ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0; +ALTER TABLE tagente_modulo ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0; -- --------------------------------------------------------------------- -- Table `tagente_estado` @@ -189,3 +191,21 @@ ALTER TABLE tgraph_source ADD COLUMN `id_server` int(11) NOT NULL default 0; -- --------------------------------------------------------------------- ALTER TABLE tevent_filter ADD COLUMN `id_agent_module` int(25) DEFAULT 0; ALTER TABLE tevent_filter ADD COLUMN `id_agent` int(25) DEFAULT 0; + +-- --------------------------------------------------------------------- +-- Table `tevent_filter` +-- --------------------------------------------------------------------- +ALTER TABLE `tnetwork_component` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0; +ALTER TABLE `tnetwork_component` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0; + +-- --------------------------------------------------------------------- +-- Table `tevent_filter` +-- --------------------------------------------------------------------- +ALTER TABLE `tlocal_component` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0; +ALTER TABLE `tlocal_component` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0; + +-- --------------------------------------------------------------------- +-- Table `tevent_filter` +-- --------------------------------------------------------------------- +ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0; +ALTER TABLE `tpolicy_modules` ADD COLUMN `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0; diff --git a/pandora_console/godmode/agentes/agent_template.php b/pandora_console/godmode/agentes/agent_template.php index 20edd4e555..31e6de29b5 100644 --- a/pandora_console/godmode/agentes/agent_template.php +++ b/pandora_console/godmode/agentes/agent_template.php @@ -96,6 +96,8 @@ if (isset($_POST['template_id'])) { 'str_critical' => $row2['str_critical'], 'critical_inverse' => $row2['critical_inverse'], 'warning_inverse' => $row2['warning_inverse'], + 'percentage_warning' => $row2['percentage_warning'], + 'percentage_critical' => $row2['percentage_critical'], 'critical_instructions' => $row2['critical_instructions'], 'warning_instructions' => $row2['warning_instructions'], 'unknown_instructions' => $row2['unknown_instructions'], diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 7383ba4506..b9304f4d2d 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1541,6 +1541,8 @@ if ($update_module || $create_module) { $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'); $id_category = (int) get_parameter('id_category'); @@ -1694,6 +1696,8 @@ if ($update_module) { 'unknown_instructions' => $unknown_instructions, 'critical_inverse' => $critical_inverse, 'warning_inverse' => $warning_inverse, + 'percentage_critical' => $percentage_critical, + 'percentage_warning' => $percentage_warning, 'cron_interval' => $cron_interval, 'id_category' => $id_category, 'disabled_types_event' => addslashes($disabled_types_event), @@ -1900,6 +1904,8 @@ if ($create_module) { 'unknown_instructions' => $unknown_instructions, 'critical_inverse' => $critical_inverse, 'warning_inverse' => $warning_inverse, + 'percentage_critical' => $percentage_critical, + 'percentage_warning' => $percentage_warning, 'cron_interval' => $cron_interval, 'id_category' => $id_category, 'disabled_types_event' => addslashes($disabled_types_event), diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index f8bbc7802a..e8805a7adc 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -704,6 +704,8 @@ if ((bool) $checked === true) { 'quiet', 'critical_inverse', 'warning_inverse', + 'percentage_critical', + 'percentage_warning', 'id_policy_module', ] ); diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 1310fa80bb..c4e62816cb 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -99,6 +99,9 @@ if (is_ajax()) { $component['str_critical'] = io_safe_output($component['str_critical']); $component['warning_inverse'] = (bool) $component['warning_inverse']; $component['critical_inverse'] = (bool) $component['critical_inverse']; + $component['percentage_warning'] = (bool) $component['percentage_warning']; + $component['percentage_critical'] = (bool) $component['percentage_critical']; + echo io_json_mb_encode($component); return; @@ -328,6 +331,9 @@ if ($id_agent_module) { $critical_inverse = $module['critical_inverse']; $warning_inverse = $module['warning_inverse']; + $percentage_critical = $module['percentage_critical']; + $percentage_warning = $module['percentage_warning']; + $id_category = $module['id_category']; @@ -467,6 +473,8 @@ if ($id_agent_module) { $critical_inverse = ''; $warning_inverse = ''; + $percentage_critical = ''; + $percentage_warning = ''; $each_ff = 0; $ff_event_normal = ''; diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index d64d2662fb..7f97a7d1ec 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -459,6 +459,12 @@ if (modules_is_string_type($id_module_type) || $edit) { $table_simple->data[2][1] .= '
'.__('Inverse interval').''; $table_simple->data[2][1] .= html_print_checkbox('warning_inverse', 1, $warning_inverse, true, $disabledBecauseInPolicy); +if (modules_is_string_type($id_module_type) === false) { + $table_simple->data[2][1] .= '
'.__('Percentage').''; + $table_simple->data[2][1] .= html_print_checkbox('percentage_warning', 1, $percentage_warning, true, $disabledBecauseInPolicy); + $table_simple->data[2][1] .= '
'; +} + if (!modules_is_string_type($id_module_type) || $edit) { $table_simple->data[2][2] = ' '; } @@ -512,6 +518,12 @@ if (modules_is_string_type($id_module_type) || $edit) { $table_simple->data[3][1] .= '
'.__('Inverse interval').''; $table_simple->data[3][1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true, $disabledBecauseInPolicy); +if (modules_is_string_type($id_module_type) === false) { + $table_simple->data[3][1] .= '
'.__('Percentage').''; + $table_simple->data[3][1] .= html_print_checkbox('percentage_critical', 1, $percentage_critical, true, $disabledBecauseInPolicy); + $table_simple->data[3][1] .= '
'; +} + $table_simple->data[4][0] = __('Historical data'); if ($disabledBecauseInPolicy) { // If is disabled, we send a hidden in his place and print a false @@ -1551,6 +1563,8 @@ $(document).ready (function () { $('#minmax_critical').show(); $('#minmax_warning').show(); $('#svg_dinamic').show(); + $('#percentage_warning').show(); + $('#percentage_critical').show(); } else { // String types @@ -1559,6 +1573,8 @@ $(document).ready (function () { $('#minmax_critical').hide(); $('#minmax_warning').hide(); $('#svg_dinamic').hide(); + $('#percentage_warning').hide(); + $('#percentage_critical').hide(); } if (type_name_selected.match(/async/) == null) { diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index e64abcd413..ba1e7e7869 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -613,6 +613,26 @@ $table->data['edit1'][1] = ''; ); $table->data['edit1'][1] .= ''; $table->data['edit1'][1] .= ''; + $table->data['edit1'][1] .= ''; + $table->data['edit1'][1] .= ''; + $table->data['edit1'][1] .= ''; + $table->data['edit1'][1] .= ''; $table->data['edit1'][1] .= '
'; + $table->data['edit1'][1] .= ''.__('Percentage').''; + $table->data['edit1'][1] .= ''; + $table->data['edit1'][1] .= html_print_select( + [ + '' => __('No change'), + '1' => __('Yes'), + '0' => __('No'), + ], + 'percentage_warning', + '', + '', + '', + '', + true + ); + $table->data['edit1'][1] .= '
'; $table->data['edit1'][2] = __('Critical status'); @@ -682,6 +702,27 @@ $table->data['edit1'][1] = ''; ); $table->data['edit1'][3] .= ''; $table->data['edit1'][3] .= ''; + + $table->data['edit1'][3] .= ''; + $table->data['edit1'][3] .= ''; + $table->data['edit1'][3] .= ''; + $table->data['edit1'][3] .= ''; $table->data['edit1'][3] .= '
'; + $table->data['edit1'][3] .= ''.__('Percentage').''; + $table->data['edit1'][3] .= ''; + $table->data['edit1'][3] .= html_print_select( + [ + '' => __('No change'), + '1' => __('Yes'), + '0' => __('No'), + ], + 'percentage_critical', + '', + '', + '', + '', + true + ); + $table->data['edit1'][3] .= '
'; $table->data['edit1_1'][0] = ''.__('Description').''; @@ -1571,6 +1612,12 @@ $(document).ready (function () { else if (this.id == "checkbox-warning_inverse") { return; //Do none } + else if (this.id == "checkbox-percentage_critical") { + return; //Do none + } + else if (this.id == "checkbox-percentage_warning") { + return; //Do none + } else if (this.id == "checkbox-critical_inverse") { return; //Do none } @@ -1950,6 +1997,8 @@ function process_manage_edit($module_name, $agents_select=null, $module_status=' 'history_data', 'critical_inverse', 'warning_inverse', + 'percentage_warning', + 'percentage_critical', 'critical_instructions', 'warning_instructions', 'unknown_instructions', diff --git a/pandora_console/godmode/modules/manage_network_components.php b/pandora_console/godmode/modules/manage_network_components.php index 4b3fdab1be..4ab509dbc0 100644 --- a/pandora_console/godmode/modules/manage_network_components.php +++ b/pandora_console/godmode/modules/manage_network_components.php @@ -130,6 +130,9 @@ $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'); + $id_category = (int) get_parameter('id_category'); $id_tag_selected = (array) get_parameter('id_tag_selected'); $pure = get_parameter('pure', 0); @@ -383,6 +386,8 @@ if ($is_management_allowed === true && $create_component) { 'unknown_instructions' => $unknown_instructions, 'critical_inverse' => $critical_inverse, 'warning_inverse' => $warning_inverse, + 'percentage_warning' => $percentage_warning, + 'percentage_critical' => $percentage_critical, 'id_category' => $id_category, 'tags' => $tags, 'disabled_types_event' => $disabled_types_event, @@ -482,6 +487,8 @@ if ($is_management_allowed === true && $update_component) { 'unknown_instructions' => $unknown_instructions, 'critical_inverse' => $critical_inverse, 'warning_inverse' => $warning_inverse, + 'percentage_warning' => $percentage_warning, + 'percentage_critical' => $percentage_critical, 'id_category' => $id_category, 'tags' => $tags, 'disabled_types_event' => $disabled_types_event, diff --git a/pandora_console/godmode/modules/manage_network_components_form.php b/pandora_console/godmode/modules/manage_network_components_form.php index 6776316d54..b26af8bbbe 100644 --- a/pandora_console/godmode/modules/manage_network_components_form.php +++ b/pandora_console/godmode/modules/manage_network_components_form.php @@ -93,6 +93,8 @@ if ($create_network_from_module) { $unknown_instructions = $data_module['unknown_instructions']; $critical_inverse = $data_module['critical_inverse']; $warning_inverse = $data_module['warning_inverse']; + $percentage_critical = $data_module['percentage_critical']; + $percentage_warning = $data_module['percentage_warning']; $id_category = $data_module['id_category']; $ff_event_normal = $data_module['min_ff_event_normal']; $ff_event_warning = $data_module['min_ff_event_warning']; @@ -150,7 +152,9 @@ if (isset($id)) { $warning_instructions = $component['warning_instructions']; $unknown_instructions = $component['unknown_instructions']; $critical_inverse = $component['critical_inverse']; + $percentage_critical = $component['percentage_critical']; $warning_inverse = $component['warning_inverse']; + $percentage_warning = $component['percentage_warning']; $id_category = $component['id_category']; $tags = $component['tags']; $ff_event_normal = $component['min_ff_event_normal']; @@ -233,6 +237,8 @@ if (isset($id)) { $unknown_instructions = ''; $critical_inverse = 0; $warning_inverse = 0; + $percentage_critical = 0; + $percentage_warning = 0; $id_category = 0; $tags = ''; $ff_event_normal = 0; diff --git a/pandora_console/godmode/modules/manage_network_components_form_common.php b/pandora_console/godmode/modules/manage_network_components_form_common.php index d6d6a3ed46..c10b48a4f0 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_common.php +++ b/pandora_console/godmode/modules/manage_network_components_form_common.php @@ -188,6 +188,10 @@ $table->data[4][1] .= html_print_input_text( $table->data[4][1] .= '
'.__('Inverse interval').''; $table->data[4][1] .= html_print_checkbox('warning_inverse', 1, $warning_inverse, true); +$table->data[4][1] .= '
'.__('Percentage').''; +$table->data[4][1] .= html_print_checkbox('percentage_warning', 1, $percentage_warning, true); +$table->data[4][1] .= '
'; + $table->data[4][2] = ' '; $table->colspan[4][2] = 2; $table->rowspan[4][2] = 3; @@ -223,6 +227,11 @@ $table->data[5][1] .= html_print_input_text( $table->data[5][1] .= '
'.__('Inverse interval').''; $table->data[5][1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true); +$table->data[5][1] .= '
'.__('Percentage').''; +$table->data[5][1] .= html_print_checkbox('percentage_critical', 1, $percentage_critical, true); +$table->data[5][1] .= '
'; + + $table->data[6][0] = __('FF threshold'); $table->colspan[6][1] = 3; @@ -518,6 +527,9 @@ $next_row++; $('#string_warning').hide(); $('#minmax_critical').show(); $('#minmax_warning').show(); + $('#percentage_warning').show(); + $('#percentage_critical').show(); + } else { // String types @@ -525,6 +537,8 @@ $next_row++; $('#string_warning').show(); $('#minmax_critical').hide(); $('#minmax_warning').hide(); + $('#percentage_warning').hide(); + $('#percentage_critical').hide(); } }); diff --git a/pandora_console/godmode/modules/manage_network_components_form_wizard.php b/pandora_console/godmode/modules/manage_network_components_form_wizard.php index 4ee77bafb5..9c2ec3c27d 100644 --- a/pandora_console/godmode/modules/manage_network_components_form_wizard.php +++ b/pandora_console/godmode/modules/manage_network_components_form_wizard.php @@ -391,6 +391,8 @@ $data[1] .= html_print_input_text('str_warning', $str_warning, '', 5, 1024, true // Warning inverse values. $data[1] .= '
'.__('Inverse interval').' '; $data[1] .= html_print_checkbox('warning_inverse', 1, $warning_inverse, true); +$data[1] .= '
'.__('Percentage').' '; +$data[1] .= html_print_checkbox('percentage_warning', 1, $percentage_warning, true); $data[2] = ' '; $table->colspan['warning-svg-row'][2] = 2; @@ -427,6 +429,9 @@ $data[1] .= html_print_input_text('str_critical', $str_critical, '', 5, 1024, tr // Critical inverse values. $data[1] .= '
'.__('Inverse interval').' '; $data[1] .= html_print_checkbox('critical_inverse', 1, $critical_inverse, true); +$data[1] .= '
'.__('Percentage').' '; +$data[1] .= html_print_checkbox('percentage_critical', 1, $percentage_critical, true); + push_table_row($data, 'critical-row'); diff --git a/pandora_console/include/class/AgentWizard.class.php b/pandora_console/include/class/AgentWizard.class.php index 13e4264e23..f6b7afdd97 100644 --- a/pandora_console/include/class/AgentWizard.class.php +++ b/pandora_console/include/class/AgentWizard.class.php @@ -1441,6 +1441,10 @@ class AgentWizard extends HTML $result[$value]['criticalInv'] = $data[$k]; } else if (empty(preg_match('/module-warning-inv/', $k)) === false) { $result[$value]['warningInv'] = $data[$k]; + } else if (empty(preg_match('/module-warning-perc/', $k)) === false) { + $result[$value]['warningPerc'] = $data[$k.'_sent']; + } else if (empty(preg_match('/module-critical-perc/', $k)) === false) { + $result[$value]['criticalPerc'] = $data[$k.'_sent']; } else if (empty(preg_match('/module-type/', $k)) === false) { $result[$value]['moduleType'] = $data[$k]; } else if (empty(preg_match('/module-unit/', $k)) === false) { @@ -1856,6 +1860,8 @@ class AgentWizard extends HTML $values['max_warning'] = $candidate['warningMax']; $values['min_critical'] = $candidate['criticalMin']; $values['max_critical'] = $candidate['criticalMax']; + $values['percentage_warning'] = $candidate['warningPerc']; + $values['percentage_critical'] = $candidate['criticalPerc']; } $values['warning_inverse'] = $candidate['warningInv']; @@ -2292,6 +2298,8 @@ class AgentWizard extends HTML $tmp->max_warning($candidate['warningMax']); $tmp->min_critical($candidate['criticalMin']); $tmp->max_critical($candidate['criticalMax']); + $tmp->percentage_warning($candidate['warningPerc']); + $tmp->percentage_critical($candidate['criticalPerc']); } $tmp->warning_inverse($candidate['warningInv']); @@ -2457,6 +2465,8 @@ class AgentWizard extends HTML 'min_critical' => $moduleData['module_thresholds']['min_critical'], 'max_critical' => $moduleData['module_thresholds']['max_critical'], 'inv_critical' => $moduleData['module_thresholds']['inv_critical'], + 'perc_warning' => $moduleData['module_thresholds']['perc_warning'], + 'perc_critical' => $moduleData['module_thresholds']['perc_critical'], 'module_enabled' => $moduleData['default_enabled'], 'name_oid' => $moduleData['value'], 'value' => $moduleData['value'], @@ -2636,6 +2646,8 @@ class AgentWizard extends HTML 'min_critical' => $moduleData['module_thresholds']['min_critical'], 'max_critical' => $moduleData['module_thresholds']['max_critical'], 'inv_critical' => $moduleData['module_thresholds']['inv_critical'], + 'perc_warning' => $moduleData['module_thresholds']['perc_warning'], + 'perc_critical' => $moduleData['module_thresholds']['perc_critical'], 'module_enabled' => $moduleData['module_enabled'], 'current_value' => $currentValue, 'name_oid' => $moduleData['value'], @@ -3280,6 +3292,8 @@ class AgentWizard extends HTML nc.min_critical, nc.max_critical, nc.critical_inverse AS `inv_critical`, + nc.percentage_warning AS `perc_warning`, + nc.percentage_critical AS `perc_critical`, nc.module_enabled, %s, nc.scan_type, @@ -3867,9 +3881,11 @@ class AgentWizard extends HTML $table->width = '100%'; $table->class = 'info_table'; // Subheaders for Warning and Critical columns. - $subheaders = 'Min.'; - $subheaders .= 'Max.'; - $subheaders .= 'Inv.'; + $subheaders = 'Min.'; + $subheaders .= 'Max.'; + $subheaders .= 'Inv.'; + $subheaders .= '%.'; + // Warning header. $warning_header = html_print_div( [ @@ -4081,7 +4097,7 @@ class AgentWizard extends HTML ); $data_warning .= html_print_div( [ - 'class' => 'wizard-column-levels', + 'class' => 'wizard-column-levels-check', 'style' => 'margin-top: 0.3em;', 'content' => html_print_checkbox( 'module-warning-inv-'.$uniqueId, @@ -4096,6 +4112,23 @@ class AgentWizard extends HTML ], true ); + $data_warning .= html_print_div( + [ + 'class' => 'wizard-column-levels-check', + 'style' => 'margin-top: 0.3em;', + 'content' => html_print_checkbox( + 'module-warning-perc-'.$uniqueId, + $module['perc_warning'], + $module['perc_warning'], + true, + false, + '', + false, + 'form="form-create-modules"' + ), + ], + true + ); $data[3] = $data_warning; // Critical column. $data[4] = ''; @@ -4148,7 +4181,7 @@ class AgentWizard extends HTML $data[4] .= html_print_div( [ - 'class' => 'wizard-column-levels', + 'class' => 'wizard-column-levels-check', 'style' => 'margin-top: 0.3em;', 'content' => html_print_checkbox( 'module-critical_inv_'.$uniqueId, @@ -4164,6 +4197,24 @@ class AgentWizard extends HTML true ); + $data[4] .= html_print_div( + [ + 'class' => 'wizard-column-levels-check', + 'style' => 'margin-top: 0.3em;', + 'content' => html_print_checkbox( + 'module-critical-perc-'.$uniqueId, + $module['perc_critical'], + $module['perc_critical'], + true, + false, + '', + false, + 'form="form-create-modules"' + ), + ], + true + ); + if (is_string($module['module_enabled']) === true) { if ($module['module_enabled'] === false || $module['module_enabled'] === '0') { $module['module_enabled'] = false; @@ -4528,12 +4579,14 @@ class AgentWizard extends HTML 'default_enabled' => true, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => $min_warning, - 'max_warning' => $max_warning, - 'inv_warning' => $inv_warning, - 'min_critical' => $min_critical, - 'max_critical' => $max_critical, - 'inv_critical' => $inv_critical, + 'min_warning' => $min_warning, + 'max_warning' => $max_warning, + 'inv_warning' => $inv_warning, + 'min_critical' => $min_critical, + 'max_critical' => $max_critical, + 'inv_critical' => $inv_critical, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; @@ -4583,12 +4636,14 @@ class AgentWizard extends HTML 'default_enabled' => true, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; @@ -4635,12 +4690,14 @@ class AgentWizard extends HTML 'default_enabled' => true, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => $minc, - 'max_critical' => $maxc, - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => $minc, + 'max_critical' => $maxc, + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; } @@ -4723,12 +4780,14 @@ class AgentWizard extends HTML 'module_enabled' => false, 'module_unit' => '%', 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '85', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '85', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; @@ -4760,12 +4819,14 @@ class AgentWizard extends HTML 'module_enabled' => false, 'module_unit' => '%', 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; @@ -4797,12 +4858,14 @@ class AgentWizard extends HTML 'module_enabled' => false, 'module_unit' => '%', 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; } @@ -4826,12 +4889,14 @@ class AgentWizard extends HTML 'default_enabled' => false, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; // IfInDiscards. @@ -4851,12 +4916,14 @@ class AgentWizard extends HTML 'default_enabled' => false, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; // IfOutDiscards. @@ -4876,12 +4943,14 @@ class AgentWizard extends HTML 'default_enabled' => false, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; // IfInErrors. @@ -4901,12 +4970,14 @@ class AgentWizard extends HTML 'default_enabled' => false, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; // IfOutErrors. @@ -4926,12 +4997,14 @@ class AgentWizard extends HTML 'default_enabled' => false, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; @@ -4994,12 +5067,14 @@ class AgentWizard extends HTML 'default_enabled' => true, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; @@ -5020,12 +5095,14 @@ class AgentWizard extends HTML 'default_enabled' => true, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; @@ -5046,12 +5123,14 @@ class AgentWizard extends HTML 'default_enabled' => false, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; // IfOutUcastPkts. @@ -5071,12 +5150,14 @@ class AgentWizard extends HTML 'default_enabled' => false, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; // IfInNUcastPkts. @@ -5096,12 +5177,14 @@ class AgentWizard extends HTML 'default_enabled' => false, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; // IfOutNUcastPkts. @@ -5121,12 +5204,14 @@ class AgentWizard extends HTML 'default_enabled' => false, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; @@ -5189,12 +5274,14 @@ class AgentWizard extends HTML 'default_enabled' => true, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; @@ -5215,12 +5302,14 @@ class AgentWizard extends HTML 'default_enabled' => true, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; @@ -5241,12 +5330,14 @@ class AgentWizard extends HTML 'default_enabled' => false, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; @@ -5267,12 +5358,14 @@ class AgentWizard extends HTML 'default_enabled' => false, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; // IfHCInNUcastPkts. @@ -5292,12 +5385,14 @@ class AgentWizard extends HTML 'default_enabled' => false, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; // IfOutNUcastPkts. @@ -5317,12 +5412,14 @@ class AgentWizard extends HTML 'default_enabled' => false, 'module_enabled' => false, 'module_thresholds' => [ - 'min_warning' => '0', - 'max_warning' => '0', - 'inv_warning' => false, - 'min_critical' => '0', - 'max_critical' => '0', - 'inv_critical' => false, + 'min_warning' => '0', + 'max_warning' => '0', + 'inv_warning' => false, + 'min_critical' => '0', + 'max_critical' => '0', + 'inv_critical' => false, + 'perc_warning' => false, + 'perc_critical' => false, ], ]; diff --git a/pandora_console/include/functions_network_components.php b/pandora_console/include/functions_network_components.php index d85f6d4251..25542ec4bf 100644 --- a/pandora_console/include/functions_network_components.php +++ b/pandora_console/include/functions_network_components.php @@ -532,6 +532,8 @@ function network_components_create_module_from_network_component($id_network_com 'min_ff_event', 'critical_inverse', 'warning_inverse', + 'percentage_warning', + 'percentage_critical', 'module_critical_instructions', 'module_warning_instructions', 'module_unknown_instructions', diff --git a/pandora_console/include/functions_snmp_browser.php b/pandora_console/include/functions_snmp_browser.php index 10bd84ae14..bc0d48137f 100644 --- a/pandora_console/include/functions_snmp_browser.php +++ b/pandora_console/include/functions_snmp_browser.php @@ -1279,6 +1279,8 @@ function snmp_browser_create_modules_snmp( 'unknown_instructions' => '', 'critical_inverse' => 0, 'warning_inverse' => 0, + 'percentage_warning' => 0, + 'percentage_critical' => 0, 'id_category' => 0, 'tags' => '', 'disabled_types_event' => '{"going_unknown":1}', @@ -1336,6 +1338,8 @@ function snmp_browser_create_modules_snmp( 'unknown_instructions' => '', 'critical_inverse' => 0, 'warning_inverse' => 0, + 'percentage_warning' => 0, + 'percentage_critical' => 0, 'id_category' => 0, 'disabled_types_event' => '{"going_unknown":1}', 'min_ff_event_normal' => 0, @@ -1394,6 +1398,8 @@ function snmp_browser_create_modules_snmp( 'unknown_instructions' => '', 'critical_inverse' => 0, 'warning_inverse' => 0, + 'percentage_warning' => 0, + 'percentage_critical' => 0, 'id_category' => 0, 'disabled_types_event' => '{"going_unknown":1}', 'min_ff_event_normal' => 0, diff --git a/pandora_console/include/javascript/pandora_modules.js b/pandora_console/include/javascript/pandora_modules.js index d1b4df6ea5..4a2361d050 100644 --- a/pandora_console/include/javascript/pandora_modules.js +++ b/pandora_console/include/javascript/pandora_modules.js @@ -105,6 +105,8 @@ function configure_modules_form() { $("#text-unit").attr("value", ""); $("#checkbox-critical_inverse").attr("value", 0); $("#checkbox-warning_inverse").attr("value", 0); + $("#checkbox-percentage_warning").attr("value", 0); + $("#checkbox-percentage_critical").attr("value", 0); $("#checkbox-ff_type").attr("value", 0); $("#textarea_critical_instructions").attr("value", ""); $("#textarea_warning_instructions").attr("value", ""); @@ -205,6 +207,16 @@ function configure_modules_form() { data["critical_inverse"] ); $("#checkbox-warning_inverse").prop("uncheck", data["warning_inverse"]); + + $("#checkbox-percentage_warning").prop( + "uncheck", + data["percentage_warning"] + ); + $("#checkbox-percentage_critical").prop( + "uncheck", + data["percentage_critical"] + ); + $("#component_loading").hide(); $("#id_module_type").change(); if ($("#id_category").is("select")) { @@ -464,6 +476,15 @@ function configure_modules_form() { data["critical_inverse"] ); $("#checkbox-warning_inverse").prop("checked", data["warning_inverse"]); + $("#checkbox-percentage_warning").prop( + "uncheck", + data["percentage_warning"] + ); + $("#checkbox-percentage_critical").prop( + "uncheck", + data["percentage_critical"] + ); + $("#component_loading").hide(); $("#id_module_type").change(); if ($("#id_category").is("select")) { diff --git a/pandora_console/include/styles/wizard.css b/pandora_console/include/styles/wizard.css index e47bc9d2ca..4f55f19e3e 100644 --- a/pandora_console/include/styles/wizard.css +++ b/pandora_console/include/styles/wizard.css @@ -148,6 +148,12 @@ ul.wizard li > textarea { text-align: center; } +.wizard-column-levels-check { + float: left; + width: 17%; + text-align: center; +} + .action_button_list { height: 60px; } diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index d8cb8d1d0b..80744b632d 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -267,6 +267,8 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` ( `parent_module_id` int(10) unsigned NOT NULL default 0, `cps` int NOT NULL default 0, `debug_content` varchar(200), + `percentage_critical` tinyint(1) unsigned default '0', + `percentage_warning` tinyint(1) unsigned default '0', PRIMARY KEY (`id_agente_modulo`), KEY `main_idx` (`id_agente_modulo`,`id_agente`), KEY `tam_agente` (`id_agente`), @@ -982,6 +984,8 @@ CREATE TABLE IF NOT EXISTS `tnetwork_component` ( `scan_filters` text NOT NULL, `query_filters` text NOT NULL, `enabled` tinyint(1) UNSIGNED DEFAULT 1, + `percentage_critical` tinyint(1) unsigned default '0', + `percentage_warning` tinyint(1) unsigned default '0', PRIMARY KEY (`id_nc`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -2420,6 +2424,8 @@ CREATE TABLE IF NOT EXISTS `tlocal_component` ( `prediction_sample_window` int(10) default 0, `prediction_samples` int(4) default 0, `prediction_threshold` int(4) default 0, + `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0, + `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0, PRIMARY KEY (`id`), FOREIGN KEY (`id_network_component_group`) REFERENCES tnetwork_component_group(`id_sg`) ON DELETE CASCADE ON UPDATE CASCADE @@ -2500,6 +2506,8 @@ CREATE TABLE IF NOT EXISTS `tpolicy_modules` ( `prediction_samples` int(4) default 0, `prediction_threshold` int(4) default 0, `cps` int NOT NULL DEFAULT 0, + `percentage_warning` tinyint(1) UNSIGNED DEFAULT 0, + `percentage_critical` tinyint(1) UNSIGNED DEFAULT 0, PRIMARY KEY (`id`), KEY `main_idx` (`id_policy`), UNIQUE (`id_policy`, `name`)