Merge branch 'ent-3305-pandora-db-esta-reseteando-alertas-incorrectamente' into 'develop'
Validate alerts at the time agents/modules are modified. Closes pandora_enterprise#3305 See merge request artica/pandorafms!2155 Former-commit-id: 6dead1fed27249ea1913e70530571d33b76cf3ff
This commit is contained in:
commit
4f158ed61b
|
@ -945,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) {
|
||||||
|
|
|
@ -205,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) {
|
||||||
|
|
|
@ -1700,6 +1700,32 @@ function alerts_get_effective_alert_actions($id_agent_module)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate alerts for the given module.
|
||||||
|
*
|
||||||
|
* @param int agent_module_id ID of the module
|
||||||
|
*/
|
||||||
|
function alerts_validate_alert_module ($agent_module_id) {
|
||||||
|
|
||||||
|
db_process_sql(sprintf('UPDATE talert_template_modules
|
||||||
|
SET times_fired=0, internal_counter=0
|
||||||
|
WHERE id_agent_module = %d',
|
||||||
|
$agent_module_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate alerts for the given agent.
|
||||||
|
*
|
||||||
|
* @param int agent_id ID of the agent
|
||||||
|
*/
|
||||||
|
function alerts_validate_alert_agent ($agent_id) {
|
||||||
|
db_process_sql(sprintf('UPDATE talert_template_modules tm
|
||||||
|
INNER JOIN tagente_modulo am ON tm.id_agent_module = am.id_agente_modulo
|
||||||
|
SET tm.times_fired=0, tm.internal_counter=0
|
||||||
|
WHERE am.id_agente = %d',
|
||||||
|
$agent_id));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates an alert id or an array of alert id's.
|
* Validates an alert id or an array of alert id's.
|
||||||
*
|
*
|
||||||
|
|
|
@ -328,6 +328,10 @@ function modules_change_disabled($id_agent_module, $new_value=1)
|
||||||
if ($current_disabled == $new_value) {
|
if ($current_disabled == $new_value) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// Validate alerts for disabled modules.
|
||||||
|
if ($new_value == 1) {
|
||||||
|
alerts_validate_alert_module($id_module);
|
||||||
|
}
|
||||||
|
|
||||||
$id_agent_changed[] = modules_get_agentmodule_agent($id_module);
|
$id_agent_changed[] = modules_get_agentmodule_agent($id_module);
|
||||||
$id_agent_module_changed[] = $id_module;
|
$id_agent_module_changed[] = $id_module;
|
||||||
|
|
|
@ -171,11 +171,6 @@ sub pandora_purgedb ($$) {
|
||||||
if (!defined($conf->{'_string_purge'})){
|
if (!defined($conf->{'_string_purge'})){
|
||||||
$conf->{'_string_purge'} = 7;
|
$conf->{'_string_purge'} = 7;
|
||||||
}
|
}
|
||||||
# Update alert with last_fired older than today - time_threshold
|
|
||||||
my @templates = get_db_rows ($dbh, 'SELECT t1.id,t1.time_threshold FROM talert_templates t1 WHERE EXISTS ( SELECT * FROM talert_template_modules t2 WHERE t1.id = t2.id_alert_template );');
|
|
||||||
foreach my $template(@templates) {
|
|
||||||
db_do($dbh, 'UPDATE talert_template_modules SET times_fired = 0 WHERE id_alert_template = ? AND times_fired > 0 AND last_fired < (? - ?)',$template->{'id'},time(),$template->{'time_threshold'});
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($conf->{'_string_purge'} > 0) {
|
if ($conf->{'_string_purge'} > 0) {
|
||||||
$ulimit_access_timestamp = time() - 86400;
|
$ulimit_access_timestamp = time() - 86400;
|
||||||
|
|
Loading…
Reference in New Issue