".__('Pandora Agents')." > ".__('Summary').""; // Show group selector (POST) if (isset($_POST["ag_group"])){ $ag_group = $_POST["ag_group"]; echo "
"; } else { echo ""; } echo ""; echo ""; echo "
".__('Group').""; echo ""; echo " "; echo __('Free text for search (*)'); echo ""; echo "
"; echo ""; echo "
"; echo ""; echo ""; echo "
"; if ($search != ""){ $search_sql = " AND nombre LIKE '%$search%' OR direccion LIKE '%$search%' "; } else { $search_sql = ""; } // Show only selected groups if ($ag_group > 1){ $sql="SELECT * FROM tagente WHERE id_grupo=$ag_group AND disabled = 0 $search_sql ORDER BY nombre LIMIT $offset, ".$config["block_size"]; $sql2="SELECT COUNT(id_agente) FROM tagente WHERE id_grupo=$ag_group AND disabled = 0 $search_sql ORDER BY nombre"; // Not selected any specific group } else { // Is admin user ?? $sql = sprintf ("SELECT * FROM tusuario WHERE id_usuario ='%s'", $config['id_user']); if (get_db_sql ($sql, "nivel") == 1) { $sql = "SELECT * FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo LIMIT $offset, ".$config["block_size"]; $sql2 = "SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo"; // standard user } else { // User has explicit permission on group 1 ? $sql = sprintf ("SELECT COUNT(id_grupo) FROM tusuario_perfil WHERE id_usuario='%s' AND id_grupo = 1", $config['id_user']); $all_group = get_db_sql ($sql); if ($all_group > 0) { $sql = sprintf ("SELECT * FROM tagente WHERE disabled = 0 %s ORDER BY nombre, id_grupo LIMIT %d,%d", $search_sql, $offset, $config["block_size"]); $sql2 = sprintf ("SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 %s ORDER BY nombre, id_grupo", $search_sql); } else { $sql = sprintf ("SELECT * FROM tagente WHERE disabled = 0 %s AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='%s') ORDER BY nombre, id_grupo LIMIT %d,%d", $search_sql, $config['id_user'], $offset, $config["block_size"]); $sql2 = sprintf ("SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 %s AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='%s') ORDER BY nombre, id_grupo", $search_sql, $config['id_user']); } } } $result2 = mysql_query ($sql2); $row2 = mysql_fetch_array ($result2); $total_events = $row2[0]; // Prepare pagination pagination ($total_events, "index.php?sec=estado&sec2=operation/agentes/estado_agente&group_id=$ag_group&refr=60", $offset); // Show data. $result=mysql_query($sql); if (mysql_num_rows($result)){ echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; // For every agent defined in the agent table $color = 1; while ($row=mysql_fetch_array($result)){ $intervalo = $row["intervalo"]; // Interval in seconds $id_agente = $row['id_agente']; $nombre_agente = substr(strtoupper($row["nombre"]),0,18); $direccion_agente =$row["direccion"]; $id_grupo=$row["id_grupo"]; $id_os = $row["id_os"]; $ultimo_contacto = $row["ultimo_contacto"]; $biginterval=$intervalo; 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.disabled = 0 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; $monitor_ok = 0; $monitor_down=0; $numero_datamodules=0; $estado_cambio=0; $ahora=date("Y/m/d H:i:s"); // Calculate module/monitor totals for this agent while ($row_t=mysql_fetch_array($result_t)){ $est_modulo = $row_t["estado"]; $ultimo_contacto_modulo = $row_t["timestamp"]; $module_interval = $row_t["module_interval"]; $module_type = $row_t["id_tipo_modulo"]; if ($module_interval > $biginterval) $biginterval = $module_interval; if ($module_interval !=0) $intervalo_comp = $module_interval; else $intervalo_comp = $intervalo; if ($ultimo_contacto <> "") $seconds = strtotime($ahora) - strtotime($ultimo_contacto_modulo); else $seconds = -1; if (($module_type < 21) OR ($module_type == 100)){ $async = 0; } else { $async = 1; } # Defines if Agent is down (interval x 2 > time last contact if ($seconds >= ($intervalo_comp*2)){ // If (intervalx2) secs. ago we don't get anything, show alert if ($est_modulo != 100) $numero_monitor++; if ($async == 0) $monitor_down++; } elseif ($est_modulo != 100) { // estado=100 are data modules $estado_general = $estado_general + $est_modulo; $estado_cambio = $estado_cambio + $row_t["cambio"]; $numero_monitor ++; if ($est_modulo != 0) $monitor_bad++; else $monitor_ok++; } elseif ($est_modulo == 100){ // Data modules $numero_datamodules++; } $numero_modulos++; } // Color change for each line (1.2 beta2) if ($color == 1){ $tdcolor = "datos"; $color = 0; } else { $tdcolor = "datos2"; $color = 1; } echo ""; echo ""; // Show SO icon :) echo ""; // If there are a module interval bigger than agent interval if ($biginterval > $intervalo) { echo ""; } else { echo ""; } // Show GROUP icon echo ''; echo ""; /* if ($numero_monitor <> 0){ if ($estado_general <> 0){ if ($estado_cambio == 0){ // RED echo ""; echo ""; echo "
".__('Agent')."".__('OS')."".__('Interval')."".__('Group')."".__('Modules')."".__('Status')."".__('Alerts')."".__('Last contact')."
"; if (give_acl ($config['id_user'], $id_grupo, "AW")) { echo " "; } echo "  ".$nombre_agente." ".dame_so_name($id_os)." ".$biginterval."".$intervalo."'; echo ""; echo ' ". $numero_modulos." / ".$numero_monitor; if ($monitor_bad <> 0) { echo " / ".$monitor_bad.""; } if ($monitor_down <> 0){ echo " / ".$monitor_down.""; } echo ""; } else { // Yellow echo ""; } } elseif ($monitor_ok > 0) { // Green echo ""; } elseif ($numero_datamodules > 0) { // Grey #1 echo ""; } elseif ($monitor_down > 0) { // Grey - Red echo ""; } } else { // Blue echo ""; } */ echo ""; if ($numero_monitor <> 0){ if ($estado_general <> 0){ if ($estado_cambio == 0){ echo ""; } else { echo ""; } } elseif ($monitor_ok > 0) { echo ""; } elseif ($numero_datamodules > 0) { echo ""; } elseif ($monitor_down > 0) { echo ""; } } else echo ""; // checks if an alert was fired recently echo ""; if (give_disabled_group($id_grupo) == 1) echo ""; else { if (check_alert_fired($id_agente) == 1) echo ""; else echo ""; } echo ""; if ( $ultimo_contacto == "0000-00-00 00:00:00"){ echo __('Never'); } else { $ultima = strtotime($ultimo_contacto); $ahora = strtotime("now"); $diferencia = $ahora - $ultima; if ( $diferencia > ($biginterval*2)) echo ""; echo human_time_comparation($ultimo_contacto); /* if ($biginterval > 0){ $percentil = round($diferencia/(($biginterval*2) / 100)); } else { $percentil = -1; } echo "  $ultimo_contacto";*/ } } // If pertenece/belongs to group } echo "

"; require "bulbs.php"; } else { echo '
'.__('There are no agents included in this group').'
'; if (give_acl ($config['id_user'], 0, "LM") || give_acl ($config['id_user'], 0, "AW") || give_acl ($config['id_user'], 0, "PM") || give_acl ($config['id_user'], 0, "DM") || give_acl ($config['id_user'], 0, "UM")) { echo " 
"; } } ?>