Merge branch 'ent-6284-10517-non-master-actualiza-agent-cache' into 'develop'

Only the master should update the agent cache.

See merge request artica/pandorafms!3437
This commit is contained in:
Daniel Rodriguez 2020-09-08 14:12:57 +02:00
commit 615bfcfb5f
1 changed files with 11 additions and 4 deletions

View File

@ -111,9 +111,6 @@ sub pandora_startup () {
# Start the event replication thread. Do not start with start_server_thread, this thread may exit on its own.
threads->create(\&pandora_process_event_replication, \%Config) if($Config{'__enterprise_enabled'} == 1 && $Config{'event_replication'} == 1);
# Update the agent cache. Do not start with start_server_thread, this thread updates the agent cache and exits.
threads->create(\&enterprise_hook, 'update_agent_cache', [\%Config])->detach() if ($Config{'node_metaconsole'} == 1);
pandora_audit (\%Config, $Config{'rb_product_name'} . ' Server Daemon starting', 'SYSTEM', 'System', $DBH);
# Load servers
@ -290,9 +287,19 @@ sub pandora_server_tasks ($) {
my $dbh = db_connect ($pa_config->{'dbengine'}, $pa_config->{'dbname'}, $pa_config->{'dbhost'}, $pa_config->{'dbport'},
$pa_config->{'dbuser'}, $pa_config->{'dbpass'});
my $counter = 0;
my $first_run = 1;
while ($THRRUN == 1) {
if (pandora_is_master($pa_config) == 1) {
# TASKS EXECUTED ONCE
# -------------------
if ($first_run == 1) {
$first_run = 0;
# Update the agent cache.
enterprise_hook('update_agent_cache', [\%Config]);
}
# TASKS EXECUTED EVERY 5 SECONDS (Low latency tasks)
# --------------------------------------------------
if (($counter % 5) == 0) {