diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index cb05149ae3..357d580b7f 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -1,3 +1,10 @@
+2012-07-20 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
+
+	* include/db/mysql.php
+	 include/functions_groups.php
+	 include/functions_agents.php: Added functions to count global 
+	 elements (groups or agents), counting disabled elements too. 
+
 2012-07-20  Hirofumi Kosaka  <kosaka@rworks.jp>
 
         * index.php: bug fix: 'Enforce https' led to wrong URL to
diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php
index b35a4a3b40..95f2286426 100644
--- a/pandora_console/include/db/mysql.php
+++ b/pandora_console/include/db/mysql.php
@@ -1046,4 +1046,5 @@ function mysql_db_get_table_count($sql, $search_history_db = false) {
 	
 	return $count;
 }
+
 ?>
\ No newline at end of file
diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php
index 8eba38c4b4..9909a88d51 100644
--- a/pandora_console/include/functions_agents.php
+++ b/pandora_console/include/functions_agents.php
@@ -1882,9 +1882,14 @@ function agents_get_count_incidents ($id_agent) {
 	return db_get_value('count(*)', 'tincidencia', 'id_agent', $id_agent);
 }
 
-
-// Get critical monitors by using the status code in modules.
-
+/**
+ * Get critical monitors by using the status code in modules.
+ *
+ * @param int The agent id
+ * @param string Additional filters
+ *
+ * @return mixed The incidents attached or false
+ */
 function agents_monitor_critical ($id_agent, $filter="") {
 	
 	if ($filter) {
@@ -1927,6 +1932,34 @@ function agents_monitor_ok ($id_agent, $filter="") {
 	return db_get_sql ("SELECT COUNT( DISTINCT tagente_modulo.id_agente_modulo) FROM tagente_estado, tagente, tagente_modulo WHERE tagente.disabled = 0 AND tagente_estado.utimestamp != 0 AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo AND tagente_modulo.disabled = 0 AND estado = 0 AND tagente_estado.id_agente = tagente.id_agente AND tagente.id_agente = $id_agent".$filter);
 }
 
+/**
+ * Get all monitors of an specific agent.
+ *
+ * @param int The agent id
+ * @param string Additional filters
+ * @param bool Whether to retrieve disabled modules or not
+ *
+ * @return mixed Total module count or false
+ */
+function agents_monitor_total ($id_agent, $filter = '', $disabled = false) {
+	
+	if ($filter) {
+		$filter = " AND ".$filter;
+	}
+	
+	$sql = "SELECT COUNT( DISTINCT tagente_modulo.id_agente_modulo) 
+			FROM tagente_estado, tagente, tagente_modulo 
+			WHERE " . //tagente_estado.utimestamp != 0 AND 
+			"tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo 
+			AND tagente_estado.id_agente = tagente.id_agente 
+			AND tagente.id_agente = $id_agent".$filter;
+	
+	if (!$disabled)
+		$sql .= " AND tagente.disabled = 0 AND tagente_modulo.disabled = 0";
+	
+	return db_get_sql ($sql);
+}
+
 //Get alert fired for this agent
 
 function agents_get_alerts_fired ($id_agent, $filter="") {
diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php
index 4fe00bc3ee..0bf2389ce0 100644
--- a/pandora_console/include/functions_groups.php
+++ b/pandora_console/include/functions_groups.php
@@ -1248,9 +1248,16 @@ function groups_monitor_fired_alerts ($group_array) {
 					
 }
 
-// Total agents in a group, except disabled ones
-
-function groups_total_agents ($group_array) {
+/**
+ *  Total agents in a group, (by default except disabled ones)
+ *
+ * @param mixed Array or (comma separated) string with groups
+ * @param bool Whether to count disabled agents
+ *
+ * @return mixed Return group count or false if something goes wrong
+ * 
+ */
+function groups_total_agents ($group_array, $disabled = false) {
 	
 	if (empty ($group_array)) {
 		return 0;
@@ -1262,8 +1269,39 @@ function groups_total_agents ($group_array) {
 	$group_clause = implode (",", $group_array);
 	$group_clause = "(" . $group_clause . ")";
 	
-	return db_get_sql ("SELECT COUNT(*) FROM tagente WHERE id_grupo IN $group_clause AND disabled = 0");
+	$sql = "SELECT COUNT(*) FROM tagente WHERE id_grupo IN $group_clause";
+	
+	if (!$disabled)
+		$sql .= " AND disabled = 0";
+	html_debug_print($sql, "/tmp/pp");
+	return db_get_sql ($sql);
 					
 }
 
+/**
+ *  Number of disabled agents in a group
+ *
+ * @param mixed Array or (comma separated) string with groups
+ *
+ * @return mixed Return group count or false if something goes wrong
+ * 
+ */
+function groups_agent_disabled ($group_array) {
+	
+	if (empty ($group_array)) {
+		return 0;
+		
+	} else if (!is_array ($group_array)){
+		$group_array = array($group_array);
+	}
+			
+	$group_clause = implode (",", $group_array);
+	$group_clause = "(" . $group_clause . ")";
+	
+	$sql = "SELECT COUNT(*) FROM tagente WHERE id_grupo IN $group_clause AND disabled = 1";
+	
+	return db_get_sql ($sql);	
+	
+}
+
 ?>