#11705 group extra id heredity event custom id

This commit is contained in:
Jonathan 2023-09-25 12:22:10 +02:00
parent e5c5f91576
commit 70e3707b64
4 changed files with 12 additions and 6 deletions

View File

@ -733,7 +733,7 @@ $table->data[$i++][] = html_print_label_input_block(
); );
$help_tip = ui_print_help_tip( $help_tip = ui_print_help_tip(
__('If there are any "In process" events with a specific Extra ID and a New event with that Extra ID is received, it will be created as "In process" instead.'), __('If there are any "In process" events with a specific Extra ID and a New event with that Extra ID is received, it will be created as "In process" instead. The new events also inherit Event Custom ID'),
true true
); );

View File

@ -13130,7 +13130,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
if ($other['data'][18] != '') { if ($other['data'][18] != '') {
$values['id_extra'] = $other['data'][18]; $values['id_extra'] = $other['data'][18];
$sql_validation = 'SELECT id_evento,estado,ack_utimestamp,id_usuario $sql_validation = 'SELECT id_evento,estado,ack_utimestamp,id_usuario,event_custom_id
FROM tevento FROM tevento
WHERE estado IN (0,2) AND id_extra ="'.$other['data'][18].'";'; WHERE estado IN (0,2) AND id_extra ="'.$other['data'][18].'";';
@ -13145,6 +13145,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$values['status'] = 2; $values['status'] = 2;
$ack_utimestamp = $val['ack_utimestamp']; $ack_utimestamp = $val['ack_utimestamp'];
$values['id_usuario'] = $val['id_usuario']; $values['id_usuario'] = $val['id_usuario'];
$values['event_custom_id'] = $val['event_custom_id'];
} }
api_set_validate_event_by_id($val['id_evento']); api_set_validate_event_by_id($val['id_evento']);
@ -13175,7 +13176,8 @@ function api_set_create_event($id, $trash1, $other, $returnType)
$custom_data, $custom_data,
$values['server_id'], $values['server_id'],
$values['id_extra'], $values['id_extra'],
$ack_utimestamp $ack_utimestamp,
$values['event_custom_id'] ?? null
); );
if ($other['data'][12] != '') { if ($other['data'][12] != '') {

View File

@ -2339,7 +2339,8 @@ function events_create_event(
$custom_data='', $custom_data='',
$server_id=0, $server_id=0,
$id_extra='', $id_extra='',
$ack_utimestamp=0 $ack_utimestamp=0,
$event_custom_id=null
) { ) {
if ($source === false) { if ($source === false) {
$source = get_product_name(); $source = get_product_name();
@ -2371,6 +2372,7 @@ function events_create_event(
'custom_data' => $custom_data, 'custom_data' => $custom_data,
'data' => '', 'data' => '',
'module_status' => 0, 'module_status' => 0,
'event_custom_id' => $event_custom_id,
]; ];
return (int) db_process_sql_insert('tevento', $values); return (int) db_process_sql_insert('tevento', $values);

View File

@ -4160,6 +4160,7 @@ sub pandora_event {
my $utimestamp = time (); my $utimestamp = time ();
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp)); my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime ($utimestamp));
my $event_custom_id = undef;
$id_agentmodule = 0 unless defined ($id_agentmodule); $id_agentmodule = 0 unless defined ($id_agentmodule);
# Validate events with the same event id # Validate events with the same event id
@ -4177,6 +4178,7 @@ sub pandora_event {
logger($pa_config, "Keeping In process status from last event with extended id '$id_extra'.", 10); logger($pa_config, "Keeping In process status from last event with extended id '$id_extra'.", 10);
$ack_utimestamp = get_db_value ($dbh, 'SELECT ack_utimestamp FROM tevento WHERE id_extra=? AND estado=2', $id_extra); $ack_utimestamp = get_db_value ($dbh, 'SELECT ack_utimestamp FROM tevento WHERE id_extra=? AND estado=2', $id_extra);
$event_status = 2; $event_status = 2;
$event_custom_id = get_db_value ($dbh, 'SELECT event_custom_id FROM tevento WHERE id_extra=? AND estado=2', $id_extra);
} }
} }
@ -4188,8 +4190,8 @@ sub pandora_event {
# Create the event # Create the event
logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10); logger($pa_config, "Generating event '$evento' for agent ID $id_agente module ID $id_agentmodule.", 10);
$event_id = db_insert ($dbh, 'id_evento','INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status) $event_id = db_insert ($dbh, 'id_evento','INSERT INTO tevento (id_agente, id_grupo, evento, timestamp, estado, utimestamp, event_type, id_agentmodule, id_alert_am, criticity, tags, source, id_extra, id_usuario, critical_instructions, warning_instructions, unknown_instructions, ack_utimestamp, custom_data, data, module_status, event_custom_id)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, safe_input($module_data), $module_status); VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', $id_agente, $id_grupo, safe_input ($evento), $timestamp, $event_status, $utimestamp, $event_type, $id_agentmodule, $id_alert_am, $severity, $module_tags, $source, $id_extra, $user_name, $critical_instructions, $warning_instructions, $unknown_instructions, $ack_utimestamp, $custom_data, safe_input($module_data), $module_status, $event_custom_id);
if(defined($event_id) && $comment ne '') { if(defined($event_id) && $comment ne '') {
my $comment_id = db_insert ($dbh, 'id','INSERT INTO tevent_comment (id_event, utimestamp, comment, id_user, action) my $comment_id = db_insert ($dbh, 'id','INSERT INTO tevent_comment (id_event, utimestamp, comment, id_user, action)