From 3f51f901b0882c1e50434f005e23aa021caa23aa Mon Sep 17 00:00:00 2001
From: ramonn <noreply@pandorafms.org>
Date: Thu, 28 Feb 2013 10:30:32 +0000
Subject: [PATCH] 2013-02-28  Ramon Novoa  <rnovoa@artica.es>

	* bin/pandora_server: Undid the previous commit since forking after
	  having launched all server threads can lead to trouble.

	* lib/PandoraFMS/Core.pm: Removed some debugging code that polluted the
	  logs.

	* lib/PandoraFMS/NetworkServer.pm: Removed a DISTINCT from the query since
	  module ids are unique.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7741 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_server/ChangeLog                       | 11 +++++++++++
 pandora_server/bin/pandora_server              | 14 ++++++--------
 pandora_server/lib/PandoraFMS/Core.pm          |  3 ---
 pandora_server/lib/PandoraFMS/NetworkServer.pm |  2 +-
 4 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog
index b54b782c99..b2d02a20ab 100644
--- a/pandora_server/ChangeLog
+++ b/pandora_server/ChangeLog
@@ -1,3 +1,14 @@
+2013-02-28  Ramon Novoa  <rnovoa@artica.es>
+
+	* bin/pandora_server: Undid the previous commit since forking after
+	  having launched all server threads can lead to trouble.
+
+	* lib/PandoraFMS/Core.pm: Removed some debugging code that polluted the
+	  logs.
+	
+	* lib/PandoraFMS/NetworkServer.pm: Removed a DISTINCT from the query since
+	  module ids are unique.
+
 2013-02-27 Miguel de Dios <miguel.dedios@artica.es>
 	
 	* lib/PandoraFMS/Core.pm: erased lost develop traces.
diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server
index 9b820ef916..b367982db6 100755
--- a/pandora_server/bin/pandora_server
+++ b/pandora_server/bin/pandora_server
@@ -259,14 +259,18 @@ $SIG{'ALRM'} = 'IGNORE';
 pandora_init(\%Config, 'Pandora FMS Server');
 pandora_load_config (\%Config);
 
+# Daemonize and put in background
+if ($Config{'daemon'} == 1) {
+	print_message (\%Config, " [*] Backgrounding Pandora FMS Server process.\n", 1);
+	pandora_daemonize (\%Config);
+}
+
 # Load enterprise module
 if (enterprise_load (\%Config) == 0) {
 	print_message (\%Config, " [*] Pandora FMS Enterprise module not available.", 1);
 } else {
 	print_message (\%Config, " [*] Pandora FMS Enterprise module loaded.", 1);
-}
 
-if (enterprise_load (\%Config) != 0) {
 	if($Config{'policy_manager'} == 1) {
 		# Start thread to patrol policy queue
 		my $thr_policy_queue = threads->create('pandora_process_policy_queue', (\%Config));
@@ -286,12 +290,6 @@ foreach my $server (@Servers) {
 	$server->upEvent ();
 }
 
-# Daemonize and put in background
-if ($Config{'daemon'} == 1) {
-	print_message (\%Config, " [*] Backgrounding Pandora FMS Server process.\n", 1);
-	pandora_daemonize (\%Config);
-}
-
 # Main loop
 my $time_ref = time ();
 my $counter = 0;
diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm
index 398fae0e7f..fcad6340e9 100644
--- a/pandora_server/lib/PandoraFMS/Core.pm
+++ b/pandora_server/lib/PandoraFMS/Core.pm
@@ -1490,9 +1490,6 @@ Start the planned downtime, the montly type.
 sub pandora_planned_downtime_monthly_stop($$) {
 	my ($pa_config, $dbh) = @_;
 	
-	logger($pa_config, "[PLANNED_DOWNTIME] " .
-		"Enter pandora_planned_downtime_monthly_stop().", 10);
-	
 	#my $local_time = localtime();
 	my @var_localtime = localtime(time);
 	my $year = $var_localtime[5]  + 1900;
diff --git a/pandora_server/lib/PandoraFMS/NetworkServer.pm b/pandora_server/lib/PandoraFMS/NetworkServer.pm
index 49975d8c13..c188e07dde 100644
--- a/pandora_server/lib/PandoraFMS/NetworkServer.pm
+++ b/pandora_server/lib/PandoraFMS/NetworkServer.pm
@@ -105,7 +105,7 @@ sub data_producer ($) {
 		AND (tagente_modulo.flag = 1 OR ((tagente_estado.last_execution_try + tagente_estado.current_interval) < UNIX_TIMESTAMP())) 
 		ORDER BY tagente_modulo.flag DESC, time_left ASC, tagente_estado.last_execution_try ASC ', $pa_config->{'servername'});
     } else {
-		@rows = get_db_rows ($dbh, 'SELECT DISTINCT(tagente_modulo.id_agente_modulo), tagente_modulo.flag, tagente_estado.last_execution_try, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try
+		@rows = get_db_rows ($dbh, 'SELECT tagente_modulo.id_agente_modulo, tagente_modulo.flag, tagente_estado.last_execution_try, tagente_estado.current_interval + tagente_estado.last_execution_try AS time_left, last_execution_try
 		FROM tagente, tagente_modulo, tagente_estado
 		WHERE ((server_name = ?) OR (server_name = ANY(SELECT name FROM tserver WHERE status = 0))) 
 		AND tagente_modulo.id_agente = tagente.id_agente