2013-09-13 Ramon Novoa <rnovoa@artica.es>

* lib/PandoraFMS/Core.pm: Validate existing events with the same 'ID extra' instead
	  of treating them as a single event.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8765 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
Ramon Novoa 2013-09-13 13:33:11 +00:00
parent 27b30523d0
commit d7f4ce1ead
2 changed files with 11 additions and 15 deletions

View File

@ -1,3 +1,8 @@
2013-09-13 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Core.pm: Validate existing events with the same 'ID extra' instead
of treating them as a single event.
2013-09-12 Ramon Novoa <rnovoa@artica.es>
* NetBSD/pandora_server.conf,

View File

@ -2586,25 +2586,16 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$) {
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp));
$id_agentmodule = 0 unless defined ($id_agentmodule);
# Treat events with the same extended id as a single event
my $count = 0;
# Validate events with the same event id
if (defined ($id_extra) && $id_extra ne '') {
$count = get_db_value ($dbh, 'SELECT COUNT(*) FROM tevento WHERE id_extra=?', $id_extra);
$count = 0 unless defined ($count);
logger($pa_config, "Updating events with extended id '$id_extra'.", 10);
db_do ($dbh, 'UPDATE tevento SET estado = 1, ack_utimestamp = ? WHERE estado = 0 AND id_extra=?', $utimestamp, $id_extra);
}
# Update or create the event
if ($count > 0) {
logger($pa_config, "Updating event '$evento' with extended id '$id_extra' for agent ID $id_agente module ID $id_agentmodule.", 10);
db_do ($dbh, 'UPDATE tevento SET id_agente=?, id_grupo=?, evento=?, timestamp=?, estado=?, utimestamp=?, event_type=?, id_agentmodule=?, id_alert_am=?, criticity=?, user_comment=?, tags=?, source=?, id_extra=?, id_usuario=?, critical_instructions=?, warning_instructions=?, unknown_instructions=?, ack_utimestamp=?, custom_data=?
WHERE id_extra=?', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $comment, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, $id_extra);
} else {
logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10);
db_do ($dbh, 'INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, user_comment, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $comment, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data);
}
# Do not write to the event file
return if ($pa_config->{'event_file'} eq '');