".__('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"])) { if (give_acl ($config['id_user'], $_GET["update_netgroup"], "AW")) { $sql = sprintf ("UPDATE tagente_modulo SET `flag` = 1 WHERE `id_agente` = ANY(SELECT id_agente FROM tagente WHERE `id_grupo` = %d)",$_GET["update_netgroup"]); process_sql ($sql); } } // Get group list that user has access $groups = get_user_groups ($config['id_user']); $groups_info = array (); $total_agents = 0; $now = 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, 'ok' => 0, 'bad' => 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.datos, tagente_estado.current_interval, tagente_estado.utimestamp 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.estado != 100 AND tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.disabled = 0 AND tagente_estado.utimestamp != 0", $id_group); $result = get_db_all_rows_sql ($sql); foreach ($result as $module) { //if ($config["show_unknown"] > 0) { //this needs to be filled out somehow, but this was a serious bug. If that config var is set, it would short circuit both ok++ and bad++ returning empty for everything //} $seconds = $now - $module['utimestamp']; // Down = module/agent down (as in it didn't monitor in time) // Bad = module bad (as in it did monitor but it returned 0) if ($seconds >= ($module['current_interval'] * 2)) { $group_info["down"]++; } elseif ($module['datos'] != 0) { $group_info["ok"]++; } else { $group_info["bad"]++; } } 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(talerta_agente_modulo.times_fired) FROM tagente_modulo, talerta_agente_modulo, tagente WHERE tagente.disabled = 0 AND tagente.id_grupo = %d AND tagente.id_agente = tagente_modulo.id_agente AND talerta_agente_modulo.id_agente_modulo = tagente_modulo.id_agente_modulo", $id_group); $group_info["alerts"] = get_db_sql ($sql); } array_push ($groups_info, $group_info); } if ($total_agents == 0) { echo '
'; // Grey border if agent down if ($config["show_unknown"] > 0) { if ($group_info["down"] > 0) $celda = ' | '; } // Yellow border if agents with alerts if ($group_info["alerts"] > 0) $celda = ' | '; // Red border if agents bad if ($group_info["bad"] > 0) $celda = ' | '; // Orange if alerts and down modules if (($group_info["bad"] > 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 " |