diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 7e5135ef2d..371f2b0a24 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,11 @@ +2010-07-27 Ramon Novoa + + * lib/PandoraFMS/Core.pm: Make sure delete_pending is set to 0 + when selecting keepalive modules. + + * lib/PandoraFMS/DataServer.pm: Do not read more than max_queue_files + files. Suppressed some warnings. + 2010-07-27 Ramon Novoa * lib/PandoraFMS/Core.pm: Removed a misplaced parenthesis. diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 0fa6996739..190da7564e 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -999,7 +999,7 @@ sub pandora_module_keep_alive ($$$$$) { logger($pa_config, "Updating keep_alive module for agent '" . $agent_name . "'.", 10); # Update keepalive module - my $module = get_db_single_row ($dbh, 'SELECT * FROM tagente_modulo WHERE id_agente = ? AND id_tipo_modulo = 100', $id_agent); + my $module = get_db_single_row ($dbh, 'SELECT * FROM tagente_modulo WHERE id_agente = ? AND delete_pending = 0 AND id_tipo_modulo = 100', $id_agent); return unless defined ($module); my %data = ('data' => 1); diff --git a/pandora_server/lib/PandoraFMS/DataServer.pm b/pandora_server/lib/PandoraFMS/DataServer.pm index 91a3539f53..db144b9ff0 100644 --- a/pandora_server/lib/PandoraFMS/DataServer.pm +++ b/pandora_server/lib/PandoraFMS/DataServer.pm @@ -82,16 +82,30 @@ sub data_producer ($) { my $pa_config = $self->getConfig (); my @tasks; + my @files; - # Read all files in the incoming directory + # Open the incoming directory opendir (DIR, $pa_config->{'incomingdir'}) || die "[FATAL] Cannot open Incoming data directory at " . $pa_config->{'incomingdir'} . ": $!"; - my @files = readdir (DIR); + # Do not read more than max_queue_files files + my $file_count = 0; + while (my $file = readdir (DIR)) { + if ($file_count > $pa_config->{"max_queue_files"}) { + last; + } + push (@files, $file); + $file_count++; + } closedir(DIR); - @files = sort { -C $pa_config->{'incomingdir'} . "/$b" <=> -C $pa_config->{'incomingdir'} . "/$a" } (@files); + # Temporarily disable warnings (some files may have been deleted) + { + no warnings; + @files = sort { -C $pa_config->{'incomingdir'} . "/$b" <=> -C $pa_config->{'incomingdir'} . "/$a" } (@files); + } + # Queue files my $queue_count = 0; foreach my $file_name (@files) { if ($queue_count > $pa_config->{"max_queue_files"}) {