, 2003-2006 // Raul Mateos , 2005-2006 // Load global vars require("include/config.php"); //require("include/functions.php"); //require("include/functions_db.php"); if (comprueba_login() == 0) { if ((give_acl($id_user, 0, "AR")==1) or (give_acl($id_user,0,"AW")) or (dame_admin($id_user)==1)) { if (isset($_POST["ag_group"])) $ag_group = $_POST["ag_group"]; elseif (isset($_GET["group_id"])) $ag_group = $_GET["group_id"]; else $ag_group = -1; if (isset($_GET["ag_group_refresh"])){ $ag_group = $_GET["ag_group_refresh"]; } echo "

".$lang_label["ag_title"]."

"; echo "

".$lang_label["summary"]." ".$lang_label["help"]."

"; $iduser_temp=$_SESSION['id_usuario']; // Show group selector if (isset($_POST["ag_group"])){ $ag_group = $_POST["ag_group"]; echo "
"; } else { echo ""; } echo ""; echo "
"; echo ""; echo ""; // Show only selected groups if ($ag_group > 1) $sql='SELECT * FROM tagente WHERE id_grupo='.$ag_group.' order by nombre'; else $sql='SELECT * FROM tagente order by id_grupo, nombre'; $result=mysql_query($sql); if (mysql_num_rows($result)){ // Load icon index from tgrupos $iconindex_g[]=""; $sql_g='SELECT id_grupo, icon FROM tgrupo'; $result_g=mysql_query($sql_g); while ($row_g=mysql_fetch_array($result_g)){ $iconindex_g[$row_g["id_grupo"]] = $row_g["icon"]; } echo ""; echo " - ".$lang_label["fired"]; echo "  "; echo " - ".$lang_label["not_fired"]; echo "
"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; // For every agent deficed in the agent table $color = 1; while ($row=mysql_fetch_array($result)){ if ($row["disabled"] == 0) { $intervalo = $row["intervalo"]; // Interval in seconds $id_agente = $row['id_agente']; $nombre_agente = $row["nombre"]; $direccion_agente =$row["direccion"]; $id_grupo=$row["id_grupo"]; $id_os = $row["id_os"]; $agent_type = $row["agent_type"]; $ultimo_contacto = $row["ultimo_contacto"]; foreach ($mis_grupos as $migrupo){ //Verifiy if the group this agent begins is one of the user groups if (($migrupo ==1) || ($id_grupo==$migrupo)){ $pertenece = 1; break; } else $pertenece = 0; } if ($pertenece == 1) { // Si el agente pertenece a uno de los grupos que el usuario puede visualizar // Obtenemos la lista de todos los modulos de cada agente $sql_t="SELECT * FROM tagente_estado, tagente_modulo WHERE tagente_estado.id_agente_modulo = tagente_modulo.id_agente_modulo AND tagente_modulo.id_agente=".$id_agente; $result_t=mysql_query($sql_t); $estado_general = 0; $numero_modulos = 0; $numero_monitor = 0; $est_timestamp = ""; $monitor_bad=0; $estado_cambio=0; // Oops, I forgot initialize this fucking var... many problems due it while ($row_t=mysql_fetch_array($result_t)){ $est_modulo = $row_t["estado"]; # Sumamos los estados los modulos de cada agente, si hay uno mal, resultado total malo if ($est_modulo <> 100) { $estado_general = $estado_general + $est_modulo; $estado_cambio = $estado_cambio + $row_t["cambio"]; $numero_monitor ++; if ($est_modulo <> 0) $monitor_bad++; } $numero_modulos++; } # Defines if Agent is down (interval x 2) $ahora=date("Y/m/d H:i:s"); if ($ultimo_contacto <> "") $seconds = strtotime($ahora) - strtotime($ultimo_contacto); else $seconds = -100000; # Defines if Agent is down (interval x 2 > time last contact if ($seconds >= ($intervalo*2)) // If (intervalx2) secs. ago we don't get anything, show alert $agent_down = 1; else $agent_down = 0; // Color change for each line (1.2 beta2) if ($color == 1){ $tdcolor = "datos"; $color = 0; } else { $tdcolor = "datos2"; $color = 1; } echo ""; echo ""; echo "
".$lang_label["agent"]."".$lang_label["os"]."".$lang_label["interval"]."".$lang_label["group"]."".$lang_label["modules"]."".$lang_label["status"]."".$lang_label["alerts"]."".$lang_label["last_contact"]."
"; $id_grupo=dame_id_grupo($id_agente); if (give_acl($id_user, $id_grupo, "AW")==1){ echo ""; } echo "  ".$nombre_agente.""; if ( $agent_type == 0) { // Show SO icon :) echo "".dame_so_name($id_os).""; } elseif ($agent_type == 1) { // Show network icon (for pandora 1.2) echo "Network Agent"; } echo "".$intervalo; echo ' ( '.dame_grupo($id_grupo).' )'; echo " ".$numero_modulos." / ".$numero_monitor; if ($monitor_bad <> 0) echo " / ".$monitor_bad.""; if ($agent_down == 1) echo ""; else if ($numero_monitor <> 0) if ($estado_general <> 0) if ($estado_cambio == 0) echo ""; else echo ""; else echo ""; elseif ($numero_modulos <> 0) echo ""; else echo ""; // checks if an alert was fired recently echo ""; if (check_alert_fired($id_agente) == 1) echo ""; else echo ""; echo ""; if ($agent_down == 1) // if agent down, red and bold echo ""; if ( $ultimo_contacto == "0000-00-00 00:00:00") echo $lang_label["never"]; else { $ultima = strtotime($ultimo_contacto); $ahora = strtotime("now"); $diferencia = $ahora - $ultima; if ($intervalo > 0){ $percentil = round($diferencia/(($intervalo*2) / 100)); } else { echo "N/A"; } echo "  $ultimo_contacto"; // echo $ultimo_contacto; } } // writing agent data } // Disabled agent } echo "

"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
"; echo " - ".$lang_label["green_light"].""; echo " - ".$lang_label["red_light"].""; echo " - ".$lang_label["yellow_light"]."
"; echo " - ".$lang_label["no_light"].""; echo " - ".$lang_label["blue_light"].""; echo " - ".$lang_label["broken_light"]."
"; } else { echo ''.$lang_label["no_agent"].''; } } else { audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent view"); require ("general/noaccess.php"); } } ?>