From d85a488cb077bdae561cfe746f51cd2c5e6b6e06 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 22 Jan 2024 10:37:03 +0100 Subject: [PATCH] #12538 new notifications in console supervisor --- .../include/class/ConsoleSupervisor.php | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index 1b1d06d8b9..668ace85c5 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -301,6 +301,18 @@ class ConsoleSupervisor */ $this->checkLogAlerts(); + + /* + * Check total modules in system + */ + + $this->checkTotalModules(); + + /* + * Check total modules by agent + */ + + $this->checkTotalModulesByAgent(); } @@ -591,8 +603,21 @@ class ConsoleSupervisor * Check MYSQL Support Version * */ + $this->checkMYSQLSettings(); + /* + * Check total modules in system + */ + + $this->checkTotalModules(); + + /* + * Check total modules by agent + */ + + $this->checkTotalModulesByAgent(); + } @@ -3199,4 +3224,63 @@ class ConsoleSupervisor } + /** + * Check if the total number of modules in Pandora is greater than 80000. + * + * @return void + */ + public function checkTotalModules() + { + $total_modules = db_get_num_rows('select * from tagente_modulo'); + if ($total_modules > 80000) { + $this->notify( + [ + 'type' => 'NOTIF.MODULES.ALERT', + 'title' => __('Your system has a total of %s modules', $total_modules), + 'message' => __('This is higher than the recommended maximum 80,000 modules per node. This may result in poor performance of your system.'), + 'icon_notification' => self::ICON_HEADSUP, + ] + ); + } else { + $this->cleanNotifications('NOTIF.MODULES.ALERT'); + } + } + + + /** + * Check if the total number of modules by agent is greater than 200 + * + * @return void + */ + public function checkTotalModulesByAgent() + { + $modules_by_agent = db_process_sql( + 'SELECT count(*) AS modules_by_agent + FROM tagente a + LEFT JOIN tagente_modulo m ON a.id_agente = m.id_agente + GROUP BY m.id_agente' + ); + + $show_warning = false; + foreach ($modules_by_agent as $key => $total_modules) { + if ($total_modules['modules_by_agent'] > 200) { + $this->notify( + [ + 'type' => 'NOTIF.MODULES_AGENT.ALERT', + 'title' => __('Your system has an average of %s modules per agent', $total_modules['modules_by_agent']), + 'message' => __('This is higher than the recommended maximum (200). This may result in poor performance of your system.'), + 'icon_notification' => self::ICON_HEADSUP, + ] + ); + $show_warning = true; + break; + } + } + + if ($show_warning === false) { + $this->cleanNotifications('NOTIF.MODULES_AGENT.ALERT'); + } + } + + }