diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 52cefe611c..7aba26bf5e 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2012-02-13 Vanessa Gil + + * util/pandora_manage.pl + lib/PandoraFMS/Core.pm: Added optional parameters to create events. + 2012-02-13 Vanessa Gil * util/pandora_manage.pl: Changed Event validate given id. diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 717b63db1e..68b9d8fa3c 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -1539,12 +1539,18 @@ Generate an event. =cut ########################################################################## -sub pandora_event ($$$$$$$$$$;$) { +sub pandora_event ($$$$$$$$$$;$;$;$;$;$) { my ($pa_config, $evento, $id_grupo, $id_agente, $severity, - $id_alert_am, $id_agentmodule, $event_type, $event_status, $dbh, $source) = @_; - - logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10); + $id_alert_am, $id_agentmodule, $event_type, $event_status, $dbh, $source, $user_name, $criticity, $comment, $id_extra) = @_; + logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 15); + + if (!defined ($comment)) { + $comment = ''; + } + if (!defined ($id_extra)) { + $id_extra = ''; + } # Get module tags my $module_tags = ''; if (defined ($id_agentmodule) && $id_agentmodule > 0) { @@ -1558,8 +1564,8 @@ sub pandora_event ($$$$$$$$$$;$) { my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp)); $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) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, '', $module_tags, $source); + 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) + 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); } ########################################################################## diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index d64cdc49da..c9b20a07e3 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -129,7 +129,7 @@ sub help_screen{ help_screen_line('--disable_eacl', '', 'Disable enterprise ACL system'); help_screen_line('--enable_eacl', '', 'Enable enterprise ACL system'); print "EVENTS:\n\n" unless $param ne ''; - help_screen_line('--create_event', ' [ ]', 'Add event'); + help_screen_line('--create_event', ' [ ]', 'Add event'); help_screen_line('--validate_event', ' ', 'Validate events'); help_screen_line('--validate_event_id', '', 'Validate event given a event id'); print "INCIDENTS:\n\n" unless $param ne ''; @@ -2246,7 +2246,7 @@ sub cli_delete_profile() { ############################################################################## sub cli_create_event() { - my ($event,$event_type,$agent_name,$module_name,$group_name,$event_status,$severity,$template_name) = @ARGV[2..9]; + my ($event,$event_type,$agent_name,$module_name,$group_name,$event_status,$severity,$template_name, $user_name, $criticity, $comment, $source, $id_extra) = @ARGV[2..14]; $event_status = 0 unless defined($event_status); $severity = 0 unless defined($severity); @@ -2296,7 +2296,7 @@ sub cli_create_event() { print "[INFO] Adding event '$event' for agent '$agent_name' \n\n"; pandora_event ($conf, $event, $id_group, $id_agent, $severity, - $id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh); + $id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh, $source, $user_name, $criticity, $comment, $id_extra); } ############################################################################## @@ -3188,9 +3188,9 @@ sub pandora_manage_main ($$$) { cli_delete_profile(); } elsif ($param eq '--create_event') { - param_check($ltotal, 8, 3); + param_check($ltotal, 13, 8); cli_create_event(); - } + } elsif ($param eq '--validate_event') { param_check($ltotal, 7, 6); cli_validate_event();