diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index 43feec628a..77d4eaf32e 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -1,3 +1,11 @@
+2009-11-30  Miguel de Dios  <miguel.dedios@artica.es>
+
+	* include/functions_agents.php: added new parameter for order the result of
+	query, $orderby.
+	* operation/agentes/alerts_status.php, godmode/alerts/alert_list.php: use
+	new parameter to order by module name.
+	Fixes: 2902603
+
 2009-11-30  Miguel de Dios  <miguel.dedios@artica.es>
 
 	* include/functions_ui.php: show the deault action with other style.
diff --git a/pandora_console/godmode/alerts/alert_list.php b/pandora_console/godmode/alerts/alert_list.php
index 4326858881..0ccc6d6854 100644
--- a/pandora_console/godmode/alerts/alert_list.php
+++ b/pandora_console/godmode/alerts/alert_list.php
@@ -288,7 +288,7 @@ echo "</div>\n";
 $simple_alerts = array();
 
 if ($id_agente) {
-	$simple_alerts = get_agent_alerts_simple (array_keys ($agents));
+	$simple_alerts = get_agent_alerts_simple (array_keys ($agents), '', false, '', false, 'agent_module_name');
 } else {
 	$total = 0;
 	$where = '';
diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php
index da3bf0eeaa..9714af16df 100644
--- a/pandora_console/include/functions_agents.php
+++ b/pandora_console/include/functions_agents.php
@@ -110,7 +110,8 @@ function create_agent ($name, $id_group, $interval, $ip_address, $values = false
  * @return array All simple alerts defined for an agent. Empty array if no
  * alerts found.
  */
-function get_agent_alerts_simple ($id_agent = false, $filter = '', $options = false, $where = '', $allModules = false) {
+function get_agent_alerts_simple ($id_agent = false, $filter = '', $options = false, $where = '', $allModules = false, $orderby = false) {
+	
 	switch ($filter) {
 		case "notfired":
 			$filter = ' AND times_fired = 0 AND disabled = 0';
@@ -147,10 +148,15 @@ function get_agent_alerts_simple ($id_agent = false, $filter = '', $options = fa
 		$subQuery = implode (",", $id_modules);
 	}
 	
-	$sql = sprintf ("SELECT talert_template_modules.*
+	if ($orderby !== false)
+		$orderbyText = sprintf("ORDER BY %s", $orderby);
+		
+	$sql = sprintf ("SELECT talert_template_modules.*, t2.nombre AS agent_module_name
 	FROM talert_template_modules
-	WHERE id_agent_module in (%s) %s %s",
-	$subQuery, $where, $filter);
+		INNER JOIN tagente_modulo AS t2
+			ON talert_template_modules.id_agent_module = t2.id_agente_modulo
+	WHERE id_agent_module in (%s) %s %s %s",
+	$subQuery, $where, $filter, $orderbyText);
 	
 	$alerts = get_db_all_rows_sql ($sql);
 	
diff --git a/pandora_console/operation/agentes/alerts_status.php b/pandora_console/operation/agentes/alerts_status.php
index 166bdb5ed4..efa65b352b 100644
--- a/pandora_console/operation/agentes/alerts_status.php
+++ b/pandora_console/operation/agentes/alerts_status.php
@@ -70,7 +70,7 @@ if (isset ($_GET["id_agente"])) {
 		exit;
 	}
 	
-	$alerts_simple = get_agent_alerts_simple ($id_agent, $filter);
+	$alerts_simple = get_agent_alerts_simple ($id_agent, $filter, false, '', false, 'agent_module_name');
 	$alerts_combined = get_agent_alerts_compound ($id_agent, $filter);
 	$print_agent = false;
 	$inside_main = 1;