diff --git a/pandora_console/godmode/setup/performance.php b/pandora_console/godmode/setup/performance.php index 03a3c15f99..b8d211c4ca 100644 --- a/pandora_console/godmode/setup/performance.php +++ b/pandora_console/godmode/setup/performance.php @@ -151,6 +151,9 @@ if ($update_config == 1 && $config['history_db_enabled'] == 1) { } } +$total_agents = db_get_value('count(*)', 'tagente'); +$disable_agentaccess = ($total_agents >= 200 && $config['agentaccess'] == 0) ? true : false; + $table_status = new StdClass(); $table_status->width = '100%'; $table_status->class = 'databox filters'; @@ -590,7 +593,7 @@ $table_other->data[$i++][1] = html_print_input_text( ); $table_other->data[$i][0] = __('Use agent access graph'); -$table_other->data[$i++][1] = html_print_checkbox_switch('agentaccess', 1, $config['agentaccess'], true); +$table_other->data[$i++][1] = html_print_checkbox_switch('agentaccess', 1, $config['agentaccess'], true, $disable_agentaccess); $table_other->data[$i][0] = __('Max. recommended number of files in attachment directory'); $table_other->data[$i++][1] = html_print_input_text( diff --git a/pandora_console/include/class/ConsoleSupervisor.php b/pandora_console/include/class/ConsoleSupervisor.php index bfa8e2fd68..837be70906 100644 --- a/pandora_console/include/class/ConsoleSupervisor.php +++ b/pandora_console/include/class/ConsoleSupervisor.php @@ -258,14 +258,21 @@ class ConsoleSupervisor $this->checkSyncQueueStatus(); } - /* - * Checkc agent missing libraries. - * NOTIF.AGENT.LIBRARY - */ + /* + * Check number of agents is equals and more than 200. + * NOTIF.ACCESSSTASTICS.PERFORMANCE + */ + + $this->checkAccessStatisticsPerformance(); + + /* + * Checkc agent missing libraries. + * NOTIF.AGENT.LIBRARY + */ + if ((bool) enterprise_installed() === true) { $this->checkLibaryError(); } - } @@ -527,13 +534,22 @@ class ConsoleSupervisor $this->checkSyncQueueStatus(); } + /* + * Check number of agents is equals and more than 200. + * NOTIF.ACCESSSTASTICS.PERFORMANCE + */ + + $this->checkAccessStatisticsPerformance(); + /* * Checkc agent missing libraries. * NOTIF.AGENT.LIBRARY */ + if ((bool) enterprise_installed() === true) { $this->checkLibaryError(); } + } @@ -548,6 +564,34 @@ class ConsoleSupervisor } + /** + * Check number of agents and disable agentaccess token if number + * is equals and more than 200. + * + * @return void + */ + public function checkAccessStatisticsPerformance() + { + $total_agents = db_get_value('count(*)', 'tagente'); + + if ($total_agents >= 200) { + db_process_sql_update('tconfig', ['value' => 0], ['token' => 'agentaccess']); + $this->notify( + [ + 'type' => 'NOTIF.ACCESSSTASTICS.PERFORMANCE', + 'title' => __('Access statistics performance'), + 'message' => __( + 'Usage of agent access statistics IS NOT RECOMMENDED on systems with more than 200 agents due performance penalty' + ), + 'url' => '__url__/index.php?sec=general&sec2=godmode/setup/setup§ion=perf', + ] + ); + } else { + $this->cleanNotifications('NOTIF.ACCESSSTASTICS.PERFORMANCE'); + } + } + + /** * Update targets for given notification using object targets. * diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 705d67ab3b..8ed023ddde 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -159,6 +159,7 @@ function notifications_get_subtypes(?string $source=null) 'NOTIF.SERVER.STATUS', 'NOTIF.SERVER.QUEUE', 'NOTIF.SERVER.MASTER', + 'NOTIF.ACCESSSTASTICS.PERFORMANCE', ], ];