diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index ad7a40aa8b..de7e811c41 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -704,7 +704,7 @@ $table->data[$i][] = html_print_label_input_block( ) ); -$table->data[$i][] = html_print_label_input_block( +$table->data[$i++][] = html_print_label_input_block( __('Check conexion interval'), html_print_input_number( [ @@ -715,6 +715,16 @@ $table->data[$i][] = html_print_label_input_block( ) ); +$table->data[$i][] = html_print_label_input_block( + __('Keep In process status for new events with extra ID'), + html_print_checkbox_switch( + 'keep_in_process_status_extra_id', + 1, + $config['keep_in_process_status_extra_id'], + true + ) +); + echo '
'; echo '
'; diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index bd1577116c..a64b5ae751 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -13090,10 +13090,17 @@ function api_set_create_event($id, $trash1, $other, $returnType) if ($other['data'][18] != '') { $values['id_extra'] = $other['data'][18]; - $sql_validation = 'SELECT id_evento FROM tevento where estado IN (0,2) and id_extra ="'.$other['data'][18].'";'; + $sql_validation = 'SELECT id_evento,estado FROM tevento where estado IN (0,2) and id_extra ="'.$other['data'][18].'";'; $validation = db_get_all_rows_sql($sql_validation); + if ($validation) { foreach ($validation as $val) { + if ((int) $val['estado'] === EVENT_STATUS_INPROCESS + && (int) $values['status'] === 0 + ) { + $values['status'] = 2; + } + api_set_validate_event_by_id($val['id_evento']); } } diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index b94892e7c1..4c682c6f82 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -370,6 +370,10 @@ function config_update_config() $error_update[] = __('alias_as_name'); } + if (config_update_value('keep_in_process_status_extra_id', get_parameter('keep_in_process_status_extra_id'), true) === false) { + $error_update[] = __('keep_in_process_status_extra_id'); + } + if (config_update_value('console_log_enabled', get_parameter('console_log_enabled'), true) === false) { $error_update[] = __('Console log enabled'); } @@ -2343,6 +2347,10 @@ function config_process_config() config_update_value('alias_as_name', 0); } + if (!isset($config['keep_in_process_status_extra_id'])) { + config_update_value('keep_in_process_status_extra_id', 0); + } + if (!isset($config['console_log_enabled'])) { config_update_value('console_log_enabled', 0); } diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index ca6b4991a9..7d9cf4a8fb 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -4070,6 +4070,20 @@ sub pandora_event { # Validate events with the same event id if (defined ($id_extra) && $id_extra ne '') { + my $keep_in_process_status_extra_id = pandora_get_tconfig_token ($dbh, 'keep_in_process_status_extra_id', 0); + + if ($keep_in_process_status_extra_id == 1) { + # Keep status if the latest event was In process + logger($pa_config, "Checking status of latest event with extended id '$id_extra'.", 10); + my $id_extra_last_status = get_db_value_limit ($dbh, 'SELECT estado FROM tevento WHERE id_extra=? ORDER BY timestamp DESC', 1, $id_extra); + + # Only when the event comes as New. Validated events are excluded + if (defined ($id_extra_last_status) && $id_extra_last_status == 2 && $event_status == 0) { + logger($pa_config, "Keeping In process status from last event with extended id '$id_extra'.", 10); + $event_status = 2; + } + } + logger($pa_config, "Updating events with extended id '$id_extra'.", 10); db_do ($dbh, 'UPDATE tevento SET estado = 1, ack_utimestamp = ? WHERE estado IN (0,2) AND id_extra=?', $utimestamp, $id_extra); }