mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
2013-03-06 Sergio Martin <sergio.martin@artica.es>
* lib/PandoraFMS/Core.pm: Fixed alert fired counts when reset internal counter and fired times in threshold loop git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7797 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
3e23e7c305
commit
45e1716c51
@ -1,3 +1,8 @@
|
|||||||
|
2013-03-06 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
|
* lib/PandoraFMS/Core.pm: Fixed alert fired counts when
|
||||||
|
reset internal counter and fired times in threshold loop
|
||||||
|
|
||||||
2013-03-06 Sergio Martin <sergio.martin@artica.es>
|
2013-03-06 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
* lib/PandoraFMS/Core.pm: Add macros substitution in all the
|
* lib/PandoraFMS/Core.pm: Add macros substitution in all the
|
||||||
|
@ -365,6 +365,11 @@ sub pandora_evaluate_alert ($$$$$$$;$$$) {
|
|||||||
$status = 5;
|
$status = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Update fired alert when cesead or recover
|
||||||
|
if(defined ($agent) && ($status == 3 || $status == 4)) {
|
||||||
|
db_do ($dbh, 'UPDATE tagente SET fired_count=fired_count-1 WHERE id_agente=?', $agent->{'id_agente'});
|
||||||
|
}
|
||||||
|
|
||||||
# Check for valid data
|
# Check for valid data
|
||||||
# Simple alert
|
# Simple alert
|
||||||
if (defined ($alert->{'id_template_module'})) {
|
if (defined ($alert->{'id_template_module'})) {
|
||||||
@ -439,6 +444,12 @@ sub pandora_evaluate_alert ($$$$$$$;$$$) {
|
|||||||
return 2 if (($alert->{'internal_counter'} < $alert->{'min_alerts'}) ||
|
return 2 if (($alert->{'internal_counter'} < $alert->{'min_alerts'}) ||
|
||||||
($alert->{'times_fired'} >= $alert->{'max_alerts'}));
|
($alert->{'times_fired'} >= $alert->{'max_alerts'}));
|
||||||
|
|
||||||
|
# Update fired alert first time
|
||||||
|
# (if is fist time after ceased it was decreased previously and will be compensated)
|
||||||
|
if(defined ($agent)) {
|
||||||
|
db_do ($dbh, 'UPDATE tagente SET fired_count=fired_count+1 WHERE id_agente=?', $agent->{'id_agente'});
|
||||||
|
}
|
||||||
|
|
||||||
return 0; #Launch the alert
|
return 0; #Launch the alert
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,11 +490,6 @@ sub pandora_process_alert ($$$$$$$$;$) {
|
|||||||
db_do($dbh, 'UPDATE ' . $table . ' SET times_fired = 0,
|
db_do($dbh, 'UPDATE ' . $table . ' SET times_fired = 0,
|
||||||
internal_counter = 0 WHERE id = ?', $id);
|
internal_counter = 0 WHERE id = ?', $id);
|
||||||
|
|
||||||
# Update fired alert count
|
|
||||||
if (defined ($agent)) {
|
|
||||||
db_do ($dbh, 'UPDATE tagente SET fired_count=fired_count-1 WHERE id_agente=?', $agent->{'id_agente'});
|
|
||||||
}
|
|
||||||
|
|
||||||
# Critical_instructions, warning_instructions, unknown_instructions
|
# Critical_instructions, warning_instructions, unknown_instructions
|
||||||
my $critical_instructions = get_db_value ($dbh, 'SELECT critical_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
|
my $critical_instructions = get_db_value ($dbh, 'SELECT critical_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
|
||||||
my $warning_instructions = get_db_value ($dbh, 'SELECT warning_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
|
my $warning_instructions = get_db_value ($dbh, 'SELECT warning_instructions FROM tagente_modulo WHERE id_agente_modulo = ?', $alert->{'id_agent_module'});
|
||||||
@ -517,11 +523,6 @@ sub pandora_process_alert ($$$$$$$$;$) {
|
|||||||
db_do($dbh, 'UPDATE talert_template_module_actions SET last_execution = 0 WHERE id_alert_template_module = ?', $id);
|
db_do($dbh, 'UPDATE talert_template_module_actions SET last_execution = 0 WHERE id_alert_template_module = ?', $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update fired alert count
|
|
||||||
if (defined ($agent)) {
|
|
||||||
db_do ($dbh, 'UPDATE tagente SET fired_count=fired_count-1 WHERE id_agente=?', $agent->{'id_agente'});
|
|
||||||
}
|
|
||||||
|
|
||||||
pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 0, $dbh, $timestamp, $extra_macros);
|
pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 0, $dbh, $timestamp, $extra_macros);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -541,7 +542,6 @@ sub pandora_process_alert ($$$$$$$$;$) {
|
|||||||
|
|
||||||
# Increment internal counter
|
# Increment internal counter
|
||||||
if ($rc == 2) {
|
if ($rc == 2) {
|
||||||
|
|
||||||
# Update alert status
|
# Update alert status
|
||||||
$alert->{'internal_counter'} += 1;
|
$alert->{'internal_counter'} += 1;
|
||||||
|
|
||||||
@ -555,7 +555,6 @@ sub pandora_process_alert ($$$$$$$$;$) {
|
|||||||
|
|
||||||
# Execute
|
# Execute
|
||||||
if ($rc == 0) {
|
if ($rc == 0) {
|
||||||
|
|
||||||
# Update alert status
|
# Update alert status
|
||||||
$alert->{'times_fired'} += 1;
|
$alert->{'times_fired'} += 1;
|
||||||
$alert->{'internal_counter'} += 1;
|
$alert->{'internal_counter'} += 1;
|
||||||
@ -564,11 +563,6 @@ sub pandora_process_alert ($$$$$$$$;$) {
|
|||||||
last_fired = ?, internal_counter = ? ' . $new_interval . ' WHERE id = ?',
|
last_fired = ?, internal_counter = ? ' . $new_interval . ' WHERE id = ?',
|
||||||
$alert->{'times_fired'}, $utimestamp, $alert->{'internal_counter'}, $id);
|
$alert->{'times_fired'}, $utimestamp, $alert->{'internal_counter'}, $id);
|
||||||
|
|
||||||
# Update fired alert count only in first fired time
|
|
||||||
if (defined ($agent) && $alert->{'times_fired'} == 1) {
|
|
||||||
db_do ($dbh, 'UPDATE tagente SET fired_count=fired_count+1 WHERE id_agente=?', $agent->{'id_agente'});
|
|
||||||
}
|
|
||||||
|
|
||||||
pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 1, $dbh, $timestamp, $extra_macros);
|
pandora_execute_alert ($pa_config, $data, $agent, $module, $alert, 1, $dbh, $timestamp, $extra_macros);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user