Merge branch 'ent-1480-4731-deshabilitado-de-modulos-agencia_aadcm' into 'develop'
Do not add disabled modules to the execution queue. See merge request artica/pandorafms!2456
This commit is contained in:
commit
9096444f8f
|
@ -536,6 +536,12 @@ sub parse_conf_modules($) {
|
|||
# Check for invalid modules
|
||||
next unless (($module->{'name'} ne '' && $module->{'func'} != 0) || $module->{'func'} == \&module_plugin);
|
||||
|
||||
# Skip disabled modules.
|
||||
if (defined($module->{'disabled'}) && $module->{'disabled'} == 1) {
|
||||
log_message('setup', 'Skipping disabled module "' . $module->{'name'} . '"');
|
||||
next;
|
||||
}
|
||||
|
||||
# Set the intensive interval
|
||||
if ($module->{'is_intensive'} == 1) {
|
||||
$module->{'intensive_interval'} = $module->{'interval'};
|
||||
|
|
|
@ -1117,6 +1117,12 @@ Pandora_Module_Factory::getModuleFromDefinition (string definition) {
|
|||
}
|
||||
}
|
||||
|
||||
/* Skip disabled modules */
|
||||
if (module_disabled == "1") {
|
||||
pandoraLog ("Skipping disabled module \"%s\"", module_name.c_str ());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Create module objects */
|
||||
if (module_exec != "") {
|
||||
module = new Pandora_Module_Exec (module_name,
|
||||
|
|
|
@ -1437,32 +1437,11 @@ if ($update_module || $create_module) {
|
|||
|
||||
$module_in_policy = enterprise_hook('policies_is_module_in_policy', [$id_agent_module]);
|
||||
$module_linked = enterprise_hook('policies_is_module_linked', [$id_agent_module]);
|
||||
|
||||
if ((!$module_in_policy && !$module_linked && $update_module)
|
||||
|| ( $module_in_policy && !$module_linked && $update_module)
|
||||
) {
|
||||
enterprise_hook(
|
||||
'config_agents_update_module_in_conf',
|
||||
[
|
||||
$id_agente,
|
||||
io_safe_output($old_configuration_data),
|
||||
io_safe_output($configuration_data),
|
||||
$disabled,
|
||||
]
|
||||
);
|
||||
} else {
|
||||
enterprise_hook(
|
||||
'config_agents_write_module_in_conf',
|
||||
[
|
||||
$id_agente,
|
||||
io_safe_output($old_configuration_data),
|
||||
io_safe_output($configuration_data),
|
||||
$disabled,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize result of the action (insert or update).
|
||||
$success_action = NOERR;
|
||||
|
||||
// MODULE UPDATE.
|
||||
if ($update_module) {
|
||||
$id_agent_module = (int) get_parameter('id_agent_module');
|
||||
|
@ -1598,6 +1577,8 @@ if ($update_module) {
|
|||
break;
|
||||
}
|
||||
|
||||
// I save the result of the action (insert or update).
|
||||
$success_action = $result;
|
||||
$result = false;
|
||||
ui_print_error_message($msg);
|
||||
|
||||
|
@ -1639,6 +1620,9 @@ if ($update_module) {
|
|||
|
||||
// MODULE INSERT.
|
||||
if ($create_module) {
|
||||
// Old configuration data must always be empty in case of creation.
|
||||
$old_configuration_data = '';
|
||||
|
||||
if (isset($_POST['combo_snmp_oid'])) {
|
||||
$combo_snmp_oid = get_parameter_post('combo_snmp_oid');
|
||||
}
|
||||
|
@ -1648,12 +1632,6 @@ if ($create_module) {
|
|||
}
|
||||
|
||||
$id_module = (int) get_parameter('id_module');
|
||||
// Commented because can't create prediction modules
|
||||
/*
|
||||
if ($id_module == 5) {
|
||||
$prediction_module = 1;
|
||||
}
|
||||
*/
|
||||
|
||||
switch ($config['dbtype']) {
|
||||
case 'oracle':
|
||||
|
@ -1777,17 +1755,26 @@ if ($create_module) {
|
|||
break;
|
||||
}
|
||||
|
||||
// I save the result of the action (insert or update).
|
||||
$success_action = $id_agent_module;
|
||||
|
||||
$id_agent_module = false;
|
||||
ui_print_error_message($msg);
|
||||
$edit_module = true;
|
||||
$moduletype = $id_module;
|
||||
db_pandora_audit(
|
||||
'Agent management',
|
||||
"Fail to try added module '$name' for agent ".$agent['alias']
|
||||
'Fail to try added module '.$name.' for agent '.$agent['alias']
|
||||
);
|
||||
} else {
|
||||
if ($prediction_module == 3) {
|
||||
enterprise_hook('modules_create_synthetic_operations', [$id_agent_module, $serialize_ops]);
|
||||
enterprise_hook(
|
||||
'modules_create_synthetic_operations',
|
||||
[
|
||||
$id_agent_module,
|
||||
$serialize_ops,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
// Update the module interval.
|
||||
|
@ -1810,6 +1797,112 @@ if ($create_module) {
|
|||
}
|
||||
}
|
||||
|
||||
// MODULE ENABLE/DISABLE
|
||||
// =====================.
|
||||
if ($enable_module) {
|
||||
$result = modules_change_disabled($enable_module, 0);
|
||||
$module_name = modules_get_agentmodule_name($enable_module);
|
||||
|
||||
// Write for conf disable if remote_config.
|
||||
$configuration_data = enterprise_hook(
|
||||
'config_agents_get_module_from_conf',
|
||||
[
|
||||
$id_agente,
|
||||
io_safe_output($module_name),
|
||||
]
|
||||
);
|
||||
// Force disable.
|
||||
$disabled = 0;
|
||||
|
||||
// Force Update when disabled for save disabled in conf.
|
||||
$old_configuration_data = $configuration_data;
|
||||
|
||||
// Successfull action.
|
||||
$success_action = $result;
|
||||
|
||||
$success_action = $result;
|
||||
if ($result === NOERR) {
|
||||
db_pandora_audit(
|
||||
'Module management',
|
||||
'Enable #'.$enable_module.' | '.$module_name.' | '.$agent['alias']
|
||||
);
|
||||
} else {
|
||||
db_pandora_audit(
|
||||
'Module management',
|
||||
'Fail to enable #'.$enable_module.' | '.$module_name.' | '.$agent['alias']
|
||||
);
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully enabled'),
|
||||
__('Could not be enabled')
|
||||
);
|
||||
}
|
||||
|
||||
if ($disable_module) {
|
||||
$result = modules_change_disabled($disable_module, 1);
|
||||
$module_name = modules_get_agentmodule_name($disable_module);
|
||||
|
||||
// Write for conf disable if remote_config.
|
||||
$configuration_data = enterprise_hook(
|
||||
'config_agents_get_module_from_conf',
|
||||
[
|
||||
$id_agente,
|
||||
io_safe_output($module_name),
|
||||
]
|
||||
);
|
||||
// Force disable.
|
||||
$disabled = 1;
|
||||
|
||||
// Force Update when disabled for save disabled in conf.
|
||||
$old_configuration_data = $configuration_data;
|
||||
|
||||
// Successfull action.
|
||||
$success_action = $result;
|
||||
|
||||
|
||||
if ($result === NOERR) {
|
||||
db_pandora_audit(
|
||||
'Module management',
|
||||
'Disable #'.$disable_module.' | '.$module_name.' | '.$agent['alias']
|
||||
);
|
||||
} else {
|
||||
db_pandora_audit(
|
||||
'Module management',
|
||||
'Fail to disable #'.$disable_module.' | '.$module_name.' | '.$agent['alias']
|
||||
);
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully disabled'),
|
||||
__('Could not be disabled')
|
||||
);
|
||||
}
|
||||
|
||||
// Fix to stop the module from being added to the agent's conf
|
||||
// when an error occurred while updating or inserting. or enable disable module.
|
||||
if ($update_module || $create_module
|
||||
|| $enable_module || $disable_module
|
||||
) {
|
||||
if ((!$module_in_policy && !$module_linked)
|
||||
|| ($module_in_policy && !$module_linked)
|
||||
) {
|
||||
if ($success_action > 0) {
|
||||
enterprise_hook(
|
||||
'config_agents_write_module_in_conf',
|
||||
[
|
||||
$id_agente,
|
||||
io_safe_output($old_configuration_data),
|
||||
io_safe_output($configuration_data),
|
||||
$disabled,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE DELETION
|
||||
// =================.
|
||||
if ($delete_module) {
|
||||
|
@ -2009,46 +2102,6 @@ if (!empty($duplicate_module)) {
|
|||
}
|
||||
}
|
||||
|
||||
// MODULE ENABLE/DISABLE
|
||||
// =====================.
|
||||
if ($enable_module) {
|
||||
$result = modules_change_disabled($enable_module, 0);
|
||||
$modulo_nombre = db_get_row_sql('SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = '.$enable_module.'');
|
||||
$modulo_nombre = $modulo_nombre['nombre'];
|
||||
|
||||
if ($result === NOERR) {
|
||||
enterprise_hook('config_agents_enable_module_conf', [$id_agente, $enable_module]);
|
||||
db_pandora_audit('Module management', 'Enable #'.$enable_module.' | '.$modulo_nombre.' | '.$agent['alias']);
|
||||
} else {
|
||||
db_pandora_audit('Module management', 'Fail to enable #'.$enable_module.' | '.$modulo_nombre.' | '.$agent['alias']);
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully enabled'),
|
||||
__('Could not be enabled')
|
||||
);
|
||||
}
|
||||
|
||||
if ($disable_module) {
|
||||
$result = modules_change_disabled($disable_module, 1);
|
||||
$modulo_nombre = db_get_row_sql('SELECT nombre FROM tagente_modulo WHERE id_agente_modulo = '.$disable_module.'');
|
||||
$modulo_nombre = $modulo_nombre['nombre'];
|
||||
|
||||
if ($result === NOERR) {
|
||||
enterprise_hook('config_agents_disable_module_conf', [$id_agente, $disable_module]);
|
||||
db_pandora_audit('Module management', 'Disable #'.$disable_module.' | '.$modulo_nombre.' | '.$agent['alias']);
|
||||
} else {
|
||||
db_pandora_audit('Module management', 'Fail to disable #'.$disable_module.' | '.$modulo_nombre.' | '.$agent['alias']);
|
||||
}
|
||||
|
||||
ui_print_result_message(
|
||||
$result,
|
||||
__('Successfully disabled'),
|
||||
__('Could not be disabled')
|
||||
);
|
||||
}
|
||||
|
||||
// UPDATE GIS
|
||||
// ==========.
|
||||
$updateGIS = get_parameter('update_gis', 0);
|
||||
|
|
Loading…
Reference in New Issue