From c8c5ed519958e6a18d2fa634aa11525c65e19c19 Mon Sep 17 00:00:00 2001 From: zarzuelo Date: Fri, 14 Jun 2013 10:47:26 +0000 Subject: [PATCH] 2013-06-14 Sergio Martin * lib/PandoraFMS/Core.pm: Fixed comments addition in the events with the internal action Create Pandora FMS event git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8328 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 +++++ pandora_server/lib/PandoraFMS/Core.pm | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index aa5e72fba1..2fb590657d 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2013-06-14 Sergio Martin + + * lib/PandoraFMS/Core.pm: Fixed comments addition in the + events with the internal action Create Pandora FMS event + 2013-06-13 SAncho Lerena * pandora_server.redhat.spec: Fixed some path permissions. diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 7a590007b6..7e76dc5554 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -893,6 +893,14 @@ sub pandora_execute_action ($$$$$$$$$;$) { # Field 8 (comments); my $comment = $field8; + if($comment ne '') { + # Get datetime for the comment of the event + my $datetime = strftime( "%F, %H:%M:%S %p", localtime(time)); + + # This format is necessary for the ugly parser of event comments. Will be changed in the future to json + $comment = "-- Added comment by an alert [" . $datetime . "] --
" . $comment . "
"; + } + pandora_event ($pa_config, $event_text, (defined ($agent) ? $agent->{'id_grupo'} : 0), (defined ($fullagent) ? $fullagent->{'id_agente'} : 0), $priority, 0, 0, $event_type, 0, $dbh, $source, '', $comment, $id_extra, $tags); # Validate event (field1: agent name; field2: module name) } elsif ($clean_name eq "Validate Event") { @@ -3490,7 +3498,7 @@ sub pandora_process_event_replication ($) { # Get the metaconsole DB connection my $dbh_metaconsole = enterprise_hook('get_metaconsole_dbh', [$pa_config, $dbh]); - + if($dbh_metaconsole eq '') { logger($pa_config, "Metaconsole DB connection error. Event replication thread will be aborted.", 1); return;