From 6b3930c38f8c70b6ee28317c125cd0a95cb761cf Mon Sep 17 00:00:00 2001 From: darode Date: Wed, 30 May 2012 08:30:40 +0000 Subject: [PATCH] 2012-05-30 Dario Rodriguez * include/functions_reporting.php: Fixed group view, unkown agent count was wrong. MERGED PANDORA 4.0.2 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6363 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 7 +++++ .../include/functions_reporting.php | 28 +++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index d18290dfe1..94d2bcb56a 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,10 @@ +2012-05-30 Dario Rodriguez + + * include/functions_reporting.php: Fixed group view, + unkown agent count was wrong. + + MERGED PANDORA 4.0.2 + 2012-05-30 Hirofumi Kosaka * godmode/db/db_main.php: Tiny bug fix. The number of log4x diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index e9ec535f5d..40521b0753 100644 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -912,22 +912,38 @@ function reporting_get_group_stats ($id_group = 0) { switch ($config["dbtype"]) { case "mysql": - $data["agents_unknown"] += db_get_sql ("SELECT COUNT(*) + $agents_in_group = db_get_all_rows_sql ("SELECT id_agente FROM tagente - WHERE id_grupo IN $group_clause AND disabled = 0 AND ultimo_contacto < NOW() - (intervalo * 2)"); + WHERE id_grupo IN $group_clause AND disabled = 0"); break; case "postgresql": - $data["agents_unknown"] += db_get_sql ("SELECT COUNT(*) + $agents_in_group = db_get_all_rows_sql ("SELECT id_agente FROM tagente - WHERE id_grupo IN $group_clause AND disabled = 0 AND ceil(date_part('epoch', ultimo_contacto)) < ceil(date_part('epoch', NOW())) - (intervalo * 2)"); + WHERE id_grupo IN $group_clause AND disabled = 0"); break; case "oracle": - $data["agents_unknown"] += db_get_sql ("SELECT COUNT(*) + $agents_in_group = db_get_all_rows_sql ("SELECT id_agente FROM tagente - WHERE id_grupo IN $group_clause AND disabled = 0 AND ultimo_contacto < CURRENT_TIMESTAMP - (intervalo * 2)"); + WHERE id_grupo IN $group_clause AND disabled = 0"); break; } + //Count unkown agents, forget agent without modules + if (!$agents_in_group) { + $agents_in_group = array(); + } + $data["agents_unknown"] = 0; + + foreach ($agents_in_group as $id) { + $info = reporting_get_agent_module_info($id['id_agente']); + + //If the agent has modules then is counted + if ($info['monitor_unknown']) { + $data["agents_unknown"]++; + } + } + + //Calculate other metrics $data["total_agents"] += db_get_sql ("SELECT COUNT(*) FROM tagente WHERE id_grupo IN $group_clause AND disabled = 0");