Merge branch 'ent-10259-control-de-configuracion-en-tagent_acess' into 'develop'

Ent 10259 control de configuracion en tagent acess

See merge request artica/pandorafms!5504
This commit is contained in:
Matias Didier 2023-02-27 08:45:00 +00:00
commit 1d30123d53
3 changed files with 54 additions and 6 deletions

View File

@ -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(

View File

@ -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&section=perf',
]
);
} else {
$this->cleanNotifications('NOTIF.ACCESSSTASTICS.PERFORMANCE');
}
}
/**
* Update targets for given notification using object targets.
*

View File

@ -159,6 +159,7 @@ function notifications_get_subtypes(?string $source=null)
'NOTIF.SERVER.STATUS',
'NOTIF.SERVER.QUEUE',
'NOTIF.SERVER.MASTER',
'NOTIF.ACCESSSTASTICS.PERFORMANCE',
],
];