From d0667d7012c6e19bdcf33832870c3f96a3f56b2c Mon Sep 17 00:00:00 2001 From: slerena Date: Wed, 24 Jun 2009 16:53:17 +0000 Subject: [PATCH] 2009-06-23 Sancho Lerena * lib/pandoraFMS/DataServer.pm, Config.pm: Fixes bug #2811605. This add a new config token to define max files queued to avoid problems reading incoming dir with huge number of files. * lib/PandoraFMS/Core.pm: Adds new feature to have optional agent access graph & data. Included to improve the performance in huge systems git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1766 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 9 +++++++++ pandora_server/conf/pandora_server.conf | 5 +++++ pandora_server/lib/PandoraFMS/Config.pm | 6 ++++++ pandora_server/lib/PandoraFMS/Core.pm | 3 +++ pandora_server/lib/PandoraFMS/DataServer.pm | 7 ++++++- 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 03ce1de0df..7d46d19734 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,12 @@ +2009-06-23 Sancho Lerena + + * lib/pandoraFMS/DataServer.pm, Config.pm: Fixes bug #2811605. This + add a new config token to define max files queued to avoid problems + reading incoming dir with huge number of files. + + * lib/PandoraFMS/Core.pm: Adds new feature to have optional agent + access graph & data. Included to improve the performance in huge systems + 2009-06-24 Ramon Novoa * lib/PandoraFMS/Core.pm: Small fixes to compound alert and event diff --git a/pandora_server/conf/pandora_server.conf b/pandora_server/conf/pandora_server.conf index 66c8c37167..71f7350276 100755 --- a/pandora_server/conf/pandora_server.conf +++ b/pandora_server/conf/pandora_server.conf @@ -207,4 +207,9 @@ max_log_size 65536 # mcast_change_port 11111 # mcast_change_group 224.1.1.1 +# max_queue_files (250 by default) +# When server have more than max_queue_files in incoming directory, skips the read +# the directory to avoid filesystem overhead. + +max_queue_files 250 diff --git a/pandora_server/lib/PandoraFMS/Config.pm b/pandora_server/lib/PandoraFMS/Config.pm index 7391ac1887..11e9e611f2 100644 --- a/pandora_server/lib/PandoraFMS/Config.pm +++ b/pandora_server/lib/PandoraFMS/Config.pm @@ -185,6 +185,8 @@ sub pandora_load_config { $pa_config->{"export_threads"} = 1; # 3.0 $pa_config->{"web_threads"} = 1; # 3.0 + $pa_config->{"max_queue_files"} = 250; + # Internal MTA for alerts, each server need its own config. $pa_config->{"mta_address"} = '127.0.0.1'; # Introduced on 2.0 $pa_config->{"mta_port"} = '25'; # Introduced on 2.0 @@ -467,6 +469,10 @@ sub pandora_load_config { elsif ($parametro =~ m/^export_threads\s([0-9]*)/i) { $pa_config->{'export_threads'}= clean_blank($1); } + elsif ($parametro =~ m/^max_queue_files\s([0-9]*)/i) { + $pa_config->{'max_queue_files'}= clean_blank($1); + } + } # end of loop for parameter # diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 24584ed6fc..70c444911f 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -475,6 +475,9 @@ sub pandora_access_update ($$$) { return if ($agent_id < 0); + if ($pa_config->{"agentaccess"} == 0){ + return; + } db_insert ($dbh, "INSERT INTO tagent_access (`id_agent`, `utimestamp`) VALUES (?, ?)", $agent_id, time ()); } diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 554db14047..7c6e0f9aad 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -81,7 +81,11 @@ sub data_producer ($) { opendir (DIR, $pa_config->{'incomingdir'}) || die "[FATAL] Cannot open Incoming data directory at " . $pa_config->{'incomingdir'} . ": $!"; + my $queue_count = 0; while (defined (my $file_name = readdir(DIR))) { + if ($queue_count > $pa_config->{"max_queue_files"}) { + last; + } # For backward compatibility if ($file_name =~ /^.*\.checksum$/) { @@ -89,9 +93,10 @@ sub data_producer ($) { next; } - # Data files have the extension .data + # Data files must have the extension .data next if ($file_name !~ /^.*\.data$/); + $queue_count++; push (@tasks, $file_name); }