From 31004702a1b2b9b1b6135da02bdc710b81e97fcd Mon Sep 17 00:00:00 2001 From: Azabel Date: Mon, 2 Oct 2006 15:01:10 +0000 Subject: [PATCH] added tooltip in module description git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@210 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/datos_agente.php | 121 ++++++++++ pandora_console/estadisticas.php | 27 +++ pandora_console/estado_agente.php | 271 +++++++++++++++++++++++ pandora_console/estado_alertas.php | 169 ++++++++++++++ pandora_console/estado_generalagente.php | 144 ++++++++++++ pandora_console/estado_grupo.php | 178 +++++++++++++++ pandora_console/estado_monitores.php | 96 ++++++++ pandora_console/estado_ultimopaquete.php | 181 +++++++++++++++ pandora_console/exportdata.php | 219 ++++++++++++++++++ pandora_console/status_monitor.php | 174 +++++++++++++++ pandora_console/ver_agente.php | 66 ++++++ 11 files changed, 1646 insertions(+) create mode 100644 pandora_console/datos_agente.php create mode 100644 pandora_console/estadisticas.php create mode 100644 pandora_console/estado_agente.php create mode 100644 pandora_console/estado_alertas.php create mode 100644 pandora_console/estado_generalagente.php create mode 100644 pandora_console/estado_grupo.php create mode 100644 pandora_console/estado_monitores.php create mode 100644 pandora_console/estado_ultimopaquete.php create mode 100644 pandora_console/exportdata.php create mode 100644 pandora_console/status_monitor.php create mode 100644 pandora_console/ver_agente.php diff --git a/pandora_console/datos_agente.php b/pandora_console/datos_agente.php new file mode 100644 index 0000000000..fa9081f19f --- /dev/null +++ b/pandora_console/datos_agente.php @@ -0,0 +1,121 @@ + '".$periodo."' ORDER BY timestamp"; + } + else { + $sql1="SELECT * FROM tagente_datos WHERE id_agente_modulo = ".$id_agente_modulo." AND timestamp > '".$periodo."' ORDER BY timestamp"; + } + + $result=mysql_query($sql1); + $nombre_agente = dame_nombre_agente_agentemodulo($id_agente_modulo); + $nombre_modulo = dame_nombre_modulo_agentemodulo($id_agente_modulo); + + echo "

".$lang_label["data_received"]." '$nombre_agente' / '$nombre_modulo'

"; + echo "

$et  ".$lang_label["help"]."

"; + if (mysql_num_rows($result)){ + echo ""; + $color=1; + echo ""; + echo ""; + while ($row=mysql_fetch_array($result)){ + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + echo ""; + echo ""; + echo "
".$lang_label["timestamp"]."".$lang_label["data"]."
".$row["timestamp"]; + echo "".salida_limpia($row["datos"]); + } + echo "
"; + } + else { + echo "no_data"; + } +} + +// Comienzo de la pagina en si misma + +if (comprueba_login() == 0) { + if (isset($_GET["tipo"]) AND isset($_GET["id"])) { + $id =entrada_limpia($_GET["id"]); + $tipo= entrada_limpia($_GET["tipo"]); + } + else { + echo "

".$lang_label["graf_error"]."

"; + exit; + } + + datos_raw($id,$tipo); +} +?> \ No newline at end of file diff --git a/pandora_console/estadisticas.php b/pandora_console/estadisticas.php new file mode 100644 index 0000000000..2b9072bbb6 --- /dev/null +++ b/pandora_console/estadisticas.php @@ -0,0 +1,27 @@ +, 2003-2006 +// Raul Mateos , 2005-2006 + +// Load global vars +require("include/config.php"); +if (comprueba_login() == 0){ + $iduser_temp=$_SESSION['id_usuario']; + if (give_acl($iduser_temp, 0, "AR") == 1){ + echo "

".$lang_label["ag_title"]."

"; + echo "

".$lang_label["db_stat_agent"]." ".$lang_label["help"]."

"; + echo ""; + echo "

"; + echo "

"; + echo "

"; + echo "
"; + } + else { + audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent estatistics"); + require ("general/noaccess.php"); + } +} +?> \ No newline at end of file diff --git a/pandora_console/estado_agente.php b/pandora_console/estado_agente.php new file mode 100644 index 0000000000..183bcef82d --- /dev/null +++ b/pandora_console/estado_agente.php @@ -0,0 +1,271 @@ +".$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.' and disabled = 0 order by nombre'; + else + $sql='SELECT * FROM tagente WHERE disabled = 0 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 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 = $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"]; + $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.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; // Oops, I forgot initialize this fucking var... many problems due it + $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"]; + 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; + + # 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++; + $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 ""; + 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"; + } + // If there are a module interval bigger than agent interval + if ($biginterval > $intervalo) + echo "".$biginterval.""; + else + echo "".$intervalo; + echo ' ( '.dame_grupo($id_grupo).' )'; + echo " ".$numero_modulos." / ".$numero_monitor; + if ($monitor_bad <> 0) + echo " / ".$monitor_bad.""; + if ($monitor_down <> 0) + echo " / ".$monitor_down.""; + 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 (check_alert_fired($id_agente) == 1) + echo ""; + else + echo ""; + + 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 ($biginterval > 0){ + $percentil = round($diferencia/(($biginterval*2) / 100)); + } else { + echo "N/A"; + } + echo "  + $ultimo_contacto"; + // echo $ultimo_contacto; + } + + } // If pertenece/belongs to group + } + 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"); +} +} +?> \ No newline at end of file diff --git a/pandora_console/estado_alertas.php b/pandora_console/estado_alertas.php new file mode 100644 index 0000000000..5f352db9ba --- /dev/null +++ b/pandora_console/estado_alertas.php @@ -0,0 +1,169 @@ +".$lang_label["alert_listing"]."".$lang_label["help"].""; + $id_agente = $_GET["id_agente"]; + $query_gen='SELECT talerta_agente_modulo.id_alerta, talerta_agente_modulo.descripcion, talerta_agente_modulo.last_fired, talerta_agente_modulo.times_fired, tagente_modulo.nombre, talerta_agente_modulo.dis_max, talerta_agente_modulo.dis_min, talerta_agente_modulo.max_alerts, talerta_agente_modulo.time_threshold, talerta_agente_modulo.min_alerts, talerta_agente_modulo.id_agente_modulo, tagente_modulo.id_agente_modulo FROM tagente_modulo, talerta_agente_modulo WHERE tagente_modulo.id_agente = '.$id_agente.' AND tagente_modulo.id_agente_modulo = talerta_agente_modulo.id_agente_modulo order by tagente_modulo.nombre'; + $result_gen=mysql_query($query_gen); + if (mysql_num_rows ($result_gen)) { + echo ""; + echo ""; + $color=1; + while ($data=mysql_fetch_array($result_gen)){ + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + echo ""; + echo "
".$lang_label["type"]."".$lang_label["name"]."".$lang_label["description"]."".$lang_label["min_max"]."".$lang_label["time_threshold"]."".$lang_label["last_fired"]."".$lang_label["times_fired"]."".$lang_label["status"]."
".dame_nombre_alerta($data["id_alerta"]); + echo "".$data["nombre"]; + echo "".$data["descripcion"]; + echo "".$data["dis_max"]."/".$data["dis_min"]; + echo "".$data["time_threshold"]; + echo "".$data["last_fired"]; + echo "".$data["times_fired"]; + if ($data["times_fired"] <> 0) + echo ""; + else + echo ""; + } + echo '
'; + } + else echo "".$lang_label["no_alerts"].""; + } + else + { + echo "

".$lang_label["ag_title"]."

"; + echo "

".$lang_label["alert_listing"]." ".$lang_label["help"]."

"; + $iduser_temp=$_SESSION['id_usuario']; + 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"]; + } + + 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)){ + $color=1; + while ($row=mysql_fetch_array($result)){ //while there are agents + if ($row["disabled"] == 0) { + $id_agente = $row['id_agente']; + $nombre_agente = $row["nombre"]; + $query_gen='SELECT talerta_agente_modulo.id_alerta, talerta_agente_modulo.descripcion, talerta_agente_modulo.last_fired, talerta_agente_modulo.times_fired, talerta_agente_modulo.id_agente_modulo, tagente_modulo.id_agente_modulo FROM tagente_modulo, talerta_agente_modulo WHERE tagente_modulo.id_agente = '.$id_agente.' AND tagente_modulo.id_agente_modulo = talerta_agente_modulo.id_agente_modulo'; + $result_gen=mysql_query($query_gen); + if (mysql_num_rows ($result_gen)) { + while ($data=mysql_fetch_array($result_gen)){ + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + if (!isset($string)) { + $string=''; + } + $string=$string."
".$nombre_agente.""; + $string=$string."".dame_nombre_alerta($data["id_alerta"]); + $string=$string."".$data["descripcion"]; + $string=$string."".$data["last_fired"]; + $string=$string."".$data["times_fired"]; + if ($data["times_fired"] <> 0) + $string=$string.""; + else + $string=$string.""; + } + } + else if($ag_group>1) { + unset($string); + } //end result + } //end disabled=0 + + } //end while + if (isset($string)) { + echo ""; + echo " - ".$lang_label["fired"]; + echo "  "; + echo " - ".$lang_label["not_fired"]; + echo "
"; + echo "
"; + echo ""; + echo ""; + echo $string; //built table of alerts + echo "
".$lang_label["agent"]."".$lang_label["type"]."".$lang_label["description"]."".$lang_label["last_fired"]."".$lang_label["times_fired"]."".$lang_label["status"]."
"; + } + else { + echo "".$lang_label["no_alert"].""; + } + } else echo "". $lang_label["no_agent"].$lang_label["no_agent_alert"].""; + } +} //end acl +} //end login + +?> \ No newline at end of file diff --git a/pandora_console/estado_generalagente.php b/pandora_console/estado_generalagente.php new file mode 100644 index 0000000000..8c823a11ba --- /dev/null +++ b/pandora_console/estado_generalagente.php @@ -0,0 +1,144 @@ +".$lang_label["agent_error"].""; + echo ""; + include ("general/footer.php"); + exit; + } + } + + // Load icon index from tgrupos + $iconindex_g[]=""; + + $sql_tg='SELECT id_grupo, icon FROM tgrupo'; + $result_tg=mysql_query($sql_tg); + while ($row_tg=mysql_fetch_array($result_tg)){ + $iconindex_g[$row_tg["id_grupo"]] = $row_tg["icon"]; + } + + echo "

".$lang_label["ag_title"]."

"; + echo "

".$lang_label["view_agent_general_data"]." ".$lang_label["help"]."

"; + echo ''; + echo '
'.$lang_label["agent_name"].' '.salida_limpia($nombre_agente); + + echo "  "; + if (dame_admin($_SESSION['id_usuario'])==1 ) + echo "  "; + // Data base access graph + + echo "".$lang_label["agent_access_rate"]."

+ "; + + echo '
'.$lang_label["ip_address"].' '.salida_limpia($direccion_agente); + if ($agent_type == 0) { + echo '
'.$lang_label["os"].' - '.dame_so_name($id_os); + } elseif ($agent_type == 1) { + echo '
'.$lang_label["agent_type"].' '.$lang_label["interval"].' '.$intervalo; + echo '
'.salida_limpia($lang_label["description"]).' '.$comentarios; + + echo "".$lang_label["agent_module_shareout"]."

"; + echo ""; + + echo '
'.salida_limpia($lang_label["group"]).' ( '.dame_grupo($id_grupo).' )'; + if ($agent_type == 0) { + echo '
'.$lang_label["agentversion"].' '.salida_limpia($agent_version); + } + + // Total packets + echo '
'.$lang_label["total_packets"].' '; + $total_paketes= 0; + $id_agente = dame_agente_id($nombre_agente); + $sql_2='SELECT * FROM tagente_modulo WHERE id_agente = '.$id_agente; + $result_t=mysql_query($sql_2); + while ($row=mysql_fetch_array($result_t)){ + $sql_3='SELECT COUNT(*) FROM tagente_datos WHERE id_agente_modulo = '.$row["id_agente_modulo"]; + $result_3=mysql_query($sql_3); + $row3=mysql_fetch_array($result_3); + $total_paketes = $total_paketes + $row3[0]; + } + echo $total_paketes; + + // Last contact + echo '
'.$lang_label["last_contact"]." / ".$lang_label["remote"].' '; + echo $ultima_act." / ".$ultima_act_remota; + + // Asigned/active server + echo '
'.$lang_label["server_asigned"].' '; + if ($server == ""){ + echo "N/A"; + } else { + echo give_server_name($server); + } + + // Next contact + + $ultima = strtotime($ultima_act); + $ahora = strtotime("now"); + $diferencia = $ahora - $ultima; + + // Get higher interval set for the set of modules from this agent + $sql_maxi ="SELECT MAX(module_interval) FROM tagente_modulo WHERE id_agente = ".$id_agente; + $result_maxi=mysql_query($sql_maxi); + if ($row_maxi=mysql_fetch_array($result_maxi)) + if ($row_maxi[0] > 0 ) + $intervalo = $row_maxi[0]; + + if ($intervalo > 0){ + $percentil = round($diferencia/(($intervalo*2) / 100)); + } else { + $percentil = -1; + } + echo '
'.$lang_label["next_contact"].' '; + + echo ""; + echo "
"; + +} + +?> \ No newline at end of file diff --git a/pandora_console/estado_grupo.php b/pandora_console/estado_grupo.php new file mode 100644 index 0000000000..cc6bcbd5a3 --- /dev/null +++ b/pandora_console/estado_grupo.php @@ -0,0 +1,178 @@ +".$lang_label["ag_title"].""; + echo "

".$lang_label["group_view"]." ".$lang_label["help"]."

"; + $iduser_temp=$_SESSION['id_usuario']; + + $sql1='SELECT * FROM tgrupo'; + $result2=mysql_query($sql1); + if (mysql_num_rows($result2)){ + while ($row=mysql_fetch_array($result2)){ + if ($row["id_grupo"]!=1) + if (give_acl($iduser_temp,$row["id_grupo"], "AR") == 1) + $mis_grupos[]=$row["id_grupo"]; //All my groups in an array + } + // Update network modules for this group + // Check for Network FLAG change request + if (isset($_GET["update_netgroup"])){ + if (give_acl($id_user, $_GET["update_netgroup"], "AW")==1){ + $sql = "SELECT * FROM tagente WHERE id_grupo = ".$_GET["update_netgroup"]; + $result=mysql_query($sql); + while ($row=mysql_fetch_array($result)){ + $id_agente = $row["id_agente"]; + $query2 ="UPDATE tagente_modulo SET flag=1 WHERE id_agente = ".$id_agente; + $res=mysql_query($query2); + } + } + } + $contador_grupo = 0; + $contador_agente=0; + $array_index = 0; + // Recorro cada grupo para ver el estado de todos los modulos + foreach ($mis_grupos as $migrupo) + if ($migrupo != "") { + $grupo[$array_index]["agent"]=0; + $grupo[$array_index]["ok"]=0; + $grupo[$array_index]["down"]=0; + $grupo[$array_index]["bad"]=0; + $grupo[$array_index]["alerts"]=0; + $grupo[$array_index]["data"]=0; + $grupo[$array_index]["icon"]=dame_grupo_icono($migrupo); + $grupo[$array_index]["id_grupo"]=$migrupo; + $existen_agentes =0; + $sql1="SELECT * FROM tagente WHERE disabled=0 AND id_grupo =".$migrupo; + if ($result1=mysql_query($sql1)){ + while ($row1 = mysql_fetch_array($result1)){ + $existen_agentes =1; + $intervalo = $row1["intervalo"]; + $id_agente=$row1["id_agente"]; // Bugsolved 0607113 + // Check for recent alerts + if (check_alert_fired($id_agente) == 1){ + $grupo[$array_index]["alerts"]++; + } + $grupo[$array_index]["agent"]++; + $grupo[$array_index]["group"]=dame_nombre_grupo($migrupo); + $contador_agente++; // Estado grupo, agent + $sql3="SELECT * FROM tagente_estado WHERE id_agente = ".$row1["id_agente"]; + $result3=mysql_query($sql3); + while ($row3 = mysql_fetch_array($result3)){ + $estado = $row3["estado"]; + // Get module interval + $ahora=date("Y/m/d H:i:s"); + $sql4="SELECT * FROM tagente_modulo WHERE id_agente_modulo = ".$row3["id_agente_modulo"]; + $result4=mysql_query($sql4); + if ($row4 = mysql_fetch_array($result4)){ + $module_interval = $row4["module_interval"]; + if ($module_interval > 0) + $intervalo_comp = $module_interval; + else { + $intervalo_comp = $intervalo; + } + } + $ultimo_contacto_modulo = $row3["timestamp"]; + # Defines if module is down (interval x 2 > time last contact) + if ($ultimo_contacto_modulo != "2000-00-00 00:00:00"){ + $seconds = strtotime($ahora) - strtotime($ultimo_contacto_modulo); + if ($seconds >= ($intervalo_comp*2)){ + $grupo[$array_index]["down"]++; + } + elseif ($estado != 100) { + if ($row3["datos"] !=0) + $grupo[$array_index]["ok"]++; + else + $grupo[$array_index]["bad"]++; + + } elseif ($estado == 100) // For data module, not monitors + $grupo[$array_index]["data"]++; // Data module + } + } + } + } + if ($existen_agentes == 1){ + $array_index++; + } + } + if ($contador_agente==0) {echo "".$lang_label["no_agent_def"]."";} + $ancho = ceil(sqrt($array_index+1)); + $real_count =0; // Puedo tener una tabla con mas items en ella que los que realmente debo mostrar, real count cuenta los que voy poniendo hasta llegar a array_index que son los que hay en el array $grupo. + echo ""; + for ($table=0;$table < $ancho;$table++){ + echo ""; + for ($table_row=0;$table_row < $ancho;$table_row++){ + if ($real_count < $array_index){ + $group_name = $grupo[$real_count]["group"]; + $icono_grupo = $grupo[$real_count]["icon"]; + $icono_type=""; + if ($grupo[$real_count]["down"]>0) { + $icono_type=""; + } + if ($grupo[$real_count]["bad"]>0) { + $icono_type=$icono_type.""; + } + if ($grupo[$real_count]["ok"]>0) { + $icono_type=$icono_type.""; + } + if ($grupo[$real_count]["data"]>0) { + $icono_type=$icono_type.""; + } + // Show yellow light if there are recent alerts fired for this group + if ($grupo[$real_count]["alerts"] > 0 ){ + $icono_type=$icono_type.""; + } + // TOOLTIP. + $celda = ""; + } + echo "
  + + + +
".$lang_label["agents"].":
".$grupo[$real_count]["agent"]."
+ + + + + + +
".ucfirst($lang_label["monitors"]).":
".$lang_label["ok"].": ".$grupo[$real_count]["ok"]."
".$lang_label["down"].": ".$grupo[$real_count]["down"]."
".$lang_label["fail"].": ".$grupo[$real_count]["bad"]."
".$lang_label["alerts"].": ".$grupo[$real_count]["alerts"]."
"; + // Render network exec module button, only when this group is writtable by user + if (give_acl($id_user, $grupo[$real_count]["id_grupo"], "AW")==1){ + $celda = $celda . ""; + } + $celda = $celda . "

".$icono_type."

".$group_name.""; + echo $celda; + } + $real_count++; + } + echo "
"; + } + else { + echo ''.$lang_label["no_agent"].''; + } +} +else { + audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent view (Grouped)"); + require ("general/noaccess.php"); +} +?> diff --git a/pandora_console/estado_monitores.php b/pandora_console/estado_monitores.php new file mode 100644 index 0000000000..248445da73 --- /dev/null +++ b/pandora_console/estado_monitores.php @@ -0,0 +1,96 @@ +".$lang_label["monitor_listing"]." ".$lang_label["help"].""; + // Get all module from agent + $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.' and tagente_estado.estado != 100 order by tagente_modulo.nombre'; + $result_t=mysql_query($sql_t); + if (mysql_num_rows ($result_t)) { + + echo ""; + echo "
".$lang_label["type"]."".$lang_label["module_name"]."".$lang_label["description"]."".$lang_label["status"]."".$lang_label["interval"]."".$lang_label["last_contact"]; + $color=0; + while ($row_t=mysql_fetch_array($result_t)){ + # For evey module in the status table + $est_modulo = $row_t["nombre"]; + $est_tipo = dame_nombre_tipo_modulo($row_t["id_tipo_modulo"]); + $est_description = $row_t["descripcion"]; + $est_timestamp = $row_t["timestamp"]; + $est_estado = $row_t["estado"]; + $est_datos = $row_t["datos"]; + $est_cambio = $row_t["cambio"]; + $est_interval = $row_t["module_interval"]; + if (($est_interval != $intervalo) && ($est_interval > 0)) { + $temp_interval = $est_interval; + } else { + $temp_interval = $intervalo; + } + if ($est_estado <>100){ # si no es un modulo de tipo datos + # Determinamos si se ha caido el agente (tiempo de intervalo * 2 superado) + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + $ahora=date("Y/m/d H:i:s"); + $seconds = strtotime($ahora) - strtotime($row_t["timestamp"]); + if ($seconds >= ($temp_interval*2)) // If every interval x 2 secs. we get nothing, there's and alert + $agent_down = 1; + else + $agent_down = 0; + + echo "
".$est_tipo; + echo "".$est_modulo; + echo "".substr($est_description,0,32); + // echo "".$row3["datos"]; + if ($agent_down == 1) + echo ""; + else + if ($est_estado == 1) + if ($est_cambio ==1) + echo ""; + else + echo ""; + else + echo ""; + echo ""; + echo $temp_interval; + echo ""; + if ($agent_down == 1) // Si el agente esta down, lo mostramos en negrita y en rojo + echo ""; + + echo $row_t["timestamp"]; + } + } + echo '
'; + } + else + echo "".$lang_label["no_monitors"].""; +} +?> \ No newline at end of file diff --git a/pandora_console/estado_ultimopaquete.php b/pandora_console/estado_ultimopaquete.php new file mode 100644 index 0000000000..4f8ada6079 --- /dev/null +++ b/pandora_console/estado_ultimopaquete.php @@ -0,0 +1,181 @@ + + + + + +, 2003-2006 +// Raúl Mateos , 2005-2006 + +// Load global vars +require("include/config.php"); +//require("include/functions.php"); +//require("include/functions_db.php"); +if (comprueba_login() == 0) { + + if (isset($_GET["id_agente"])){ + $id_agente = $_GET["id_agente"]; + } + + // Load icon index from ttipo_modulo + $iconindex[]=""; + + $sql_tm='SELECT id_tipo, icon FROM ttipo_modulo'; + $result_tm=mysql_query($sql_tm); + while ($row_tm=mysql_fetch_array($result_tm)){ + $iconindex[$row_tm["id_tipo"]] = $row_tm["icon"]; + } + + // View last data packet + // Get timestamp of last packet + $sql_t='SELECT * FROM tagente WHERE id_agente = '.$id_agente; + $result_t=mysql_query($sql_t); + $row_t=mysql_fetch_array($result_t); + $timestamp_ref = $row_t["ultimo_contacto_remoto"]; + $timestamp_lof = $row_t["ultimo_contacto"]; + $intervalo_agente = $row_t["intervalo"]; + + // Get last packet + $sql3='SELECT * FROM tagente_modulo, tagente_estado WHERE tagente_modulo.id_agente = '.$id_agente.' AND tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo ORDER BY id_module_group, nombre'; + //$sql3='SELECT * FROM tagente_modulo WHERE id_agente = '.$id_agente.' order by id_module_group'; + $label_group=0; + $last_label = ""; + echo "

".$lang_label["last_data_chunk"]." ".$lang_label["help"]."

"; + $result3=mysql_query($sql3); + if (mysql_num_rows ($result3)) { + echo "
X".$lang_label["module_name"]; + echo "".$lang_label["type"]."".$lang_label["int"]."".$lang_label["description"]."".$lang_label["data"]."".$lang_label["graph"]."".$lang_label["raw_data"]."".$lang_label["timestamp"]; + $texto=''; + $color = 1; + while ($row3=mysql_fetch_array($result3)){ + // Calculate table line color + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + // Render module group names (fixed code) + $nombre_grupomodulo = dame_nombre_grupomodulo ($row3["id_module_group"]); + if ($nombre_grupomodulo != ""){ + if (($label_group == 0) || ($last_label != $nombre_grupomodulo)){ // Show label module group + $label_group = -1; + $last_label = $nombre_grupomodulo; + echo "
".$nombre_grupomodulo.""; + } + } + // Begin to render data ... + echo "
"; + // Render network exec module button, only when + // Agent Write for this module and group, is given + // Is a network module + // Has flag = 0 + $id_grupo = $row_t["id_grupo"]; + $id_usuario=$_SESSION["id_usuario"]; + if (give_acl($id_usuario, $id_grupo, "AW")==1){ + if ($row3["id_tipo_modulo"] > 4){ + if ($row3["flag"] == 0){ + echo ""; + } else { + echo ""; + } + } + } + $nombre_grupomodulo = dame_nombre_grupomodulo ($row3["id_module_group"]); + if ($nombre_grupomodulo != ""){ + if (($label_group == 0) || ($last_label != $nombre_grupomodulo)){ // Show label module group + $label_group = -1; + $last_label = $nombre_grupomodulo; + $texto = $texto. "".$nombre_grupomodulo.""; + } + } + + $nombre_tipo_modulo = dame_nombre_tipo_modulo($row3["id_tipo_modulo"]); + echo ""; + echo salida_limpia(substr($row3["nombre"],0,15)); + echo ""; + echo ""; + echo ""; + if ($row3["module_interval"] != 0) + echo $row3["module_interval"]; + else + echo $intervalo_agente; + //echo $nombre_tipo_modulo; + echo ""; + echo salida_limpia(substr($row3["descripcion"],0,32)); + if (strlen($row3["descripcion"]) > 32){ + echo "..."; + } + // For types not string type (3 data_string, 9 tcp_string, 14 snmp_string) + if (($row3["id_tipo_modulo"] != 3) AND ($row3["id_tipo_modulo"]!=10) AND ($row3["id_tipo_modulo"]!=17)){ + + echo ""; + echo substr($row3["datos"],0,5); + $handle = "stat".$nombre_tipo_modulo."_".$nombre_agente; + $url = 'reporting/procesos.php?agente='.$nombre_agente; + $win_handle=dechex(crc32($nombre_agente.$row3["nombre"])); + echo ""; + + echo " "; + + $link ="winopeng('reporting/stat_win.php?tipo=semana&id=".$row3["id_agente_modulo"]."&refresh=6000','sem_".$win_handle."')"; + echo ' '; + + $link ="winopeng('reporting/stat_win.php?tipo=dia&id=".$row3["id_agente_modulo"]."&refresh=800','dia_".$win_handle."')"; + echo ' '; + + $link ="winopeng('reporting/stat_win.php?tipo=hora&id=".$row3["id_agente_modulo"]."&refresh=30','hora_".$win_handle."')"; + echo ''; + } + else { # Writing string data in different way :) + echo ""; + echo salida_limpia(substr($row3["datos"],0,42)); + } + + echo ""; + echo "  "; + echo "  "; + echo ""; + echo "".$row3["timestamp"]; + + //} + } + echo '
'; +} +else echo "".$lang_label["no_modules"].""; +} +?> diff --git a/pandora_console/exportdata.php b/pandora_console/exportdata.php new file mode 100644 index 0000000000..8eb9349fc3 --- /dev/null +++ b/pandora_console/exportdata.php @@ -0,0 +1,219 @@ +".$lang_label["ag_title"].""; + echo "

".$lang_label["export_title"]." ".$lang_label["help"]."

"; + if (isset ($_POST["origen_modulo"])){ + if (isset ($_POST["csv"])) // CSV version + $csv = 1; + else + $csv = 0; + $origen = $_POST["origen"]; + if (give_acl($id_user,dame_id_grupo($origen),"AR")!=1) { + audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent Export Data"); + require ("general/noaccess.php"); + } + $origen_modulo = $_POST["origen_modulo"]; + $from_date =$_POST["from_date"]; + $to_date=$_POST["to_date"]; + echo $lang_label["db_agent_bra"]."".dame_nombre_agente($origen)."".$lang_label["from2"]."".$from_date."".$lang_label["to2"]."".$to_date."
"; + if ($csv == 0){ + echo "
"; + $separador_1 = ""; + } + echo "
".$lang_label["module"]."".$lang_label["data"]."Timestamp
"; + $separador_2 = ""; + $separador_3= ""; + } else { + $separador_1 = "
'"; + $separador_2 = "','"; + $separador_3 = "'"; + } + + for ($a=0;$a
"; + + } else echo "".$lang_label["no_sel_mod"].""; + } + } else { // Form view + ?> +

+

 

+
+ + + + + +


+ +   

"; + + echo "".$lang_label["modules"]."

"; + echo "


+ + + + + + +
+  

+
«".generate_calendar($year, $month, $days_f, 3, NULL, $locale)."»
+ "; ?> +

    

+
«".generate_calendar($year, $month, $days_t, 3, NULL, $locale)."»
+ "; ?> +
+ + + + "> + + + + \ No newline at end of file diff --git a/pandora_console/status_monitor.php b/pandora_console/status_monitor.php new file mode 100644 index 0000000000..1b3f9a3c1a --- /dev/null +++ b/pandora_console/status_monitor.php @@ -0,0 +1,174 @@ +".$lang_label["ag_title"].""; + echo "

".$lang_label["monitor_listing"]." ".$lang_label["help"]."

"; + $iduser_temp=$_SESSION['id_usuario']; + + + 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"]; + } + + if (isset($_POST["ag_group"])){ + $ag_group = $_POST["ag_group"]; + echo ""; + } else { + echo ""; + } + echo "
".$lang_label["group_name"]; + echo ""; + echo ""; + + // Module name selector + // This code thanks for an idea from Nikum, nikun_h@hotmail.com + if (isset($_POST["ag_modulename"])){ + $ag_modulename = $_POST["ag_modulename"]; + echo ""; + } else { + echo ""; + } + echo "
"; + echo $lang_label["module_name"]." "; + echo ""; + + + // Show only selected names & 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'; + + echo "
"; + echo "
"; + $color =1; + $result=mysql_query($sql); + if (mysql_num_rows($result)){ + while ($row=mysql_fetch_array($result)){ //while there are agents + if ($row["disabled"] == 0) { + if ((isset($ag_modulename)) && ($ag_modulename != "---")) + $query_gen='SELECT * FROM tagente_modulo WHERE id_agente = '.$row["id_agente"].' AND nombre = "'.entrada_limpia($_POST["ag_modulename"]).'" AND ( (id_tipo_modulo = 2) OR (id_tipo_modulo = 9) OR (id_tipo_modulo = 12) OR (id_tipo_modulo = 18) OR (id_tipo_modulo = 6))'; + else + $query_gen='SELECT * FROM tagente_modulo WHERE id_agente = '.$row["id_agente"].' AND ( (id_tipo_modulo = 2) OR (id_tipo_modulo = 9) OR (id_tipo_modulo = 12) OR (id_tipo_modulo = 18) OR (id_tipo_modulo = 6))'; + $result_gen=mysql_query($query_gen); + if (mysql_num_rows ($result_gen)) { + while ($data=mysql_fetch_array($result_gen)){ + if ($color == 1){ + $tdcolor="datos"; + $color =0; + } else { + $tdcolor="datos2"; + $color =1; + } + if (!isset($string)) {$string='';} + $string=$string.""; + $string=$string."".dame_nombre_agente($data["id_agente"]).""; + $string=$string.""; + $string=$string.""; + $string=$string."".$data["nombre"]; + $string=$string."".substr($data["descripcion"],0,30); + $string=$string."".$data["max"]."/".$data["min"]; + $string=$string.""; + if ($data["module_interval"] == 0){ + $string=$string.give_agentinterval($data["id_agente"]); + } else { + $string=$string.$data["module_interval"]; + } + $query_gen2='SELECT * FROM tagente_estado WHERE id_agente_modulo = '.$data["id_agente_modulo"]; + $result_gen2=mysql_query($query_gen2); + $data2=mysql_fetch_array($result_gen2); + $string=$string.""; + if ($data2["datos"] > 0){ + $string=$string.""; + } else { + $string=$string.""; + } + $string=$string."".$data2["timestamp"].""; + } + } + else if($ag_group>1) {unset($string);} + } + } + if (isset($string)) { + echo ""; + echo $string; //the built table of monitors + echo "
".$lang_label["agent"]."".$lang_label["type"]."".$lang_label["name"]."".$lang_label["description"]."".$lang_label["max_min"]."".$lang_label["interval"]."".$lang_label["status"]."".$lang_label["timestamp"]."
"; + echo "
"; + echo ""; + echo ""; + echo "
"; + echo " - ".$lang_label["green_light"]." "; + echo " - ".$lang_label["red_light"]."
"; + } + else { + echo "".$lang_label["no_monitors_g"].""; + } + } else { + echo "".$lang_label["no_agent"].""; + } + +} //end acl +} //end login + +?> \ No newline at end of file diff --git a/pandora_console/ver_agente.php b/pandora_console/ver_agente.php new file mode 100644 index 0000000000..5aabd9bb4e --- /dev/null +++ b/pandora_console/ver_agente.php @@ -0,0 +1,66 @@ +"; + require "estado_ultimopaquete.php"; + echo "
"; + require "estado_monitores.php"; + echo "
"; + require "estado_alertas.php"; + echo "
"; + } else { + audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to read data from agent ".dame_nombre_agente($id_agente)); + require ("general/noaccess.php"); + } + } else { + audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access (read) to agent ".dame_nombre_agente($id_agente)); + include ("general/noaccess.php"); + } + } +} +?> \ No newline at end of file