Merged from develop.

Former-commit-id: 438c0bfa6cfa77ef0b75df02f3bce020122692b9
This commit is contained in:
Ramon Novoa 2019-02-12 14:52:18 +01:00
parent 6e236c404b
commit fa7f519d34
3 changed files with 76 additions and 67 deletions

View File

@ -824,23 +824,25 @@ if ($update_agent) {
] ]
); );
# Update the configuration files if ($old_value === false) {
if ($old_values['intervalo'] != $intervalo) { // Create custom field if not exist
enterprise_hook( $update_custom = db_process_sql_insert(
'config_agents_update_config_token', 'tagent_custom_data',
array($id_agente, 'interval', $intervalo) [
'id_field' => $key,
'id_agent' => $id_agente,
'description' => $value,
]
); );
} } else {
if ($old_values['disabled'] != $disabled) { $update_custom = db_process_sql_update(
enterprise_hook( 'tagent_custom_data',
'config_agents_update_config_token', ['description' => $value],
array($id_agente, 'standby', $disabled ? "1" : "0") [
'id_field' => $key,
'id_agent' => $id_agente,
]
); );
// Validate alerts for disabled agents.
if ($disabled) {
alerts_validate_alert_agent($id_agente);
}
}
if ($update_custom == 1) { if ($update_custom == 1) {
$update_custom_result = 1; $update_custom_result = 1;
@ -943,6 +945,10 @@ if ($update_agent) {
$disabled ? '1' : '0', $disabled ? '1' : '0',
] ]
); );
// Validate alerts for disabled agents.
if ($disabled) {
alerts_validate_alert_agent($id_agente);
}
} }
if ($tpolicy_group_old) { if ($tpolicy_group_old) {

View File

@ -63,15 +63,8 @@ if ($update_agents) {
$values['intervalo'] = get_parameter('interval'); $values['intervalo'] = get_parameter('interval');
} }
if ($disabled_old !== false && $disabled_old != $values['disabled']) { if (get_parameter('id_os', '') != -1) {
enterprise_hook( $values['id_os'] = get_parameter('id_os');
'config_agents_update_config_token',
array($id_agent, 'standby', $values['disabled'])
);
// Validate alerts for disabled agents.
if ($values['disabled'] == 1) {
alerts_validate_alert_agent($id_agent);
}
} }
if (get_parameter('id_parent', '') != '') { if (get_parameter('id_parent', '') != '') {
@ -212,6 +205,10 @@ if ($update_agents) {
$values['disabled'], $values['disabled'],
] ]
); );
// Validate alerts for disabled agents.
if ($values['disabled'] == 1) {
alerts_validate_alert_agent($id_agent);
}
} }
if ($group_old || $result) { if ($group_old || $result) {

View File

@ -311,19 +311,23 @@ function modules_copy_agent_module_to_agent($id_agent_module, $id_destiny_agent,
* *
* @return True if the module was disabled. False if not. * @return True if the module was disabled. False if not.
*/ */
function modules_change_disabled($id_agent_module, $new_value = 1) { function modules_change_disabled($id_agent_module, $new_value=1)
{
$id_agent_module = (array) $id_agent_module; $id_agent_module = (array) $id_agent_module;
$id_agent_module_changed = array(); $id_agent_module_changed = [];
foreach ($id_agent_module as $id_module) { foreach ($id_agent_module as $id_module) {
// If the module is already disabled/enabled ignore // If the module is already disabled/enabled ignore
$current_disabled = db_get_value('disabled', 'tagente_modulo', $current_disabled = db_get_value(
'id_agente_modulo', $id_module); 'disabled',
'tagente_modulo',
'id_agente_modulo',
$id_module
);
if ($current_disabled == $new_value) { if ($current_disabled == $new_value) {
continue; continue;
} }
// Validate alerts for disabled modules. // Validate alerts for disabled modules.
if ($new_value == 1) { if ($new_value == 1) {
alerts_validate_alert_module($id_module); alerts_validate_alert_module($id_module);
@ -335,22 +339,24 @@ function modules_change_disabled($id_agent_module, $new_value = 1) {
if (empty($id_agent_module_changed)) { if (empty($id_agent_module_changed)) {
return NOERR; return NOERR;
} } else {
else { $result = db_process_sql_update(
$result = db_process_sql_update('tagente_modulo', 'tagente_modulo',
array('disabled' => (int) $new_value), ['disabled' => (int) $new_value],
array('id_agente_modulo' => $id_agent_module_changed)); ['id_agente_modulo' => $id_agent_module_changed]
);
} }
if ($result) { if ($result) {
// Change the agent flag to update modules count // Change the agent flag to update modules count
db_process_sql_update('tagente', db_process_sql_update(
array('update_module_count' => 1), 'tagente',
array('id_agente' => $id_agent_changed)); ['update_module_count' => 1],
['id_agente' => $id_agent_changed]
);
return NOERR; return NOERR;
} } else {
else {
return ERR_GENERIC; return ERR_GENERIC;
} }
} }