From 958930931e5ffcea9c7d18f3f3d53fea29d1f3c9 Mon Sep 17 00:00:00 2001 From: danielmaya Date: Wed, 3 Oct 2018 10:42:59 +0200 Subject: [PATCH] Fixed filter group in agents/modules view --- pandora_console/include/functions_agents.php | 4 ++ .../operation/agentes/ver_agente.php | 48 ++----------------- 2 files changed, 9 insertions(+), 43 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 426a5c2e6b..a077f1ef45 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -912,6 +912,10 @@ function agents_get_group_agents ( unset ($search["alias"]); } + if (isset($search['id_os'])) { + $filter[] = "id_os = ". $search['id_os']; + } + if (isset($search['status'])) { switch ($search['status']) { case AGENT_STATUS_NORMAL: diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 49011d540d..05ea2532a1 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -60,21 +60,8 @@ if (is_ajax ()) { $keys_prefix = (string) get_parameter ('keys_prefix', ''); $status_agents = (int)get_parameter('status_agents', AGENT_STATUS_ALL); - if ($id_group > 0) { - $groups = array($id_group); - if ($recursion === 'true' || $recursion == 1 ) { - $groups = array_merge($groups, - groups_get_id_recursive($id_group, true)); - } - } - else { - $groups_orig = users_get_groups(false, $privilege); - $groups = array_keys($groups_orig); - } - // Build filter $filter = array(); - $filter['id_grupo'] = $groups; if (!empty($id_os)) $filter['id_os'] = $id_os; @@ -83,27 +70,7 @@ if (is_ajax ()) { if (!empty($agent_alias)) $filter['alias'] = '%' . $agent_alias . '%'; - switch ($status_agents) { - case AGENT_STATUS_NORMAL: - $filter[] = "(normal_count = total_count)"; - break; - case AGENT_STATUS_WARNING: - $filter[] = "(critical_count = 0 AND warning_count > 0)"; - break; - case AGENT_STATUS_CRITICAL: - $filter[] = "(critical_count > 0)"; - break; - case AGENT_STATUS_UNKNOWN: - $filter[] = "(critical_count = 0 AND warning_count = 0 AND unknown_count > 0)"; - break; - case AGENT_STATUS_NOT_NORMAL: - $filter[] = "(normal_count <> total_count)"; - break; - case AGENT_STATUS_NOT_INIT: - $filter[] = "(notinit_count = total_count)"; - break; - } - $filter['order'] = "alias ASC"; + $filter['status'] = $status_agents; if($cluster_mode){ @@ -141,23 +108,18 @@ if (is_ajax ()) { } } - - // Build fields - $fields = array('id_agente', 'alias'); // Perform search - $agents = db_get_all_rows_filter('tagente', $filter, $fields); + $agents = agents_get_group_agents($id_group,$filter,"lower",false,false,false,'|',$cluster_mode); if (empty($agents)) $agents = array(); - - foreach ($agents as $k => $v) { - $agents[$k] = io_safe_output($v); - } // Add keys prefix if ($keys_prefix !== '') { + $i = 0; foreach ($agents as $k => $v) { - $agents[$keys_prefix . $k] = io_safe_output($v); + $agents[$keys_prefix . $i] = array('id_agente' => $k, 'alias' => io_safe_output($v)); unset($agents[$k]); + $i++; } }