diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 502da22326..dbc91a4224 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -9340,15 +9340,34 @@ function reporting_get_agent_module_info($id_agent) $return = []; $return['last_contact'] = 0; - // Last agent contact + // Last agent contact. $return['status'] = STATUS_AGENT_NO_DATA; - $return['status_img'] = ui_print_status_image(STATUS_AGENT_NO_DATA, __('Agent without data'), true); + $return['status_img'] = ui_print_status_image( + STATUS_AGENT_NO_DATA, + __('Agent without data'), + true + ); $return['alert_status'] = 'notfired'; $return['alert_value'] = STATUS_ALERT_NOT_FIRED; - $return['alert_img'] = ui_print_status_image(STATUS_ALERT_NOT_FIRED, __('Alert not fired'), true); - $return['agent_group'] = agents_get_agent_group($id_agent); + $return['alert_img'] = ui_print_status_image( + STATUS_ALERT_NOT_FIRED, + __('Alert not fired'), + true + ); - if (!check_acl($config['id_user'], $return['agent_group'], 'AR')) { + $return['agent_group'] = ''; + // Important agents_get_all_groups_agent check secondary groups. + $id_all_groups = agents_get_all_groups_agent($id_agent); + if (isset($id_all_groups) && is_array($id_all_groups)) { + foreach ($id_all_groups as $value) { + if (check_acl($config['id_user'], $value, 'AR')) { + $return['agent_group'] = $value; + } + } + } + + // If $return['agent_group'] is empty no access. + if ($return['agent_group'] == '') { return $return; } @@ -9361,7 +9380,7 @@ function reporting_get_agent_module_info($id_agent) $now = get_system_time(); - // Get modules status for this agent + // Get modules status for this agent. $agent = db_get_row('tagente', 'id_agente', $id_agent); $return['total_count'] = $agent['total_count']; @@ -9375,28 +9394,52 @@ function reporting_get_agent_module_info($id_agent) if ($return['total_count'] > 0) { if ($return['critical_count'] > 0) { $return['status'] = STATUS_AGENT_CRITICAL; - $return['status_img'] = ui_print_status_image(STATUS_AGENT_CRITICAL, __('At least one module in CRITICAL status'), true); + $return['status_img'] = ui_print_status_image( + STATUS_AGENT_CRITICAL, + __('At least one module in CRITICAL status'), + true + ); } else if ($return['warning_count'] > 0) { $return['status'] = STATUS_AGENT_WARNING; - $return['status_img'] = ui_print_status_image(STATUS_AGENT_WARNING, __('At least one module in WARNING status'), true); + $return['status_img'] = ui_print_status_image( + STATUS_AGENT_WARNING, + __('At least one module in WARNING status'), + true + ); } else if ($return['unknown_count'] > 0) { $return['status'] = STATUS_AGENT_DOWN; - $return['status_img'] = ui_print_status_image(STATUS_AGENT_DOWN, __('At least one module is in UKNOWN status'), true); + $return['status_img'] = ui_print_status_image( + STATUS_AGENT_DOWN, + __('At least one module is in UKNOWN status'), + true + ); } else { $return['status'] = STATUS_AGENT_OK; - $return['status_img'] = ui_print_status_image(STATUS_AGENT_OK, __('All Monitors OK'), true); + $return['status_img'] = ui_print_status_image( + STATUS_AGENT_OK, + __('All Monitors OK'), + true + ); } } - // Alert not fired is by default + // Alert not fired is by default. if ($return['fired_count'] > 0) { $return['alert_status'] = 'fired'; - $return['alert_img'] = ui_print_status_image(STATUS_ALERT_FIRED, __('Alert fired'), true); + $return['alert_img'] = ui_print_status_image( + STATUS_ALERT_FIRED, + __('Alert fired'), + true + ); $return['alert_value'] = STATUS_ALERT_FIRED; } else if (groups_give_disabled_group($return['agent_group'])) { $return['alert_status'] = 'disabled'; $return['alert_value'] = STATUS_ALERT_DISABLED; - $return['alert_img'] = ui_print_status_image(STATUS_ALERT_DISABLED, __('Alert disabled'), true); + $return['alert_img'] = ui_print_status_image( + STATUS_ALERT_DISABLED, + __('Alert disabled'), + true + ); } return $return; diff --git a/pandora_console/operation/search_agents.getdata.php b/pandora_console/operation/search_agents.getdata.php index 5038800cf7..c754628731 100644 --- a/pandora_console/operation/search_agents.getdata.php +++ b/pandora_console/operation/search_agents.getdata.php @@ -182,7 +182,8 @@ if ($searchAgents) { } $sql = " - FROM tagente t1 + FROM tagente t1 LEFT JOIN tagent_secondary_group tasg + ON t1.id_agente = tasg.id_agent INNER JOIN tgrupo t2 ON t2.id_grupo = t1.id_grupo WHERE ( @@ -191,9 +192,11 @@ if ($searchAgents) { FROM tusuario WHERE id_user = '".$config['id_user']."' ) - OR t1.id_grupo IN ( - ".implode(',', $id_userGroups)." - ) OR 0 IN ( + OR ( + t1.id_grupo IN (".implode(',', $id_userGroups).') + OR tasg.id_group IN ('.implode(',', $id_userGroups).") + ) + OR 0 IN ( SELECT id_grupo FROM tusuario_perfil WHERE id_usuario = '".$config['id_user']."' @@ -208,7 +211,7 @@ if ($searchAgents) { ) '; - $select = 'SELECT t1.id_agente, t1.ultimo_contacto, t1.nombre, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled, t1.alias, t1.quiet'; + $select = 'SELECT DISTINCT(t1.id_agente), t1.ultimo_contacto, t1.nombre, t1.id_os, t1.intervalo, t1.id_grupo, t1.disabled, t1.alias, t1.quiet'; if ($only_count) { $limit = ' ORDER BY '.$order['field'].' '.$order['order'].' LIMIT '.$config['block_size'].' OFFSET 0'; } else {