".__('Pandora Agents')." > ".__('Group view').""; // Update network modules for this group // Check for Network FLAG change request // Made it a subquery, much faster on both the database and server side if (isset ($_GET["update_netgroup"])) { $group = get_parameter_get ("update_netgroup", 0); if (give_acl ($config['id_user'], $group, "AW")) { $sql = sprintf ("UPDATE tagente_modulo SET `flag` = 1 WHERE `id_agente` = ANY(SELECT id_agente FROM tagente WHERE `id_grupo` = %d)",$group); process_sql ($sql); } else { audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to set flag for groups"); require ("general/noaccess.php"); exit; } } // Get group list that user has access $groups = get_user_groups ($config['id_user']); $groups_info = array (); $total_agents = 0; $now = get_system_time (); // Prepare data to show // For each valid group for this user, take data from agent and modules foreach ($groups as $id_group => $group_name) { $sql = sprintf ("SELECT COUNT(id_agente) FROM tagente WHERE id_grupo = %d AND disabled = 0", $id_group); $agents = get_db_sql ($sql); if ($agents == 0) continue; $total_agents += $agents; $group_info = array ('agent' => $agents, 'normal' => 0, 'critical' => 0, 'warning' => 0, 'alerts' => 0, 'down' => 0, 'icon' => dame_grupo_icono ($id_group), 'id_group' => $id_group, 'name' => $group_name); // SQL Join to get monitor status for agents belong this group $sql = sprintf ("SELECT tagente_estado.estado, tagente_estado.current_interval, tagente_estado.utimestamp, tagente_modulo.id_tipo_modulo FROM tagente, tagente_estado, tagente_modulo WHERE tagente.disabled = 0 AND tagente.id_grupo = %d AND tagente.id_agente = tagente_estado.id_agente AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_estado.utimestamp != 0", $id_group); $modules = get_db_all_rows_sql ($sql); if ($modules === false) $modules = array (); foreach ($modules as $module) { $seconds = $now - $module['utimestamp']; if ($seconds >= ($module['current_interval'] * 2)) { if ($module['id_tipo_modulo'] < 21) // Avoiding ASYNC and Keepalive $group_info['down']++; } elseif ($module['estado'] == 2) { $group_info['warning']++; } elseif ($module['estado'] == 1) { $group_info['critical']++; } else { $group_info['normal']++; } } if ($config["show_lastalerts"] == 1) { // How many alerts has been fired recently for this group: // SQL Join to get alert status for agents belong this group $sql = sprintf ("SELECT SUM(talert_template_modules.times_fired) FROM tagente_modulo, talert_template_modules, tagente WHERE tagente.disabled = 0 AND tagente.id_grupo = %d AND tagente.id_agente = tagente_modulo.id_agente AND talert_template_modules.id_agent_module = tagente_modulo.id_agente_modulo", $id_group); $group_info["alerts"] = (int) get_db_sql ($sql); } array_push ($groups_info, $group_info); } if ($total_agents == 0) { echo '
'; // Grey border if agent down if ($group_info["down"] > 0) $celda = ' | '; // Yellow border if agents WARNING if ($group_info["warning"] > 0) $celda = ' | '; // Red border if agents CRITICAL if ($group_info["critical"] > 0) $celda = ' | '; // Magenta border if agents with alerts if ($group_info["alerts"] > 0) $celda = ' | '; // Black if alerts and down modules if (($group_info["critical"] > 0) && ($group_info["alerts"] > 0)) $celda = ' | ';
$celda .= '';
// Add group icon
$celda .= '';
// Add float info table
$celda .= '
'.$icono_type.' '.$group_name.''; echo $celda; $real_count++; } echo " |