Validate alerts at the time agents/modules are modified.
Former-commit-id: de1f4d5bbf7abda60a99b3a9718727f73657be75
This commit is contained in:
parent
98c0bbec9a
commit
2626605030
|
@ -868,6 +868,11 @@ if ($update_agent) { // if modified some agent paramenter
|
|||
'config_agents_update_config_token',
|
||||
array($id_agente, 'standby', $disabled ? "1" : "0")
|
||||
);
|
||||
|
||||
// Validate alerts for disabled agents.
|
||||
if ($disabled) {
|
||||
alerts_validate_alert_agent($id_agente);
|
||||
}
|
||||
}
|
||||
|
||||
if($tpolicy_group_old){
|
||||
|
|
|
@ -159,6 +159,11 @@ if ($update_agents) {
|
|||
'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($group_old || $result){
|
||||
|
|
|
@ -1431,6 +1431,32 @@ function alerts_get_effective_alert_actions($id_agent_module) {
|
|||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
|
@ -262,6 +262,11 @@ function modules_change_disabled($id_agent_module, $new_value = 1) {
|
|||
if ($current_disabled == $new_value) {
|
||||
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_module_changed[] = $id_module;
|
||||
|
@ -2817,4 +2822,4 @@ function modules_get_state_condition($state, $prefix = "tae") {
|
|||
// If the state is not an expected state, return no condition
|
||||
return "1=1";
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -171,11 +171,6 @@ sub pandora_purgedb ($$) {
|
|||
if (!defined($conf->{'_string_purge'})){
|
||||
$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) {
|
||||
$ulimit_access_timestamp = time() - 86400;
|
||||
|
|
Loading…
Reference in New Issue