diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index fe34c2ebdb..5acd48e5df 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -2350,6 +2350,8 @@ function events_page_general ($event) { } $table_general->data[] = $data; + $event["owner_user"] = $event["id_usuario"]; + $data = array(); $data[0] = __('Owner'); if (empty($event["owner_user"])) { diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index a79b780770..5857e8eca8 100644 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -173,11 +173,11 @@ sub help_screen{ help_screen_line('--enable_eacl', '', 'Enable enterprise ACL system'); help_screen_line('--disable_double_auth', '', 'Disable the double authentication for the specified user'); print "\nEVENTS:\n\n" unless $param ne ''; - help_screen_line('--create_event', " [ \n\t \n\t ]", 'Add event'); - help_screen_line('--validate_event', " \n\t ", 'Validate events'); - help_screen_line('--validate_event_id', '', 'Validate event given a event id'); - help_screen_line('--get_event_info', '[]', 'Show info about a event given a event id'); - help_screen_line('--add_event_comment', ' ', 'Add event\'s comment'); + help_screen_line('--create_event', " [ \n\t \n\t \n\t ]", 'Add event'); + help_screen_line('--validate_event', " \n\t ", 'Validate events'); + help_screen_line('--validate_event_id', '', 'Validate event given a event id'); + help_screen_line('--get_event_info', '[]', 'Show info about a event given a event id'); + help_screen_line('--add_event_comment', ' ', 'Add event\'s comment'); print "\nINCIDENTS:\n\n" unless $param ne ''; help_screen_line('--create_incident', " <description> <origin> <status> <priority 0 for Informative, \n\t 1 for Low, 2 for Medium, 3 for Serious, 4 for Very serious or 5 for Maintenance>\n\t <group> [<owner>]", 'Create incidents'); print "\nPOLICIES:\n\n" unless $param ne ''; @@ -3063,14 +3063,14 @@ sub cli_delete_profile() { ############################################################################## sub cli_create_event() { - my ($event,$event_type,$group_name,$agent_name,$module_name,$event_status,$severity,$template_name, $user_name, $comment, $source, $id_extra, $tags, $custom_data) = @ARGV[2..15]; + my ($event,$event_type,$group_name,$agent_name,$module_name,$event_status,$severity,$template_name, $user_name, $comment, $source, $id_extra, $tags, $custom_data,$force_create_agent,$c_instructions,$w_instructions,$u_instructions) = @ARGV[2..19]; $event_status = 0 unless defined($event_status); $severity = 0 unless defined($severity); my $id_user; - if (!defined($user_name)) { + if (!defined($user_name) || $user_name eq '') { $id_user = 0; } else { @@ -3095,7 +3095,18 @@ sub cli_create_event() { } else { $id_agent = get_agent_id($dbh,$agent_name); - exist_check($id_agent,'agent',$agent_name); + # exist_check($id_agent,'agent',$agent_name); + if($id_agent == -1){ + if($force_create_agent == 1){ + pandora_create_agent ($conf, '', $agent_name, '', '', '', '', 'Created by cli_create_event', '', $dbh); + print_log "[INFO] Adding agent '$agent_name' \n\n"; + $id_agent = get_agent_id($dbh,$agent_name); + } + else{ + exist_check($id_agent,'agent',$agent_name); + } + } + } my $id_agentmodule; @@ -3129,7 +3140,7 @@ sub cli_create_event() { $custom_data = encode_base64 ($custom_data); pandora_event ($conf, $event, $id_group, $id_agent, $severity, - $id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh, $source, $user_name, $comment, $id_extra, $tags, '', '', '', $custom_data); + $id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh, $source, $user_name, $comment, $id_extra, $tags, $c_instructions, $w_instructions, $u_instructions, $custom_data); } ############################################################################## @@ -4880,7 +4891,7 @@ sub pandora_manage_main ($$$) { cli_delete_profile(); } elsif ($param eq '--create_event') { - param_check($ltotal, 14, 11); + param_check($ltotal, 18, 15); cli_create_event(); } elsif ($param eq '--validate_event') {