Added enable MADE option to modules and bulk op

This commit is contained in:
Calvo 2023-08-31 18:07:26 +02:00
parent 0d4a097a48
commit 2fc08b7246
9 changed files with 101 additions and 9 deletions

View File

@ -0,0 +1,11 @@
pandorafms.vmware=d41d8cd98f00b204e9800998ecf8427e
pandorafms.mysql=d41d8cd98f00b204e9800998ecf8427e
pandorafms.mssql=d41d8cd98f00b204e9800998ecf8427e
pandorafms.oracle=d41d8cd98f00b204e9800998ecf8427e
pandorafms.db2=d41d8cd98f00b204e9800998ecf8427e
pandorafms.sap.deset=d41d8cd98f00b204e9800998ecf8427e
pandorafms.gcp.ce=d41d8cd98f00b204e9800998ecf8427e
pandorafms.aws.ec2=d41d8cd98f00b204e9800998ecf8427e
pandorafms.aws.s3=d41d8cd98f00b204e9800998ecf8427e
pandorafms.aws.rds=d41d8cd98f00b204e9800998ecf8427e
pandorafms.azure.mc=d41d8cd98f00b204e9800998ecf8427e

View File

@ -1,3 +1,4 @@
-- Active: 1685706586212@@172.16.0.2@3306@pandora
START TRANSACTION;
@ -9,5 +10,8 @@ UPDATE `twelcome_tip`
UPDATE tagente_modulo SET `tcp_send` = '2c' WHERE `tcp_send` = '2';
UPDATE tpolicy_modules SET `tcp_send` = '2c' WHERE `tcp_send` = '2';
UPDATE tnetwork_component SET `tcp_send` = '2c' WHERE `tcp_send` = '2';
ALTER TABLE tagente_modulo ADD COLUMN `made_enabled` TINYINT UNSIGNED DEFAULT 0;
ALTER TABLE tpolicy_modules ADD COLUMN `made_enabled` TINYINT UNSIGNED DEFAULT 0;
COMMIT;

View File

@ -1333,6 +1333,12 @@ if ($update_module === true || $create_module === true) {
*/
$post_process = (string) get_parameter('post_process', 0.0);
if (modules_is_string_type($id_module_type) === false) {
$made_enabled = (bool) get_parameter_checkbox('made_enabled', 0);
} else {
$made_enabled = false;
}
$prediction_module = (int) get_parameter('prediction_module');
$max_timeout = (int) get_parameter('max_timeout');
$max_retries = (int) get_parameter('max_retries');
@ -1711,6 +1717,7 @@ if ($update_module) {
'plugin_parameter' => $plugin_parameter,
'id_plugin' => $id_plugin,
'post_process' => $post_process,
'made_enabled' => $made_enabled,
'prediction_module' => $prediction_module,
'max_timeout' => $max_timeout,
'max_retries' => $max_retries,
@ -1909,6 +1916,7 @@ if ($create_module) {
'plugin_parameter' => $plugin_parameter,
'id_plugin' => $id_plugin,
'post_process' => $post_process,
'made_enabled' => $made_enabled,
'prediction_module' => $prediction_module,
'max_timeout' => $max_timeout,
'max_retries' => $max_retries,

View File

@ -294,6 +294,7 @@ if ($id_agent_module) {
$plugin_parameter = $module['plugin_parameter'];
$id_plugin = $module['id_plugin'];
$post_process = $module['post_process'];
$made_enabled = $module['made_enabled'];
$prediction_module = $module['prediction_module'];
$custom_integer_1 = $module['custom_integer_1'];
$custom_integer_2 = $module['custom_integer_2'];
@ -408,6 +409,7 @@ if ($id_agent_module) {
$id_module_group = 1;
$id_module_type = 1;
$post_process = '';
$made_enabled = false;
$max_timeout = 0;
$max_retries = 0;
$min = '';

View File

@ -1376,6 +1376,24 @@ $table_advanced->data['process_unit'][1] = html_print_extended_select_for_post_p
$disabledBecauseInPolicy
);
$table_advanced->rowclass['caption_made_enabled'] = 'w50p';
$table_advanced->rowclass['made_enabled'] = 'w50p';
$table_advanced->data['caption_made_enabled'][0] = __('MADE enabled').ui_print_help_tip(
__('By activating this option, the module data will be processed by the MADE engine (if active), and events will be generated automatically by the IA engine'),
true
);
$table_advanced->data['made_enabled'][0] = html_print_checkbox_switch(
'made_enabled',
1,
(bool) $made_enabled,
false,
false,
'',
false,
false,
'wp100 static'
);
$table_advanced->data['title_5'] = html_print_subtitle_table(__('Notifications and alerts'));
$table_advanced->data['caption_export_target'][0] = __('Export target');
@ -1882,6 +1900,8 @@ $(document).ready (function () {
$('#percentage_critical').show();
// Show dinamic reference.
$('#svg_dinamic').show();
$('#advanced-made_enabled').show();
$('#advanced-caption_made_enabled').show();
}
else {
// Show string fields.
@ -1902,6 +1922,8 @@ $(document).ready (function () {
$('#percentage_critical').hide();
// Hide dinamic reference.
$('#svg_dinamic').hide();
$('#advanced-made_enabled').hide();
$('#advanced-caption_made_enabled').hide();
}
if (type_name_selected.match(/async/) == null) {

View File

@ -916,7 +916,24 @@ $table->data[17][0] = html_print_label_input_block(
)
);
$table->data[17][1] = html_print_label_input_block(
$table->data['made_enabled'][1] = html_print_label_input_block(
__('MADE enabled').ui_print_help_tip(
__('By activating this option, the module data will be processed by the MADE engine (if active), and events will be generated automatically by the IA engine'),
true
),
html_print_checkbox_switch(
'made_enabled',
1,
false,
true,
false,
'',
false,
'wp100 static'
)
);
$table->data[17][2] = html_print_label_input_block(
__('SNMP community'),
html_print_input_text(
'snmp_community',
@ -1654,6 +1671,7 @@ $(document).ready (function () {
"tr#delete_table-37, " +
"tr#delete_table-38, " +
"tr#delete_table-39, " +
"tr#delete_table-made_enabled, " +
"tr#delete_table-40").hide();
var params = {
@ -1729,6 +1747,7 @@ $(document).ready (function () {
"tr#delete_table-37, " +
"tr#delete_table-38, " +
"tr#delete_table-39, " +
"tr#delete_table-made_enabled, " +
"tr#delete_table-40").show ();
switch($('#module_type').val()) {
@ -1839,6 +1858,7 @@ $(document).ready (function () {
"tr#delete_table-37, " +
"tr#delete_table-38, " +
"tr#delete_table-39, " +
"tr#delete_table-made_enabled, " +
"tr#delete_table-40").hide ();
$('input[type=checkbox]').attr('checked', false);
$('input[type=checkbox]').attr('disabled', true);
@ -1878,6 +1898,7 @@ $(document).ready (function () {
"tr#delete_table-37, " +
"tr#delete_table-38, " +
"tr#delete_table-39, " +
"tr#delete_table-made_enabled, " +
"tr#delete_table-40").show();
}
else {
@ -1909,6 +1930,7 @@ $(document).ready (function () {
"tr#delete_table-37, " +
"tr#delete_table-38, " +
"tr#delete_table-39, " +
"tr#delete_table-made_enabled, " +
"tr#delete_table-40").hide();
}
}
@ -1932,6 +1954,9 @@ $(document).ready (function () {
else if (this.id == "checkbox-dynamic_two_tailed") {
return; //Do none
}
else if (this.id == "checkbox-made_enabled") {
return; //Do none
}
else {
if (this.id == "checkbox-force_group") {
$("#checkbox-recursion").prop("checked", false);
@ -1996,6 +2021,7 @@ $(document).ready (function () {
"tr#delete_table-37, " +
"tr#delete_table-38, " +
"tr#delete_table-39, " +
"tr#delete_table-made_enabled, " +
"tr#delete_table-40").hide();
}
}
@ -2086,6 +2112,7 @@ $(document).ready (function () {
"tr#delete_table-37, " +
"tr#delete_table-38, " +
"tr#delete_table-39, " +
"tr#delete_table-made_enabled, " +
"tr#delete_table-40").hide();
jQuery.post ("ajax.php",
@ -2315,6 +2342,7 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
'module_interval',
'disabled',
'post_process',
'made_enabled',
'unit_select',
'snmp_community',
'snmp_oid',
@ -2626,6 +2654,10 @@ function process_manage_edit($module_name, $agents_select=null, $module_status='
$values['macros'] = json_encode($module_macros);
}
if (modules_is_string_type($module['id_tipo_modulo']) === true) {
$values['made_enabled'] = 0;
}
$result = modules_update_agent_module(
$module['id_agente_modulo'],
$values,

View File

@ -482,6 +482,13 @@ if (check_login()) {
'tagente_modulo',
['id_agente_modulo' => $module_id]
);
$made_enabled = db_get_value_filter(
'made_enabled',
'tagente_modulo',
['id_agente_modulo' => $module_id]
);
$unit = db_get_value_filter(
'unit',
'tagente_modulo',

View File

@ -391,6 +391,10 @@ class Module extends Entity
$keyName = 'postprocess';
}
if ($methodName === 'made_enabled') {
$keyName = 'madeEnabled';
}
if ($methodName === 'max_timeout') {
$keyName = 'timeout';
}

View File

@ -174,6 +174,7 @@ CREATE TABLE IF NOT EXISTS `tagente_estado` (
`last_unknown_update` BIGINT NOT NULL DEFAULT 0,
`last_status_change` BIGINT NOT NULL DEFAULT 0,
`warning_count` INT UNSIGNED DEFAULT 0,
`made_enambled` TINYINT UNSIGNED DEFAULT 0,
PRIMARY KEY (`id_agente_estado`),
KEY `status_index_1` (`id_agente_modulo`),
KEY `idx_agente` (`id_agente`),
@ -2570,6 +2571,7 @@ CREATE TABLE IF NOT EXISTS `tpolicy_modules` (
`percentage_warning` TINYINT UNSIGNED DEFAULT 0,
`percentage_critical` TINYINT UNSIGNED DEFAULT 0,
`warning_time` INT UNSIGNED DEFAULT 0,
`made_enabled` TINYINT UNSIGNED DEFAULT 0,
PRIMARY KEY (`id`),
KEY `main_idx` (`id_policy`),
UNIQUE (`id_policy`, `name`)