From 43f006038ec986157f0504eae0116914c289573d Mon Sep 17 00:00:00 2001 From: Jonathan Date: Wed, 3 Apr 2024 12:14:18 +0200 Subject: [PATCH] #13171 log collector move and notification --- pandora_console/godmode/setup/setup.php | 17 +++++---- .../include/class/ConsoleSupervisor.php | 35 +++++++++++++++++++ pandora_console/include/functions.php | 7 ++++ .../include/functions_notifications.php | 1 + 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/pandora_console/godmode/setup/setup.php b/pandora_console/godmode/setup/setup.php index 6518470811..8624146692 100644 --- a/pandora_console/godmode/setup/setup.php +++ b/pandora_console/godmode/setup/setup.php @@ -111,11 +111,8 @@ if (enterprise_installed()) { array_push($menu_tabs, $menu_tab_url); $menu_tab_url = ''.__('History database').''; array_push($menu_tabs, $menu_tab_url); - - if ($config['log_collector']) { - $menu_tab_url = ''.__('Log collector').''; - array_push($menu_tabs, $menu_tab_url); - } + $menu_tab_url = ''.__('Log collector').''; + array_push($menu_tabs, $menu_tab_url); } $buttons['auth'] = [ @@ -422,8 +419,14 @@ switch ($section) { $help_header = ''; break; + case 'log': + $buttons['log']['active'] = true; + $subpage = __('Log Collector'); + $help_header = 'opensearch_installation'; + break; + default: - $subpage = 'seccion: '; + $subpage = ''; // Default. break; } @@ -432,7 +435,7 @@ $dots = dot_tab($menu_tabs); // Header. ui_print_standard_header( - __('Setup').' » '.$subpage, + $subpage, '', false, $help_header, diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 24af0a860c..a18781e9a2 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -540,6 +540,12 @@ class ConsoleSupervisor $this->checkUpdateManagerRegistration(); + /* + * Check if OpenSearch is configured and log collector enabled + * NOTIF.OPENSEARCH.CONSOLELOG + */ + $this->checkOpenSearchLogCollector(); + /* * Check if has API access. * NOTIF.API.ACCESS @@ -2540,6 +2546,35 @@ class ConsoleSupervisor } + /** + * Check if OpenSearch is configured and log collector enabled. + * + * @return void + */ + public function checkOpenSearchLogCollector() + { + global $config; + include_once $config['homedir'].'/include/functions_update_manager.php'; + $login = get_parameter('login', false); + + if ($config['log_collector'] !== '1' && empty($config['elasticsearch_ip']) === false && empty($config['elasticsearch_port']) === false) { + if (update_manager_verify_registration() === false) { + $this->notify( + [ + 'type' => 'NOTIF.OPENSEARCH.CONSOLELOG', + 'title' => __('The Log collector is not enabled'), + 'message' => __('The OpenSearch is defined but the log collector is not enabled.'), + 'url' => '__url__/index.php?sec=gsetup&sec2=godmode/setup/setup§ion=log', + 'icon_notification' => self::ICON_QUESTION, + ] + ); + } else { + $this->cleanNotifications('NOTIF.OPENSEARCH.CONSOLELOG'); + } + } + } + + /** * Check if has access to the API * diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 60d22cee1e..a81c84f9c0 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -5617,6 +5617,13 @@ function get_help_info($section_name) } break; + case 'opensearch_installation': + if ($es) { + $result .= 'pandorafms/technical_annexes/38_opensearch_installation#instalacion'; + } else { + $result .= 'pandorafms/technical_annexes/38_opensearch_installation#installation'; + } + case 'servers_ha_clusters_tab': if ($es) { $result .= 'pandorafms/complex_environments_and_optimization/06_ha#alta_disponibilidad_del_servidor_de_datos'; diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 30b30539d5..947b2d8657 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -147,6 +147,7 @@ function notifications_get_subtypes(?string $source=null) 'NOTIF.METACONSOLE.DB_CONNECTION', 'NOTIF.DOWNTIME', 'NOTIF.UPDATEMANAGER.REGISTRATION', + 'NOTIF.OPENSEARCH.CONSOLELOG', 'NOTIF.API.ACCESS', 'NOTIF.MISC.EVENTSTORMPROTECTION', 'NOTIF.MISC.DEVELOPBYPASS',