2013-09-04 Ramon Novoa <rnovoa@artica.es>
* lib/PandoraFMS/Core.pm: Added support for treating events with the same id_extra as a single event. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8738 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
eed5d0efb4
commit
59054d4401
|
@ -1,3 +1,8 @@
|
||||||
|
2013-09-04 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
|
* lib/PandoraFMS/Core.pm: Added support for treating events with the
|
||||||
|
same id_extra as a single event.
|
||||||
|
|
||||||
2013-09-03 Miguel de Dios <miguel.dedios@artica.es>
|
2013-09-03 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* util/pandora_revent.pl: fixed the script, now runs fine the tags
|
* util/pandora_revent.pl: fixed the script, now runs fine the tags
|
||||||
|
|
|
@ -2520,7 +2520,9 @@ Generate an event.
|
||||||
##########################################################################
|
##########################################################################
|
||||||
sub pandora_event ($$$$$$$$$$;$$$$$$$$$) {
|
sub pandora_event ($$$$$$$$$$;$$$$$$$$$) {
|
||||||
my ($pa_config, $evento, $id_grupo, $id_agente, $severity,
|
my ($pa_config, $evento, $id_grupo, $id_agente, $severity,
|
||||||
$id_alert_am, $id_agentmodule, $event_type, $event_status, $dbh, $source, $user_name, $comment, $id_extra, $tags, $critical_instructions, $warning_instructions, $unknown_instructions) = @_;
|
$id_alert_am, $id_agentmodule, $event_type, $event_status, $dbh,
|
||||||
|
$source, $user_name, $comment, $id_extra, $tags,
|
||||||
|
$critical_instructions, $warning_instructions, $unknown_instructions) = @_;
|
||||||
|
|
||||||
my $agent = undef;
|
my $agent = undef;
|
||||||
if ($id_agente != 0) {
|
if ($id_agente != 0) {
|
||||||
|
@ -2539,9 +2541,7 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10);
|
|
||||||
|
|
||||||
# Get module tags
|
# Get module tags
|
||||||
my $module_tags = '';
|
my $module_tags = '';
|
||||||
if (defined ($tags) && ($tags ne '')) {
|
if (defined ($tags) && ($tags ne '')) {
|
||||||
|
@ -2570,9 +2570,26 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$) {
|
||||||
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp));
|
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp));
|
||||||
$id_agentmodule = 0 unless defined ($id_agentmodule);
|
$id_agentmodule = 0 unless defined ($id_agentmodule);
|
||||||
|
|
||||||
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)
|
# Treat events with the same extended id as a single event
|
||||||
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);
|
my $count = 0;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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=?
|
||||||
|
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, $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)
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
# Do not write to the event file
|
# Do not write to the event file
|
||||||
return if ($pa_config->{'event_file'} eq '');
|
return if ($pa_config->{'event_file'} eq '');
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue