Fixed filter group in agents/modules view
This commit is contained in:
parent
46830a4cbe
commit
958930931e
|
@ -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:
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue