From 81b1cebe61b32dd415cf0570aac12c3af1777e2a Mon Sep 17 00:00:00 2001
From: slerena <slerena@gmail.com>
Date: Fri, 20 Jul 2007 10:42:20 +0000
Subject: [PATCH] 2007-07-20  Sancho Lerena  <slerena@artica.es>

        * operation/servers/view_server.php: Fixed bug with Data Server lag check (#1757084)

        * operation/agents/tactical.php: Fixed the same bug above (#1757084)



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@571 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_console/ChangeLog                         | 7 ++++++-
 pandora_console/operation/agentes/tactical.php    | 6 +++++-
 pandora_console/operation/servers/view_server.php | 5 ++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index 2f0d800361..cac743160c 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -1,5 +1,10 @@
-2007-07-19  Sancho Lerena  <slerena@artica.es>
+2007-07-20  Sancho Lerena  <slerena@artica.es>
 
+	* operation/servers/view_server.php: Fixed bug with Data Server lag check
+
+	* operation/agents/tactical.php: Fixed the same bug above.
+
+2007-07-19  Sancho Lerena  <slerena@artica.es>
 
 	* godmode/agentes/agent_manager.php: Fixed problems not really
 	fixed in commit 563 (bug 1744913).
diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php
index 6b8cb69e28..f07f993f27 100644
--- a/pandora_console/operation/agentes/tactical.php
+++ b/pandora_console/operation/agentes/tactical.php
@@ -273,7 +273,11 @@
 	                        // and calculate difference in seconds
 	                        // Get total modules defined for this server
 	                        if (($network_server == 1) OR ($data_server == 1)){
-	                                $sql1 = "SELECT MIN(last_execution_try), current_interval FROM tagente_estado WHERE last_execution_try > 0 AND running_by=$id_server GROUP BY current_interval ORDER BY 1";
+					if ($network_server == 1)
+	                                        $sql1 = "SELECT MIN(last_execution_try),current_interval FROM tagente_estado WHERE last_execution_try > 0 AND running_by=$id_server GROUP BY current_interval ORDER BY 1";
+	                                if ($data_server == 1)
+	                                        $sql1 = "SELECT MAX(last_execution_try), current_interval, id_agente FROM tagente_estado WHERE last_execution_try > 0 AND running_by=$id_server GROUP BY id_agente ORDER BY 1 ASC";
+
 	                                $nowtime = time();
 	                                $maxlag=0;
 	                                if ($result1=mysql_query($sql1))
diff --git a/pandora_console/operation/servers/view_server.php b/pandora_console/operation/servers/view_server.php
index 0fd49eed25..edfd1f9a7e 100644
--- a/pandora_console/operation/servers/view_server.php
+++ b/pandora_console/operation/servers/view_server.php
@@ -158,7 +158,10 @@ if (comprueba_login() == 0) {
 			// and calculate difference in seconds 
 			// Get total modules defined for this server
 			if (($network_server == 1) OR ($data_server == 1)){
-				$sql1 = "SELECT MIN(last_execution_try),current_interval FROM tagente_estado WHERE last_execution_try > 0 AND running_by=$id_server GROUP BY current_interval ORDER BY 1";
+				if ($network_server == 1)
+					$sql1 = "SELECT MIN(last_execution_try),current_interval FROM tagente_estado WHERE last_execution_try > 0 AND running_by=$id_server GROUP BY current_interval ORDER BY 1";
+				if ($data_server == 1)
+					$sql1 = "SELECT MAX(last_execution_try), current_interval, id_agente FROM tagente_estado WHERE last_execution_try > 0 AND running_by=$id_server GROUP BY id_agente ORDER BY 1 ASC";
 				$nowtime = time();
 				$maxlag=0;
 				if ($result1=mysql_query($sql1))