diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 2be3e3d1af..8884c1d631 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -13182,6 +13182,12 @@ function api_set_create_event($id, $trash1, $other, $returnType) $values['id_extra'] = ''; } + if ($other['data'][21] != '') { + $values['event_custom_id'] = $other['data'][21]; + }else{ + $values['event_custom_id'] = ''; + } + $custom_data = base64_decode($values['custom_data']); $custom_data = mysql_escape_string_sql($custom_data); @@ -13204,7 +13210,7 @@ function api_set_create_event($id, $trash1, $other, $returnType) $values['server_id'], $values['id_extra'], $ack_utimestamp, - $values['event_custom_id'] ?? null + $values['event_custom_id'] ); if ($other['data'][12] != '') { diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index c42e993a9a..2bd9b4ef98 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -4273,13 +4273,15 @@ Generate an event. =cut ########################################################################## -#sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$$) { +#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, $user_name, $comment, $id_extra, $tags, $critical_instructions, $warning_instructions, $unknown_instructions, $custom_data, - $module_data, $module_status, $server_id) = @_; + $module_data, $module_status, $server_id, $event_custom_id) = @_; + + $event_custom_id //= ""; my $agent = undef; if (defined($id_agente) && $id_agente != 0) { @@ -4332,7 +4334,7 @@ sub pandora_event { my $utimestamp = time (); my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp)); - my $event_custom_id = undef; + $id_agentmodule = 0 unless defined ($id_agentmodule); # Validate events with the same event id diff --git a/pandora_server/util/pandora_manage.pl b/pandora_server/util/pandora_manage.pl index 63b39f7771..2d010312d9 100755 --- a/pandora_server/util/pandora_manage.pl +++ b/pandora_server/util/pandora_manage.pl @@ -200,7 +200,7 @@ 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 \n\t ]", 'Add event'); + help_screen_line('--create_event', " [ \n\t \n\t \n\t ]", 'Add event'); help_screen_line('--update_event_custom_id', " ", 'Update Event Custom ID'); help_screen_line('--validate_event', " \n\t []", 'Validate events'); help_screen_line('--validate_event_id', '', 'Validate event given a event id'); @@ -4454,7 +4454,7 @@ 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,$force_create_agent,$c_instructions,$w_instructions,$u_instructions,$use_alias,$server_id) = @ARGV[2..21]; + 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,$use_alias,$server_id,$event_custom_id) = @ARGV[2..22]; $event_status = 0 unless defined($event_status); $severity = 0 unless defined($severity); @@ -4513,7 +4513,7 @@ sub cli_create_event() { print_log "[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, safe_input($source), $user_name, safe_input($comment), safe_input($id_extra), safe_input($tags), safe_input($c_instructions), safe_input($w_instructions), safe_input($u_instructions), $custom_data, undef, undef, $server_id); + $id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh, safe_input($source), $user_name, safe_input($comment), safe_input($id_extra), safe_input($tags), safe_input($c_instructions), safe_input($w_instructions), safe_input($u_instructions), $custom_data, undef, undef, $server_id, safe_input($event_custom_id)); } } else { if (! $agent_name) { @@ -4562,7 +4562,7 @@ sub cli_create_event() { print_log "[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, safe_input($source), $user_name, $comment, safe_input($id_extra), safe_input($tags), safe_input($c_instructions), safe_input($w_instructions), safe_input($u_instructions), $custom_data, undef, undef, $server_id); + $id_alert_agent_module, $id_agentmodule, $event_type, $event_status, $dbh, safe_input($source), $user_name, $comment, safe_input($id_extra), safe_input($tags), safe_input($c_instructions), safe_input($w_instructions), safe_input($u_instructions), $custom_data, undef, undef, $server_id, safe_input($event_custom_id)); } } @@ -7943,10 +7943,11 @@ sub pandora_manage_main ($$$) { {'name' => 'warning_instructions'}, {'name' => 'unknown_instructions'}, {'name' => 'use_alias'}, - {'name' => 'metaconsole'} + {'name' => 'metaconsole'}, + {'name' => 'event_custom_id'} ); - param_check($ltotal, 20, 17); + param_check($ltotal, 21, 18); check_values(\@fields);