From 58f5f4e9f1cf955acf51b718c27f3d23034d9563 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Thu, 23 Jun 2022 12:47:49 +0200 Subject: [PATCH] refactor events meta pandora_enterprise#9086 --- pandora_console/extras/mr/55.sql | 8 +++ .../pandoradb_migrate_6.0_to_759.mysql.sql | 3 +- pandora_console/include/functions_api.php | 17 ------- pandora_console/include/functions_config.php | 50 ------------------- pandora_console/include/functions_events.php | 2 +- .../help/en/help_events_replication.php | 18 ------- .../help/es/help_events_replication.php | 22 -------- .../help/ja/help_events_replication.php | 21 -------- .../operation/agentes/stat_win.php | 13 ----- pandora_console/operation/events/events.php | 46 ----------------- pandora_console/pandoradb.sql | 1 - 11 files changed, 10 insertions(+), 191 deletions(-) delete mode 100644 pandora_console/include/help/en/help_events_replication.php delete mode 100644 pandora_console/include/help/es/help_events_replication.php delete mode 100644 pandora_console/include/help/ja/help_events_replication.php diff --git a/pandora_console/extras/mr/55.sql b/pandora_console/extras/mr/55.sql index e8815a524f..85c6997149 100644 --- a/pandora_console/extras/mr/55.sql +++ b/pandora_console/extras/mr/55.sql @@ -43,6 +43,14 @@ ALTER TABLE `tdashboard` MODIFY `name` TEXT NOT NULL DEFAULT ''; ALTER TABLE `tagente` ADD COLUMN `satellite_server` INT NOT NULL default 0; ALTER TABLE `tmetaconsole_agent` ADD COLUMN `satellite_server` INT NOT NULL default 0; + +ALTER TABLE `tmetaconsole_setup` DROP COLUMN `last_event_replication`; +DELETE FROM `tconfig` WHERE `token` LIKE 'event_replication'; +DELETE FROM `tconfig` WHERE `token` LIKE 'replication_interval'; +DELETE FROM `tconfig` WHERE `token` LIKE 'replication_limit'; +DELETE FROM `tconfig` WHERE `token` LIKE 'replication_mode'; +DELETE FROM `tconfig` WHERE `token` LIKE 'show_events_in_local'; + SET @st_oum763 = (SELECT IF( (SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'tautoconfig' AND table_schema = DATABASE() AND column_name = 'disabled') > 0, "SELECT 1", diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_759.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_759.mysql.sql index ca68a5472a..995f1b0409 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_759.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_759.mysql.sql @@ -412,8 +412,7 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_setup` ( `auth_token` text default '', `id_group` int(10) unsigned NOT NULL default 0, `api_password` text NOT NULL, - `disabled` tinyint(1) unsigned NOT NULL default '0', - `last_event_replication` bigint(20) default '0' + `disabled` tinyint(1) unsigned NOT NULL default '0' ) ENGINE=InnoDB COMMENT = 'Table to store metaconsole sources' DEFAULT CHARSET=utf8; diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index ab9e68f99a..c5de8c5b78 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -388,23 +388,6 @@ function api_get_test_agent_cache() } -// Returs the string OK if a connection to the event replication DB can be established. -function api_get_test_event_replication_db() -{ - if (defined('METACONSOLE')) { - return; - } - - $status = enterprise_hook('events_test_replication_db', []); - if ($status === ENTERPRISE_NOT_HOOK) { - echo 'ERR'; - return; - } - - echo $status; -} - - // -------------------------DEFINED OPERATIONS FUNCTIONS----------------- diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 05584d6ca6..be7c6aa4bd 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -409,32 +409,6 @@ function config_update_config() $error_update[] = __('Size of collection'); } - if (config_update_value('event_replication', (int) get_parameter('event_replication'), true) === false) { - $error_update[] = __('Events replication'); - } - - if ((int) get_parameter('event_replication') === 1) { - if (config_update_value('replication_interval', (int) get_parameter('replication_interval'), true) === false) { - $error_update[] = __('Replication interval'); - } - - if (config_update_value('replication_limit', (int) get_parameter('replication_limit'), true) === false) { - $error_update[] = __('Replication limit'); - } - - if (config_update_value('replication_mode', (string) get_parameter('replication_mode'), true) === false) { - $error_update[] = __('Replication mode'); - } - - if (config_update_value('show_events_in_local', (string) get_parameter('show_events_in_local'), true) === false) { - $error_update[] = __('Show events list in local console (read only)'); - } - } - - if (config_update_value('replication_dbengine', (string) get_parameter('replication_dbengine'), true) === false) { - $error_update[] = __('Replication DB engine'); - } - if (config_update_value('replication_dbhost', (string) get_parameter('replication_dbhost'), true) === false) { $error_update[] = __('Replication DB host'); } @@ -2135,22 +2109,6 @@ function config_process_config() config_update_value('policy_add_max_agents', 200); } - if (!isset($config['event_replication'])) { - config_update_value('event_replication', 0); - } - - if (!isset($config['replication_interval'])) { - config_update_value('replication_interval', 10); - } - - if (!isset($config['replication_limit'])) { - config_update_value('replication_limit', 50); - } - - if (!isset($config['replication_dbengine'])) { - config_update_value('replication_dbengine', 'mysql'); - } - if (!isset($config['replication_dbhost'])) { config_update_value('replication_dbhost', ''); } @@ -2171,18 +2129,10 @@ function config_process_config() config_update_value('replication_dbport', ''); } - if (!isset($config['replication_mode'])) { - config_update_value('replication_mode', 'only_validated'); - } - if (!isset($config['metaconsole_agent_cache'])) { config_update_value('metaconsole_agent_cache', 0); } - if (!isset($config['show_events_in_local'])) { - config_update_value('show_events_in_local', 0); - } - if (!isset($config['log_collector'])) { config_update_value('log_collector', 0); } diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 2f09b2ee66..0d38b0cae4 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -4841,7 +4841,7 @@ function events_page_comments($event, $ajax=false, $groupedComments=[]) 'EW', (isset($event['clean_tags']) === true) ? $event['clean_tags'] : [], [] - ))) && $config['show_events_in_local'] == false || $config['event_replication'] == false + ))) ) { $event['evento'] = io_safe_output($event['evento']); $comments_form = '
'; diff --git a/pandora_console/include/help/en/help_events_replication.php b/pandora_console/include/help/en/help_events_replication.php deleted file mode 100644 index 51e2ad24b0..0000000000 --- a/pandora_console/include/help/en/help_events_replication.php +++ /dev/null @@ -1,18 +0,0 @@ - - -

If the event replication is activated, all the events will be copied to the remote metaconsole's database. -

-It is necessary to configure the credentials of the metaconsole's database, the replication mode (all events or only validated events) and the replication interval, specified in seconds. -

-NOTES: -

-The event viewer will be disabled if this option is enabled. -

-To apply the changes made on the event replication setup, it is necessary to restart the server. -

-The token "event_replication" must be set to 1 in the server's configuration file. -

diff --git a/pandora_console/include/help/es/help_events_replication.php b/pandora_console/include/help/es/help_events_replication.php deleted file mode 100644 index 3c5ec4e2cc..0000000000 --- a/pandora_console/include/help/es/help_events_replication.php +++ /dev/null @@ -1,22 +0,0 @@ - - -

Cuando la replicación de eventos está activada, los eventos recibidos se copiarán a la base de datos remota de una metaconsola. -

-Es necesario configurar las credenciales de la base de datos de la metaconsola, así como el modo de replicación (todos los eventos o solo los validados) y el intervalo de replicación en segundos. -

-NOTAS: -

-El visor de eventos se deshabilita cuando se activa esta opción. -

-Para que los cambios en la configuración de replicación de eventos se hagan efectivos será necesario reiniciar el servidor. -

-El fichero de configuración del servidor deberá tener el token: - -event_replication 1 - -

- diff --git a/pandora_console/include/help/ja/help_events_replication.php b/pandora_console/include/help/ja/help_events_replication.php deleted file mode 100644 index 6298a4a8d8..0000000000 --- a/pandora_console/include/help/ja/help_events_replication.php +++ /dev/null @@ -1,21 +0,0 @@ - - -

イベントの複製が有効の場合、受け取ったイベントは、メタコンソールのリモートデータベースにコピーされます。 -

-メタコンソールのデータベースへのアクセス権、複製モード(全イベントまたは承諾済のみ)、複製間隔(秒)を設定する必要があります。 -

-注意: -

-このオプションが有効の場合は、イベントビューワは無効になります。 -

-イベントの複製の設定変更を反映させるには、サーバを再起動する必要があります。 -

-サーバの設定ファイルに、次の設定を行う必要があります。 - -event_replication 1 - -

diff --git a/pandora_console/operation/agentes/stat_win.php b/pandora_console/operation/agentes/stat_win.php index 710d8e6df6..72c5c55c7a 100644 --- a/pandora_console/operation/agentes/stat_win.php +++ b/pandora_console/operation/agentes/stat_win.php @@ -277,13 +277,6 @@ ui_print_message_dialog( $table->data[0][2] = __('Show events'); $disabled = false; - if (isset($config['event_replication']) === true) { - if ($config['event_replication'] - && !$config['show_events_in_local'] - ) { - $disabled = true; - } - } $table->data[0][3] = html_print_checkbox_switch( 'draw_events', @@ -292,12 +285,6 @@ ui_print_message_dialog( true, $disabled ); - if ($disabled) { - $table->data[1] .= ui_print_help_tip( - __("'Show events' is disabled because this %s node is set to event replication.", get_product_name()), - true - ); - } $table->data[1][0] = __('Begin date'); $table->data[1][1] = html_print_input_text( diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 5be4945a6a..caecc587dd 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -69,16 +69,7 @@ if ($event_a === false $access = ($event_a === true) ? 'ER' : (($event_w === true) ? 'EW' : (($event_m === true) ? 'EM' : 'ER')); - $readonly = false; -if (is_metaconsole() === false - && isset($config['event_replication']) === true - && (int) $config['event_replication'] === 1 - && (int) $config['show_events_in_local'] === 1 -) { - $readonly = true; -} - // Load specific stylesheet. ui_require_css_file('events'); ui_require_css_file('tables'); @@ -1529,31 +1520,6 @@ html_print_div( ] ); -// Controls. -if (is_metaconsole() !== true) { - if (isset($config['event_replication']) === true - && $config['event_replication'] == 1 - ) { - if ($config['show_events_in_local'] == 0) { - db_pandora_audit( - AUDIT_LOG_ACL_VIOLATION, - 'Trying to access event viewer. View disabled due event replication.' - ); - ui_print_info_message( - [ - 'message' => __( - 'Event viewer is disabled due event replication. For more information, please contact with the administrator' - ), - 'no_close' => true, - ] - ); - return; - } else { - $readonly = true; - } - } -} - if (enterprise_hook( 'enterprise_acl', [ @@ -2317,18 +2283,6 @@ if (is_user_admin($config['id_user'])) { ); } - -if ($config['event_replication'] != 1) { - if ($event_w && !$readonly) { - $array_events_actions['in_progress_selected'] = __('In progress selected'); - $array_events_actions['validate_selected'] = __('Validate selected'); - } - - if ($event_m == 1 && !$readonly) { - $array_events_actions['delete_selected'] = __('Delete selected'); - } -} - foreach ($event_responses as $val) { $array_events_actions[$val['id']] = $val['name']; } diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 6d87bb7b5a..7a5f0288e2 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -2766,7 +2766,6 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_setup` ( `api_password` TEXT, `disabled` TINYINT UNSIGNED NOT NULL DEFAULT 0, `unified` TINYINT UNSIGNED NOT NULL DEFAULT 0, - `last_event_replication` BIGINT DEFAULT 0, `server_uid` TEXT , PRIMARY KEY (`id`) ) ENGINE=InnoDB