From 986a0cc60aca88167cea1567ee301a6d23144e2f Mon Sep 17 00:00:00 2001 From: darode Date: Mon, 16 Jul 2012 13:17:30 +0000 Subject: [PATCH] 2012-07-16 Dario Rodriguez * include/functions_groups.php: Included void agents on normal status. include/functions_os.php: Included void agents on normal status. operation/tree.php: Fixed OS, groups and included void agents in groups and OS views. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6777 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 9 ++ pandora_console/include/functions_groups.php | 8 +- pandora_console/include/functions_os.php | 9 +- pandora_console/operation/tree.php | 95 +++++--------------- 4 files changed, 46 insertions(+), 75 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 1bd1a95cfb..0069dc0e93 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,12 @@ +2012-07-16 Dario Rodriguez + + * include/functions_groups.php: Included void agents on + normal status. + include/functions_os.php: Included void agents on + normal status. + operation/tree.php: Fixed OS, groups and included void agents + in groups and OS views. + 2012-07-16 Dario Rodriguez * operation/tree.php: Fixed all views: deleted alert fired diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index b59e9e8bb7..4fe00bc3ee 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -962,6 +962,12 @@ function groups_agent_ok ($group_array) { AND tagente_estado.utimestamp != 0 AND tagente.id_grupo IN $group_clause group by tagente.id_agente"; + + // Agents without modules has a normal status + $void_agents = "SELECT tagente.id_agente FROM tagente + WHERE tagente.disabled = 0 + AND tagente.id_grupo IN $group_clause + AND tagente.id_agente NOT IN (SELECT tagente_estado.id_agente FROM tagente_estado)"; return db_get_sql ("SELECT COUNT(*) FROM ( SELECT DISTINCT tagente.id_agente FROM tagente, tagente_modulo, tagente_estado @@ -972,7 +978,7 @@ function groups_agent_ok ($group_array) { AND tagente.id_agente NOT IN ($agents_critical) AND tagente.id_agente NOT IN ($agents_warning) AND tagente.id_agente NOT IN ($agents_unknown) - AND tagente.id_agente IN ($agents_ok) ) AS t"); + AND tagente.id_agente IN ($agents_ok) UNION $void_agents) AS t"); } diff --git a/pandora_console/include/functions_os.php b/pandora_console/include/functions_os.php index d6e4036d49..b6d5b0a0de 100755 --- a/pandora_console/include/functions_os.php +++ b/pandora_console/include/functions_os.php @@ -75,6 +75,12 @@ function os_agents_ok($id_os) { AND tagente.id_os = $id_os group by tagente.id_agente"; + // Agents without modules has a normal status + $void_agents = "SELECT id_agente FROM tagente + WHERE disabled = 0 + AND id_os = $id_os + AND id_agente NOT IN (SELECT id_agente FROM tagente_estado)"; + return db_get_sql ("SELECT COUNT(*) FROM ( SELECT DISTINCT tagente.id_agente FROM tagente, tagente_modulo, tagente_estado WHERE tagente.id_agente = tagente_modulo.id_agente @@ -84,7 +90,8 @@ function os_agents_ok($id_os) { AND tagente.id_agente NOT IN ($agents_critical) AND tagente.id_agente NOT IN ($agents_warning) AND tagente.id_agente NOT IN ($agents_unknown) - AND tagente.id_agente IN ($agents_ok) ) AS t"); + AND tagente.id_agente IN ($agents_ok) + UNION $void_agents) AS t"); } diff --git a/pandora_console/operation/tree.php b/pandora_console/operation/tree.php index bb69ddbd03..215212c89d 100644 --- a/pandora_console/operation/tree.php +++ b/pandora_console/operation/tree.php @@ -270,16 +270,6 @@ if (is_ajax ()) false, true); - // Skip agents without modules - $sql .= ' AND id_agente IN - (SELECT tagente.id_agente - FROM tagente, tagente_modulo - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente.id_grupo = ' . $id . ' AND tagente.disabled = 0 - AND tagente_modulo.disabled = 0 - group by tagente.id_agente - having COUNT(*) > 0)'; - break; case 'os': $sql = agents_get_agents(array ( @@ -294,15 +284,6 @@ if (is_ajax ()) false, true); - // Skip agents without modules - $sql .= ' AND id_agente IN - (SELECT tagente.id_agente - FROM tagente, tagente_modulo - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente.id_os = ' . $id . ' AND tagente.disabled = 0 - AND tagente_modulo.disabled = 0 - group by tagente.id_agente - having COUNT(*) > 0)'; break; case 'module_group': @@ -319,13 +300,13 @@ if (is_ajax ()) // Skip agents without modules $sql .= ' AND id_agente IN - (SELECT tagente.id_agente - FROM tagente, tagente_modulo - WHERE tagente.id_agente = tagente_modulo.id_agente - AND id_module_group = ' . $id . ' AND tagente.disabled = 0 - AND tagente_modulo.disabled = 0 - group by tagente.id_agente - having COUNT(*) > 0)'; + (SELECT tagente.id_agente + FROM tagente, tagente_modulo + WHERE tagente.id_agente = tagente_modulo.id_agente + AND id_module_group = ' . $id . ' AND tagente.disabled = 0 + AND tagente_modulo.disabled = 0 + group by tagente.id_agente + having COUNT(*) > 0)'; break; case 'policies': @@ -343,40 +324,6 @@ if (is_ajax ()) false, true); - if ($id == 0) { - - // Skip agents without modules - $sql .= ' AND tagente.id_agente IN - (SELECT tagente.id_agente - FROM tagente, tagente_modulo, tagente_estado - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo - AND tagente.disabled = 0 - AND tagente_modulo.disabled = 0 - AND tagente_estado.utimestamp != 0 - AND tagente_modulo.id_policy_module = 0 - AND tagente.id_agente NOT IN (SELECT id_agent FROM tpolicy_agents) - group by tagente.id_agente - having COUNT(*) > 0)'; - - } else { - - // Skip agents without modules - $sql .= ' AND tagente.id_agente IN - (SELECT tagente.id_agente - FROM tagente, tagente_modulo, tagente_estado - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo - AND tagente.disabled = 0 - AND tagente_modulo.disabled = 0 - AND tagente_estado.utimestamp != 0 - AND tagente_modulo.id_policy_module != 0 - AND tagente.id_agente IN (SELECT id_agent FROM tpolicy_agents) - group by tagente.id_agente - having COUNT(*) > 0)'; - - } - break; case 'module': //Replace separator token "articapandora_32_pandoraartica_" for " " @@ -813,7 +760,16 @@ function printTree_($type) { //Get all groups with agents $full_groups = db_get_all_rows_sql("SELECT DISTINCT tagente.id_grupo FROM tagente, tagente_estado WHERE - tagente.id_agente = tagente_estado.id_agente AND tagente_estado.utimestamp != 0"); + tagente.id_agente = tagente_estado.id_agente AND tagente_estado.utimestamp != 0 + UNION SELECT tagente.id_grupo FROM tagente + WHERE disabled = 0 + AND id_agente NOT IN (SELECT tagente.id_agente + FROM tagente, tagente_modulo + WHERE tagente.id_agente = tagente_modulo.id_agente + AND tagente.disabled = 0 + AND tagente_modulo.disabled = 0 + group by tagente.id_agente + having COUNT(*) > 0)"); $fgroups = array(); @@ -912,16 +868,6 @@ function printTree_($type) { false, true); - // Skip agents without modules - $sql .= ' AND id_agente IN - (SELECT tagente.id_agente - FROM tagente, tagente_modulo - WHERE tagente.id_agente = tagente_modulo.id_agente - AND tagente.disabled = 0 - AND tagente_modulo.disabled = 0 - group by tagente.id_agente - having COUNT(*) > 0)'; - $sql_os = sprintf("SELECT * FROM tconfig_os WHERE id_os IN (%s)", $sql); $list = db_get_all_rows_sql($sql_os); @@ -969,7 +915,7 @@ function printTree_($type) { AND tagente.disabled = 0 AND tagente_modulo.disabled = 0 group by tagente.id_agente - having COUNT(*) > 0)'; + having COUNT(*) > 0)'; $sql_module_groups = sprintf("SELECT * FROM tmodule_group WHERE id_mg IN (SELECT id_module_group FROM tagente_modulo WHERE id_agente IN (%s))", $sql); @@ -977,7 +923,10 @@ function printTree_($type) { $list = db_get_all_rows_sql($sql_module_groups); - if ($list !== false) + if ($list == false) { + $list = array(); + } + array_push($list, array('id_mg' => 0, 'name' => 'Not assigned')); break;