From 31004702a1b2b9b1b6135da02bdc710b81e97fcd Mon Sep 17 00:00:00 2001 From: Azabel <noreply@pandorafms.org> 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 @@ +<?php + +// Pandora - the Free monitoring system +// ==================================== +// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com +// Copyright (c) 2005-2006 Artica Soluciones Tecnologicas S.L, info@artica.es +// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +// Load global vars +require("include/config.php"); + +function datos_raw($id_agente_modulo, $periodo){ + require("include/config.php"); + require("include/languages/language_".$language_code.".php"); + + // 24 hours date + $yesterday_year = date("Y", time()-86400); + $yesterday_month = date("m", time()-86400); + $yesterday_day = date ("d", time()-86400); + $yesterday_hour = date ("H", time()-86400); + $dia = $yesterday_year."-".$yesterday_month."-".$yesterday_day." ".$yesterday_hour.":00:00"; + + + // 24x7 hours (one week) + $week_year = date("Y", time()-604800); + $week_month = date("m", time()-604800); + $week_day = date ("d", time()-604800); + $week_hour = date ("H", time()-604800); + $week = $week_year."-".$week_month."-".$week_day." ".$week_hour.":00:00"; + + // 24x7x30 Hours (one month) + $month_year = date("Y", time()-2592000); + $month_month = date("m", time()-2592000); + $month_day = date ("d", time()-2592000); + $month_hour = date ("H", time()-2592000); + $month = $month_year."-".$month_month."-".$month_day." ".$month_hour.":00:00"; + $et = " "; + switch ($periodo) { + case "mes": + $periodo = $month; + $et=$lang_label["last_month"]; + break; + case "semana": + $periodo = $week; + $et=$lang_label["last_week"]; + break; + case "dia": + $periodo = $dia; + $et=$lang_label["last_24"]; + break; + } + + // Different query for string data type + $id_tipo_modulo = dame_id_tipo_modulo_agentemodulo($id_agente_modulo); + if ( (dame_nombre_tipo_modulo($id_tipo_modulo) == "generic_data_string" ) OR + (dame_nombre_tipo_modulo($id_tipo_modulo) == "remote_tcp_string" ) OR + (dame_nombre_tipo_modulo($id_tipo_modulo) == "remote_snmp_string" )) { + $sql1="SELECT * FROM tagente_datos_string WHERE id_agente_modulo = ".$id_agente_modulo." AND timestamp > '".$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 "<h2>".$lang_label["data_received"]." '$nombre_agente' / '$nombre_modulo' </h2>"; + echo "<h3> $et <a href='help/".$help_code."/chap3.php#3322' target='_help' class='help'> <span>".$lang_label["help"]."</span></a></h3>"; + if (mysql_num_rows($result)){ + echo "<table cellpadding='3' cellspacing='3' width='600' border='0'>"; + $color=1; + echo "<th>".$lang_label["timestamp"]."</th>"; + echo "<th>".$lang_label["data"]."</th>"; + while ($row=mysql_fetch_array($result)){ + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + echo "<tr>"; + echo "<td class='".$tdcolor."f9 w130'>".$row["timestamp"]; + echo "<td class='".$tdcolor."'>".salida_limpia($row["datos"]); + } + echo "<tr><td colspan='3'><div class='raya'></div></td></tr>"; + echo "</table>"; + } + 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 "<h3 class='error'>".$lang_label["graf_error"]."</h3>"; + 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 @@ +<?php + +// Pandora - The Free Monitoring System +// This code is protected by GPL license. +// Este codigo esta protegido por la licencia GPL. +// Sancho Lerena <slerena@gmail.com>, 2003-2006 +// Raul Mateos <raulofpandora@gmail.com>, 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 "<h2>".$lang_label["ag_title"]."</h2>"; + echo "<h3>".$lang_label["db_stat_agent"]."<a href='help/".$help_code."/chap3.php#337' target='_help' class='help'> <span>".$lang_label["help"]."</span></a></h3>"; + echo "<table border=0>"; + echo "<tr><td><img src='reporting/fgraph.php?tipo=db_agente_modulo'><br>"; + echo "<tr><td><br>"; + echo "<tr><td><img src='reporting/fgraph.php?tipo=db_agente_paquetes'><br>"; + echo "</table>"; + } + 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 @@ +<?php + +// Pandora - the Free monitoring system +// ==================================== +// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com +// Copyright (c) 2005-2006 Artica Soluciones Tecnologicas S.L, info@artica.es +// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +// Load global vars +require("include/config.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 "<h2>".$lang_label["ag_title"]."</h2>"; + echo "<h3>".$lang_label["summary"]."<a href='help/".$help_code."/chap3.php#331' target='_help' class='help'> <span>".$lang_label["help"]."</span></a></h3>"; + + $iduser_temp=$_SESSION['id_usuario']; + + // Show group selector + + if (isset($_POST["ag_group"])){ + $ag_group = $_POST["ag_group"]; + echo "<form method='post' action='index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&ag_group_refresh=".$ag_group."'>"; + } else { + echo "<form method='post' action='index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60'>"; + } + + echo "<table border='0'><tr><td valign='middle'>"; + echo "<select name='ag_group' onChange='javascript:this.form.submit();'>"; + + if ( $ag_group > 1 ){ + echo "<option value='".$ag_group."'>".dame_nombre_grupo($ag_group); + } + echo "<option value=1>".dame_nombre_grupo(1); // Group all is always active + // Group 1 (ALL) gives A LOT of problems, be careful with this code: + // Run query on all groups and show data only if ACL check its ok: $iduser_temp is user, and acl is AR (agent read) + $mis_grupos[]=""; // Define array mis_grupos to put here all groups with Agent Read permission + + $sql='SELECT * FROM tgrupo'; + $result=mysql_query($sql); + while ($row=mysql_fetch_array($result)){ + if ($row["id_grupo"] != 1){ + if (give_acl($iduser_temp,$row["id_grupo"], "AR") == 1){ + echo "<option value='".$row["id_grupo"]."'>".dame_nombre_grupo($row["id_grupo"]); + $mis_grupos[]=$row["id_grupo"]; //Put in an array all the groups the user belongs + } + } + } + echo "</select>"; + echo "<td valign='middle'><noscript><input name='uptbutton' type='submit' class='sub' value='".$lang_label["show"]."'></noscript></form>"; + // 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 "<td class='f9l30'>"; + echo "<img src='images/dot_red.gif'> - ".$lang_label["fired"]; + echo " </td>"; + echo "<td class='f9'>"; + echo "<img src='images/dot_green.gif'> - ".$lang_label["not_fired"]; + echo "</td></tr></table>"; + echo "<br>"; + echo "<table cellpadding='3' cellspacing='3' width='700'>"; + echo "<th>".$lang_label["agent"]."</th>"; + echo "<th>".$lang_label["os"]."</th>"; + echo "<th>".$lang_label["interval"]."</th>"; + echo "<th>".$lang_label["group"]."</th>"; + echo "<th>".$lang_label["modules"]."</th>"; + echo "<th>".$lang_label["status"]."</th>"; + echo "<th>".$lang_label["alerts"]."</th>"; + echo "<th>".$lang_label["last_contact"]."</th>"; + // 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 "<tr>"; + echo "<td class='$tdcolor'>"; + $id_grupo=dame_id_grupo($id_agente); + if (give_acl($id_user, $id_grupo, "AW")==1){ + echo "<a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=".$id_agente."'><img src='images/setup.gif' border=0 width=15></a>"; + } + echo " <a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$id_agente."'><b>".$nombre_agente."</b></a>"; + if ( $agent_type == 0) { + // Show SO icon :) + echo "<td class='$tdcolor' align='center'><img border=0 src='images/".dame_so_icon($id_os)."' height=18 alt='".dame_so_name($id_os)."'>"; + } elseif ($agent_type == 1) { + // Show network icon (for pandora 1.2) + echo "<td class='$tdcolor' align='center'><img border=0 src='images/network.gif' height=18 alt='Network Agent'>"; + } + // If there are a module interval bigger than agent interval + if ($biginterval > $intervalo) + echo "<td class='$tdcolor'><font color='green'>".$biginterval."</font>"; + else + echo "<td class='$tdcolor'>".$intervalo; + echo '<td class="'.$tdcolor.'"><img src="images/g_'.$iconindex_g[$id_grupo].'.gif" border="0"> ( '.dame_grupo($id_grupo).' )'; + echo "<td class='$tdcolor'> ".$numero_modulos." <b>/</b> ".$numero_monitor; + if ($monitor_bad <> 0) + echo " <b>/</b> <font class='red'>".$monitor_bad."</font>"; + if ($monitor_down <> 0) + echo " <b>/</b> <font class='grey'>".$monitor_down."</font>"; + if ($numero_monitor <> 0){ + if ($estado_general <> 0){ + if ($estado_cambio == 0){ + echo "<td class='$tdcolor' align='center'><img src='images/b_red.gif'>"; + } else { + echo "<td class='$tdcolor' align='center'><img src='images/b_yellow.gif'>"; + } + } elseif ($monitor_ok > 0) + echo "<td class='$tdcolor' align='center'><img src='images/b_green.gif'>"; + elseif ($numero_datamodules > 0) + echo "<td class='$tdcolor' align='center'><img src='images/b_white.gif'>"; + elseif ($monitor_down > 0) + echo "<td class='$tdcolor' align='center'><img src='images/b_down.gif'>"; + + + } else + echo "<td class='$tdcolor' align='center'><img src='images/b_blue.gif'>"; + + // checks if an alert was fired recently + echo "<td class='$tdcolor' align='center'>"; + if (check_alert_fired($id_agente) == 1) + echo "<img src='images/dot_red.gif'>"; + else + echo "<img src='images/dot_green.gif'>"; + + echo "<td class='$tdcolor'>"; + 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 "<a href='#' class='info2'><img src='reporting/fgraph.php?tipo=progress&percent=".$percentil."&height=15&width=80' border='0'> + <span>$ultimo_contacto</span></a>"; + // echo $ultimo_contacto; + } + + } // If pertenece/belongs to group + } + echo "<tr><td colspan='8'><div class='raya'></div></td></tr>"; + echo "</table><br>"; + echo "<table>"; + echo "<tr><td class='f9i'>"; + echo "<img src='images/b_green.gif'> - ".$lang_label["green_light"]."</td>"; + echo "<td class='f9i'>"; + echo "<img src='images/b_red.gif'> - ".$lang_label["red_light"]."</td>"; + echo "<td class='f9i'>"; + echo "<img src='images/b_yellow.gif'> - ".$lang_label["yellow_light"]."</td>"; + echo "<tr><td class='f9i'>"; + echo "<img src='images/b_white.gif'> - ".$lang_label["no_light"]."</td>"; + echo "<td class='f9i'>"; + echo "<img src='images/b_blue.gif'> - ".$lang_label["blue_light"]."</td>"; + echo "<td class='f9i'>"; + echo "<img src='images/b_down.gif'> - ".$lang_label["broken_light"]."</td>"; + echo "</table>"; + } + else { + echo '<tr><td></td></tr><tr><td class="red">'.$lang_label["no_agent"].'</td></tr></table>'; + } + +} 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 @@ +<?php +// Pandora - the Free monitoring system +// ==================================== +// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com +// Copyright (c) 2005-2006 Artica Soluciones Tecnologicas S.L, info@artica.es +// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +// Load global vars +require("include/config.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($_GET["id_agente"])){ + echo "<h3>".$lang_label["alert_listing"]."<a href='help/".$help_code."/chap3.php#3324' target='_help' class='help'><span>".$lang_label["help"]."</span></a></h3>"; + $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 "<table cellpadding='3' cellspacing='3' width=750 border=0>"; + echo "<tr><th>".$lang_label["type"]."<th>".$lang_label["name"]."</th><th>".$lang_label["description"]."</th><th>".$lang_label["min_max"]."</th><th>".$lang_label["time_threshold"]."</th><th>".$lang_label["last_fired"]."</th><th>".$lang_label["times_fired"]."</th><th>".$lang_label["status"]."</th>"; + $color=1; + while ($data=mysql_fetch_array($result_gen)){ + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + echo "<tr>"; + echo "<td class='".$tdcolor."'>".dame_nombre_alerta($data["id_alerta"]); + echo "<td class='".$tdcolor."'>".$data["nombre"]; + echo "<td class='".$tdcolor."'>".$data["descripcion"]; + echo "<td class='".$tdcolor."'>".$data["dis_max"]."/".$data["dis_min"]; + echo "<td class='".$tdcolor."'>".$data["time_threshold"]; + echo "<td class='".$tdcolor."f9'>".$data["last_fired"]; + echo "<td class='".$tdcolor."'>".$data["times_fired"]; + if ($data["times_fired"] <> 0) + echo "<td class='".$tdcolor."' align='center'><img src='images/dot_red.gif'>"; + else + echo "<td class='".$tdcolor."' align='center'><img src='images/dot_green.gif'>"; + } + echo '<tr><td colspan="9"><div class="raya"></div></td></tr></table>'; + } + else echo "<font class='red'>".$lang_label["no_alerts"]."</font>"; + } + else + { + echo "<h2>".$lang_label["ag_title"]."</h2>"; + echo "<h3>".$lang_label["alert_listing"]."<a href='help/".$help_code."/chap3.php#335' target='_help' class='help'> <span>".$lang_label["help"]."</span></a></h3>"; + $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 "<form method='post' action='index.php?sec=estado&sec2=operation/agentes/estado_alertas&refr=60&ag_group_refresh=".$ag_group."'>"; + } else { + echo "<form method='post' action='index.php?sec=estado&sec2=operation/agentes/estado_alertas&refr=60'>"; + } + echo "<table border='0'><tr><td valign='middle'>"; + echo "<select name='ag_group' onChange='javascript:this.form.submit();'>"; + + if ( $ag_group > 1 ){ + echo "<option value='".$ag_group."'>".dame_nombre_grupo($ag_group); + } + echo "<option value=1>".dame_nombre_grupo(1); + + $mis_grupos[]=""; // Define array mis_grupos to put here all groups with Agent Read permission + + $sql='SELECT * FROM tgrupo'; + $result=mysql_query($sql); + while ($row=mysql_fetch_array($result)){ + if ($row["id_grupo"] != 1){ + if (give_acl($iduser_temp,$row["id_grupo"], "AR") == 1){ + echo "<option value='".$row["id_grupo"]."'>".dame_nombre_grupo($row["id_grupo"]); + $mis_grupos[]=$row["id_grupo"]; //Put in an array all the groups the user belongs + } + } + } + echo "</select>"; + echo "<td valign='middle'><noscript><input name='uptbutton' type='submit' class='sub' value='".$lang_label["show"]."'></noscript></form>"; + // 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."<tr><td class='".$tdcolor."'><a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$id_agente."'><b>".$nombre_agente."</b>"; + $string=$string."<td class='".$tdcolor."'>".dame_nombre_alerta($data["id_alerta"]); + $string=$string."<td class='".$tdcolor."'>".$data["descripcion"]; + $string=$string."<td class='".$tdcolor."'>".$data["last_fired"]; + $string=$string."<td class='".$tdcolor."'>".$data["times_fired"]; + if ($data["times_fired"] <> 0) + $string=$string."<td class='".$tdcolor."' align='center'><img src='images/dot_red.gif'>"; + else + $string=$string."<td class='".$tdcolor."' align='center'><img src='images/dot_green.gif'>"; + } + } + else if($ag_group>1) { + unset($string); + } //end result + } //end disabled=0 + + } //end while + if (isset($string)) { + echo "<td class='f9l30'>"; + echo "<img src='images/dot_red.gif'> - ".$lang_label["fired"]; + echo " </td>"; + echo "<td class='f9'>"; + echo "<img src='images/dot_green.gif'> - ".$lang_label["not_fired"]; + echo "</td></tr></table>"; + echo "<br>"; + echo "<table cellpadding='3' cellspacing='3' width='700'>"; + echo "<tr><th>".$lang_label["agent"]."</th><th>".$lang_label["type"]."</th><th>".$lang_label["description"]."</th><th>".$lang_label["last_fired"]."</th><th>".$lang_label["times_fired"]."</th><th>".$lang_label["status"]."</th>"; + echo $string; //built table of alerts + echo "<tr><td colspan='6'><div class='raya'></div></td></tr></table>"; + } + else { + echo "<tr><td></td></tr><tr><td><font class='red'>".$lang_label["no_alert"]."</font></td></tr></table>"; + } + } else echo "<tr><td></td></tr><tr><td><font class='red'>". $lang_label["no_agent"].$lang_label["no_agent_alert"]."</td></tr></table>"; + } +} //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 @@ +<?php + +// Pandora - the Free monitoring system +// ==================================== +// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com +// Copyright (c) 2005-2006 Artica Soluciones Tecnologicas S.L, info@artica.es +// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +// Load global vars +require("include/config.php"); + +if (comprueba_login() == 0) { + + if (isset($_GET["id_agente"])){ + $id_agente = $_GET["id_agente"]; + // Connect BBDD + $sql1='SELECT * FROM tagente WHERE id_agente = '.$id_agente; + $result=mysql_query($sql1); + if ($row=mysql_fetch_array($result)){ + $intervalo = $row["intervalo"]; // Interval in seconds to receive data + $nombre_agente = $row["nombre"]; + $direccion_agente =$row["direccion"]; + $ultima_act = $row["ultimo_contacto"]; + $ultima_act_remota =$row["ultimo_contacto_remoto"]; + $comentarios = $row["comentarios"]; + $id_grupo = $row["id_grupo"]; + $id_os= $row["id_os"]; + $os_version = $row["os_version"]; + $agent_version = $row["agent_version"]; + $disabled= $row["disabled"]; + $agent_type= $row["agent_type"]; + $server = $row["id_server"]; + } else + { + echo "<h3 class='error'>".$lang_label["agent_error"]."</h3>"; + echo "</table>"; + 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 "<h2>".$lang_label["ag_title"]."</h2>"; + echo "<h3>".$lang_label["view_agent_general_data"]."<a href='help/".$help_code."/chap3.php#3321' target='_help' class='help'> <span>".$lang_label["help"]."</span></a></h3>"; + echo '<table cellspacing=3 cellpadding=3 border=0 width=750>'; + echo '<tr><td class="datos"><b>'.$lang_label["agent_name"].'</b> <td class="datos">'.salida_limpia($nombre_agente); + + echo " <a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$id_agente."&refr=60'><img src='images/refresh.gif' class='top' border=0></a>"; + if (dame_admin($_SESSION['id_usuario'])==1 ) + echo " <a href='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=".$id_agente."'><img src='images/setup.gif' border=0 width=19 class='top' ></a>"; + // Data base access graph + + echo "<td rowspan=4><b>".$lang_label["agent_access_rate"]."</b><br><br> + <img border=0 src='reporting/fgraph.php?id=".$id_agente."&tipo=agentaccess&periodo=1440' border=0>"; + + echo '<tr><td class="datos2"><b>'.$lang_label["ip_address"].'</b> <td class="datos2">'.salida_limpia($direccion_agente); + if ($agent_type == 0) { + echo '<tr><td class="datos"><b>'.$lang_label["os"].'</b> <td class="datos"><img border=0 src="images/'.dame_so_icon($id_os).'"> - '.dame_so_name($id_os); + } elseif ($agent_type == 1) { + echo '<tr><td class="datos2"><b>'.$lang_label["agent_type"].'</b> <td class="datos2"><img border=0 src="images/network.gif"'; + } + if ($os_version != "") echo ' v'.salida_limpia($os_version); + echo '<tr><td class="datos2"><b>'.$lang_label["interval"].'</b> <td class="datos2">'.$intervalo; + echo '<tr><td class="datos"><b>'.salida_limpia($lang_label["description"]).'</b> <td class="datos">'.$comentarios; + + echo "<td rowspan=6><b>".$lang_label["agent_module_shareout"]."</b><br><br>"; + echo "<img border=0 src='reporting/fgraph.php?id=".$id_agente."&tipo=agentmodules' border=0>"; + + echo '<tr><td class="datos2"><b>'.salida_limpia($lang_label["group"]).'</b> <td class="datos2"> <img src="images/g_'.$iconindex_g[$row["id_grupo"]].'.gif" border="0"> ( '.dame_grupo($id_grupo).' )'; + if ($agent_type == 0) { + echo '<tr><td class="datos"><b>'.$lang_label["agentversion"].'</b> <td class="datos">'.salida_limpia($agent_version); + } + + // Total packets + echo '<tr><td class="datos2"><b>'.$lang_label["total_packets"].'</b> <td class="datos2">'; + $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 '<tr><td class="datos"><b>'.$lang_label["last_contact"]." / ".$lang_label["remote"].'</b> <td class="datosf9">'; + echo $ultima_act." / ".$ultima_act_remota; + + // Asigned/active server + echo '<tr><td class="datos2"><b>'.$lang_label["server_asigned"].'</b> <td class="datos2">'; + 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 '<tr><td class="datos"><b>'.$lang_label["next_contact"].'</b> <td class="datos">'; + + echo "<img src='reporting/fgraph.php?tipo=progress&percent=".$percentil."&height=20&width=200'>"; + echo "</td></tr></table>"; + +} + +?> \ 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 @@ +<?php + +// Pandora - the Free Distributed Monitoring System +// ================================================ +// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com +// Copyright (c) 2005-2006 Artica Soluciones Tecnologicas S.L, info@artica.es +// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +// Load global vars +require("include/config.php"); + +if (comprueba_login() == 0) + if (give_acl($id_user, 0, "AR")==1) { + echo "<h2>".$lang_label["ag_title"]."</h2>"; + echo "<h3>".$lang_label["group_view"]."<a href='help/".$help_code."/chap3.php#324' target='_help' class='help'> <span>".$lang_label["help"]."</span></a></h3>"; + $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 <slerena@gmail.com> + // 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 "<font class='red'>".$lang_label["no_agent_def"]."</font>";} + $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 "<table border=0 cellpadding=10 cellspacing=10>"; + for ($table=0;$table < $ancho;$table++){ + echo "<tr class='bot'>"; + 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="<img src='images/dot_down.gif' alt=''>"; + } + if ($grupo[$real_count]["bad"]>0) { + $icono_type=$icono_type."<img src='images/dot_red.gif' alt=''>"; + } + if ($grupo[$real_count]["ok"]>0) { + $icono_type=$icono_type."<img src='images/dot_green.gif' alt=''>"; + } + if ($grupo[$real_count]["data"]>0) { + $icono_type=$icono_type."<img src='images/dot_white.gif' alt=''>"; + } + // Show yellow light if there are recent alerts fired for this group + if ($grupo[$real_count]["alerts"] > 0 ){ + $icono_type=$icono_type."<img src='images/dot_yellow.gif' alt=''>"; + } + // TOOLTIP. + $celda = "<td class='bot' width=100><a href='index.php?sec=estado&sec2=operation/agentes/estado_agente&refr=60&group_id=".$grupo[$real_count]["id_grupo"]."' class='info'><img class='top' src='images/groups/".$icono_grupo."_1.gif' border='0' alt=''> + <span> + <table cellspacing='2' cellpadding='0' style='margin-left:20px'> + <tr><td colspan='2' width='91' class='lb'>".$lang_label["agents"].": </td></tr> + <tr><td colspan='2' class='datos' align='center'><b>".$grupo[$real_count]["agent"]."</b></td></tr></table> + <table cellspacing='2' cellpadding='0' style='margin-left:20px'> + <tr><td colspan='2' width='90' class='lb'>".ucfirst($lang_label["monitors"]).":</td></tr> + <tr><td class='datos'><img src='images/b_green.gif' align='top' alt='' border='0'> ".$lang_label["ok"].": </td><td class='datos'><font class='greenb'>".$grupo[$real_count]["ok"]."</font></td></tr> + <tr><td class='datos'><img src='images/b_down.gif' align='top' alt='' border='0'> ".$lang_label["down"].": </td><td class='datos'><font class='grey'>".$grupo[$real_count]["down"]."</font></td></tr> + <tr><td class='datos'><img src='images/b_red.gif' align='top' alt='' border='0'> ".$lang_label["fail"].": </td><td class='datos'><font class='redb'>".$grupo[$real_count]["bad"]."</font></td></tr> + <tr><td class='datos'><img src='images/b_yellow.gif' align='top' alt='' border='0'> ".$lang_label["alerts"].": </td><td class='datos'><font class='grey'>".$grupo[$real_count]["alerts"]."</font></td></tr> + </table></span></a>"; + // 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 . "<a href='index.php?sec=estado&sec2=operation/agentes/estado_grupo&update_netgroup=".$grupo[$real_count]["id_grupo"]."'><img src='images/target.gif' border=0></a>"; + } + $celda = $celda . "<br><br>".$icono_type."<br><br><font class='gr'>".$group_name."</font>"; + echo $celda; + } + $real_count++; + } + echo "</tr>"; + } + echo "</table>"; + } + else { + echo '<tr><td></td></tr><tr><td class="red">'.$lang_label["no_agent"].'</td></tr></table>'; + } +} +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 @@ +<?php +// Pandora - the Free monitoring system +// ==================================== +// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com +// Copyright (c) 2005-2006 Artica Soluciones Tecnologicas S.L, info@artica.es +// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +// Load globar vars +require("include/config.php"); +if (comprueba_login() == 0) { + + // $id_agente can be obtained as global variable or GET param. + if (isset($_GET["id_agente"])){ + $id_agente = $_GET["id_agente"]; + } + echo "<h3>".$lang_label["monitor_listing"]."<a href='help/".$help_code."/chap3.php#3323' target='_help' class='help'> <span>".$lang_label["help"]."</span></a></h3>"; + // 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 "<table width='750' cellpadding=3 cellspacing=3>"; + echo "<tr><th>".$lang_label["type"]."<th>".$lang_label["module_name"]."<th>".$lang_label["description"]."<th>".$lang_label["status"]."<th>".$lang_label["interval"]."<th>".$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 "<tr><td class='".$tdcolor."'>".$est_tipo; + echo "<td class='".$tdcolor."'>".$est_modulo; + echo "<td class='".$tdcolor."f9'>".substr($est_description,0,32); + // echo "<td class='datos'>".$row3["datos"]; + if ($agent_down == 1) + echo "<td class='".$tdcolor."' align='center'><img src='images/b_down.gif'>"; + else + if ($est_estado == 1) + if ($est_cambio ==1) + echo "<td class='".$tdcolor."' align='center'><img src='images/b_yellow.gif'>"; + else + echo "<td class='".$tdcolor."' align='center'><img src='images/b_red.gif'>"; + else + echo "<td class='".$tdcolor."' align='center'><img src='images/b_green.gif'>"; + echo "<td class='".$tdcolor."'>"; + echo $temp_interval; + echo "<td class='".$tdcolor."f9'>"; + if ($agent_down == 1) // Si el agente esta down, lo mostramos en negrita y en rojo + echo "<b><font color='red'>"; + + echo $row_t["timestamp"]; + } + } + echo '<tr><td colspan="7"><div class="raya"></div></td></tr></table>'; + } + else + echo "<font class='red'>".$lang_label["no_monitors"]."</font>"; +} +?> \ 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 @@ +<?PHP +// Pandora - the Free monitoring system +// ==================================== +// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com +// Copyright (c) 2005-2006 Artica Soluciones Tecnologicas S.L, info@artica.es +// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +?> + +<!-- Javascript --> +<script language="javascript1.2" type="text/javascript"> +<!-- +function winopeng(url,wid) { + nueva_ventana=open(url,wid,"width=580,height=250,status=no,toolbar=no,menubar=no"); + // WARNING !! Internet Explorer DOESNT SUPPORT "-" CARACTERS IN WINDOW HANDLE VARIABLE + // I WAS 20 HOURS TESTING FOR THIS BUG >:( !!! + status =wid; +} +function help_popup(help_id) { + nueva_ventana=open("general/pandora_help.php?id=1","width=300,height=100,status=no,toolbar=no,menubar=no"); +} +--> +</script> + +<?php +// Pandora - The Free Monitoring System +// This code is protected by GPL license. +// Este codigo esta protegido por la licencia GPL. +// Sancho Lerena <slerena@gmail.com>, 2003-2006 +// Raúl Mateos <raulofpandora@gmail.com>, 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 "<h3>".$lang_label["last_data_chunk"]."<a href='help/".$help_code."/chap3.php#3322' target='_help' class='help'> <span>".$lang_label["help"]."</span></a></h3>"; + $result3=mysql_query($sql3); + if (mysql_num_rows ($result3)) { + echo "<table width='750' cellpadding='3' cellspacing='3'><th>X<th>".$lang_label["module_name"]; + echo "<th>".$lang_label["type"]."<th>".$lang_label["int"]."<th>".$lang_label["description"]."<th>".$lang_label["data"]."<th>".$lang_label["graph"]."<th>".$lang_label["raw_data"]."<th>".$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 "<tr><td class='datos3' align='center' colspan=9><b>".$nombre_grupomodulo."</b>"; + } + } + // Begin to render data ... + echo "<tr><td class='$tdcolor'>"; + // 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 "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$id_agente."&id_agente_modulo=".$row3["id_agente_modulo"]."&flag=1&refr=60'><img src='images/target.gif' border=0></a>"; + } else { + echo "<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$id_agente."&id_agente_modulo=".$row3["id_agente_modulo"]."&flag=1&refr=60'><img src='images/refresh.gif' border=0></a>"; + } + } + } + $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. "<td class='$tdcolor' align='center' colspan=7><b>".$nombre_grupomodulo."</b>"; + } + } + + $nombre_tipo_modulo = dame_nombre_tipo_modulo($row3["id_tipo_modulo"]); + echo "<td class='".$tdcolor."_id'>"; + echo salida_limpia(substr($row3["nombre"],0,15)); + echo "<td class='".$tdcolor."'>"; + echo "<img src='images/".$iconindex[$row3["id_tipo_modulo"]]."' border=0>"; + echo "<td class='".$tdcolor."'>"; + if ($row3["module_interval"] != 0) + echo $row3["module_interval"]; + else + echo $intervalo_agente; + //echo $nombre_tipo_modulo; + echo "<td class='".$tdcolor."f9' title='".$row3["descripcion"]."'>"; + 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 "<td class=".$tdcolor.">"; + 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 "<td class=".$tdcolor." width='78'>"; + + echo "<a href='javascript:winopeng(\"reporting/stat_win.php?tipo=mes&id=".$row3["id_agente_modulo"]."&refresh=180000\", \"mes_".$win_handle."\")'><img border=0 src='images/grafica_m.gif'></a> "; + + $link ="winopeng('reporting/stat_win.php?tipo=semana&id=".$row3["id_agente_modulo"]."&refresh=6000','sem_".$win_handle."')"; + echo '<a href="javascript:'.$link.'"><img border=0 src="images/grafica_w.gif"></a> '; + + $link ="winopeng('reporting/stat_win.php?tipo=dia&id=".$row3["id_agente_modulo"]."&refresh=800','dia_".$win_handle."')"; + echo '<a href="javascript:'.$link.'"><img border=0 src="images/grafica_d.gif"></a> '; + + $link ="winopeng('reporting/stat_win.php?tipo=hora&id=".$row3["id_agente_modulo"]."&refresh=30','hora_".$win_handle."')"; + echo '<a href="javascript:'.$link.'"><img border=0 src="images/grafica_h.gif"</a>'; + } + else { # Writing string data in different way :) + echo "<td class='".$tdcolor."f9' colspan='2'>"; + echo salida_limpia(substr($row3["datos"],0,42)); + } + + echo "<td class=".$tdcolor." width=70>"; + echo "<a href='index.php?sec=estado&sec2=operation/agentes/datos_agente&tipo=mes&id=".$row3["id_agente_modulo"]."'><img border=0 src='images/data_m.gif'> "; + echo "<a href='index.php?sec=estado&sec2=operation/agentes/datos_agente&tipo=semana&id=".$row3["id_agente_modulo"]."'><img border=0 src='images/data_w.gif'> "; + echo "<a href='index.php?sec=estado&sec2=operation/agentes/datos_agente&tipo=dia&id=".$row3["id_agente_modulo"]."'><img border=0 src='images/data_d.gif'>"; + echo "<td class='".$tdcolor."f9'>".$row3["timestamp"]; + + //} + } + echo '<tr><td colspan="9"><div class="raya"></div></td></tr></table>'; +} +else echo "<font class='red'>".$lang_label["no_modules"]."</font>"; +} +?> 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 @@ +<?php + +// Pandora - the Free monitoring system +// ==================================== +// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com +// Copyright (c) 2005-2006 Artica Soluciones Tecnologicas S.L, info@artica.es +// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +// Load global vars +require("include/config.php"); + +if (comprueba_login() == 0) + $id_user = $_SESSION["id_usuario"]; + if ( (give_acl($id_user, 0, "AR")==1) OR (give_acl($id_user, 0, "AW")==1) ){ + if ((isset($_GET["operacion"])) AND (! isset($_POST["update_agent"]))){ + if (isset ($_POST["copiar"])){ // Export main button + echo "<h2>".$lang_label["ag_title"]."</h2>"; + echo "<h3>".$lang_label["export_title"]."<a href='help/".$help_code."/chap3.php#336' target='_help' class='help'> <span>".$lang_label["help"]."</span></a></h3>"; + 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"]."<b>".dame_nombre_agente($origen)."</b>".$lang_label["from2"]."<b>".$from_date."</b>".$lang_label["to2"]."<b>".$to_date."</b><br>"; + if ($csv == 0){ + echo "<br><table cellpadding='3' cellspacing='3' width='600'><tr><th class='datos'>".$lang_label["module"]."</th><th class=datos>".$lang_label["data"]."<th class='datos'>Timestamp</th>"; + $separador_1 = "<tr><td class='datos_id'>"; + $separador_2 = "<td class='datos'>"; + $separador_3= ""; + } else { + $separador_1 = "<br>'"; + $separador_2 = "','"; + $separador_3 = "'"; + } + + for ($a=0;$a <count($origen_modulo); $a++){ // For each module + $id_modulo = $origen_modulo[$a]; + $sql1='SELECT * FROM tdatos WHERE id_agente = '.$origen; + $tipo = dame_nombre_tipo_modulo(dame_id_tipo_modulo_agentemodulo($id_modulo)); + if ($tipo == "generic_data_string") + $sql1='SELECT * FROM tagente_datos_string WHERE timestamp > "'.$from_date.'" AND timestamp < "'.$to_date.'" AND id_agente_modulo ='.$id_modulo.' ORDER BY timestamp DESC'; + else + $sql1='SELECT * FROM tagente_datos WHERE timestamp > "'.$from_date.'" AND timestamp < "'.$to_date.'" AND id_agente_modulo ='.$id_modulo.' ORDER BY timestamp DESC'; + $result1=mysql_query($sql1); + while ($row=mysql_fetch_array($result1)){ + echo $separador_1; + echo dame_nombre_modulo_agentemodulo($id_modulo); + echo $separador_2; + echo $row["datos"]; + echo $separador_2; + echo $row["timestamp"]; + echo $separador_3; + } + } + if ($csv == 0) { + echo "<tr><td colspan='3'><div class='raya'></div></td></tr>"; + } + echo "</table>"; + + } else echo "<b class='error'>".$lang_label["no_sel_mod"]."</b>"; + } + } else { // Form view + ?> + <h2><?php echo $lang_label["ag_title"] ?></h2> + <h3><?php echo $lang_label["export_data"] ?><a href='help/<?php echo $help_code; ?>/chap3.php#336' target='_help' class='help'> <span><?php echo $lang_label["help"] ?></span></a></h3> + <form method="post" action="index.php?sec=estado&sec2=operation/agentes/exportdata&operacion=1" name="export_form"> + <table width=550 border=0 cellspacing=3 cellpadding=5 class=fon> + <tr> + <td class='datost'><b><?php echo $lang_label["source_agent"] ?> </b><br><br> + + <select name="origen" class="w130"> + <?php + if ( (isset($_POST["update_agent"])) AND (isset($_POST["origen"])) ) { + echo "<option value=".$_POST["origen"].">".dame_nombre_agente($_POST["origen"]); + } + // Show combo with agents + $sql1='SELECT * FROM tagente'; + $result=mysql_query($sql1); + while ($row=mysql_fetch_array($result)){ + if ( (isset($_POST["update_agent"])) AND (isset($_POST["origen"])) ){ + if (give_acl($id_user, $row["id_grupo"], "AR")==1) + if ( $_POST["origen"] != $row["id_agente"]) + echo "<option value=".$row["id_agente"].">".$row["nombre"]; + } + else + if (give_acl($id_user, $row["id_grupo"], "AR")==1) + echo "<option value=".$row["id_agente"].">".$row["nombre"]; + } + echo "</select> <input type=submit name='update_agent' class=sub value='".$lang_label["get_info"]."'><br><br>"; + + echo "<b>".$lang_label["modules"]."</b><br><br>"; + echo "<select name='origen_modulo[]' size=8 multiple=yes class='w130'>"; + if ( (isset($_POST["update_agent"])) AND (isset($_POST["origen"])) ) { + // Populate Module/Agent combo + $agente_modulo = $_POST["origen"]; + $sql1="SELECT * FROM tagente_modulo WHERE id_agente = ".$agente_modulo; + $result = mysql_query($sql1); + while ($row=mysql_fetch_array($result)){ + if (give_acl($id_user, $row["id_grupo"], "AR")==1) + echo "<option value=".$row["id_agente_modulo"].">".$row["nombre"]; + } + } + ?> + <td class='datos2t'><b><?php echo $lang_label["date_range"]; ?></b><br><br> + <table cellspacing=3 cellpadding=3 border=0> + <?php + $mh = "10080"; // a week, una semana + $m_year = date("Y", time()-$mh*60); + $m_month = date("m", time()-$mh*60); + $m_day = date("d", time()-$mh*60); + $m_hour = date("H", time()-$mh*60); + $m_min = date("i", time()-$mh*60); + $m = $m_year."-".$m_month."-".$m_day." ".$m_hour.":".$m_min.":"."00"; //one week ago + $ahora = date("Y-m-d H:i:s"); //Now + + require ("include/calendar.php"); //Including calendar + $result=mysql_query("SELECT token, value FROM tconfig"); + $row=mysql_fetch_array($result); + if ($row["token"]=="language_code") $locale=$row["value"]; //language of calendar. + + $time = time(); + + if (isset($_GET["month"])) $month = $_GET["month"]; + else $month = date('n', $time); + if (isset($_GET["year"])) $year = $_GET["year"]; + else $year = date('Y', $time); + + //preparate months (the next month to december is january and back) + $first_of_month = gmmktime(0,0,0,$month,1,$year); + list($month, $year) = explode(',',gmstrftime('%m,%Y',$first_of_month)); + $month_a = ($month-1); + $month_d = ($month+1); + if ($month_d==13) {$year_d = $year; $year_a = $year;} + else { + if ($month==12) $year_d = $year+1; + else $year_d = $year; + if ($month==0) $year_a = $year-1; + else $year_a = $year; + } + + if (isset($_GET["date_from"])) $date_from=$_GET["date_from"]; + else + {if (isset($_POST["from_date"])) $date_from=$_POST["from_date"]; + else $date_from=$m; + } + + if (isset($_GET["date_to"])) $date_to=$_GET["date_to"]; + else + {if (isset($_POST["to_date"])) $date_to=$_POST["to_date"]; + else $date_to=$ahora; + } + + $days_f = array(); + $days_t = array(); + $days_in_month=gmdate('t',$first_of_month); + //create links for days in every calendar: + for ($day_f=1; $day_f<=$days_in_month; $day_f++){ + $days_f[$day_f]=array('index.php?sec=estado&sec2=operation/agentes/exportdata&date_from='.$year.'-'.$month.'-'.date('d',mktime(0, 0, 0, $month, $day_f, $year)).' 00:00:00&date_to='.$date_to.'&year='.$year.'&month='.$month); + } + for ($day_t=1; $day_t<=$days_in_month; $day_t++){ + $days_t[$day_t]=array('index.php?sec=estado&sec2=operation/agentes/exportdata&date_from='.$date_from.'&date_to='.$year.'-'.$month.'-'.date('d',mktime(0, 0, 0, $month, $day_t, $year)).' 00:00:00'.'&year='.$year.'&month='.$month); + } + if (isset($date_from) && isset($date_to)) + {$date="&date_from=".$date_from."&date_to=".$date_to;} + ?> + + <tr><td class='datost'><?php echo $lang_label["from"] ?> + <input type="text" class="sub" name="from_date" value="<?php echo $date_from; ?>" size="21"><br><br> + <?php + //print calendar and links for next and previous months + echo " + <table><tr> + <td class='datost'><a href='index.php?sec=estado&sec2=operation/agentes/exportdata&month=".$month_a."&year=".$year_a.$date."'><font size =+1>«</font></a></td> + <td>".generate_calendar($year, $month, $days_f, 3, NULL, $locale)."</td><td class='datost'><a href='index.php?sec=estado&sec2=operation/agentes/exportdata&month=".$month_d."&year=".$year_d.$date."'><font size =+1>»</font></a></td> + </tr></table> + "; ?> + <tr><td class='datost'><br><?php echo $lang_label["to"] ?> <input type="text" class="sub" name="to_date" value="<?php echo $date_to; ?>" size="21"><br><br> + <?php + //print calendar and links for next and previous months + echo " + <table><tr> + <td class='datost'><a href='index.php?sec=estado&sec2=operation/agentes/exportdata&month=".$month_a."&year=".$year_a.$date."'><font size =+1>«</font></a></td> + <td>".generate_calendar($year, $month, $days_t, 3, NULL, $locale)."</td><td class='datost'><a href='index.php?sec=estado&sec2=operation/agentes/exportdata&month=".$month_d."&year=".$year_d.$date."'><font size =+1>»</font></a></td> + </tr></table> + "; ?> + <tr class=datos><td><?php echo $lang_label["csv"] ?><td><input class="chk" type="checkbox" name="csv" value=0><br> + + <tr><td></td></tr> + <tr><td colspan=2 class="datos2b" align="right"> + <input type=submit name="copiar" class=sub value="<?php echo $lang_label["export"] ?>"> + </table></td></tr> + </table> + +<?php + } + } else { + audit_db($id_user,$REMOTE_ADDR, "ACL Violation","Trying to access Agent Export Data"); + require ("general/noaccess.php"); + } +?> \ 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 @@ +<?php +// Pandora - the Free monitoring system +// ==================================== +// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com +// Copyright (c) 2005-2006 Artica Soluciones Tecnologicas S.L, info@artica.es +// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +// Load global vars +require("include/config.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)) { + + // Load icon index array 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"]; + } + + echo "<h2>".$lang_label["ag_title"]."</h2>"; + echo "<h3>".$lang_label["monitor_listing"]."<a href='help/".$help_code."/chap3.php#334' target='_help' class='help'> <span>".$lang_label["help"]."</span></a></h3>"; + $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 "<form method='post' action='index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&ag_group_refresh=".$ag_group."'>"; + } else { + echo "<form method='post' action='index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60'>"; + } + echo "<table border='0' cellspacing=3 cellpadding=3><tr><td valign='middle'>".$lang_label["group_name"]; + echo "<td valign='middle'>"; + echo "<select name='ag_group' onChange='javascript:this.form.submit();'>"; + + if ( $ag_group > 1 ){ + echo "<option value='".$ag_group."'>".dame_nombre_grupo($ag_group); + } + echo "<option value=1>".dame_nombre_grupo(1); + $mis_grupos[]=""; // Define array mis_grupos to put here all groups with Agent Read permission + $sql='SELECT * FROM tgrupo'; + $result=mysql_query($sql); + while ($row=mysql_fetch_array($result)){ + if ($row["id_grupo"] != 1){ + if (give_acl($iduser_temp,$row["id_grupo"], "AR") == 1){ + echo "<option value='".$row["id_grupo"]."'>".dame_nombre_grupo($row["id_grupo"]); + $mis_grupos[]=$row["id_grupo"]; //Put in an array all the groups the user belongs + } + } + } + echo "</select>"; + + // 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 "<form method='post' action='index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60&ag_modulename=".$ag_modulename."'>"; + } else { + echo "<form method='post' action='index.php?sec=estado&sec2=operation/agentes/status_monitor&refr=60'>"; + } + echo "<tr><td valign='middle'>"; + echo $lang_label["module_name"]."<td valign='middle'> <select name='ag_modulename' onChange='javascript:this.form.submit();'>"; + if ( isset($ag_modulename)){ + echo "<option>".$ag_modulename; + } + echo "<option>---"; + $sql='SELECT DISTINCT nombre FROM tagente_modulo WHERE (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=mysql_query($sql); + while ($row=mysql_fetch_array($result)){ + echo "<option>".$row[0]; + } + echo "</select>"; + echo "<td valign='middle'><noscript><input name='uptbutton' type='submit' class='sub' value='".$lang_label["show"]."'></noscript></form>"; + + + // 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 "</table>"; + echo "<br>"; + $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."<tr><td class='$tdcolor'><b>"; + $string=$string."<a href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$data["id_agente"]."'>".dame_nombre_agente($data["id_agente"])."</a></b>"; + $string=$string."<td class='$tdcolor'>"; + $string=$string."<img src='images/".$iconindex[$data["id_tipo_modulo"]]."' border=0>"; + $string=$string."<td class='$tdcolor'>".$data["nombre"]; + $string=$string."<td class='".$tdcolor."f9'>".substr($data["descripcion"],0,30); + $string=$string."<td class='$tdcolor' width=25>".$data["max"]."/".$data["min"]; + $string=$string."<td class='$tdcolor' width=25>"; + 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."<td class='$tdcolor' align='center' width=20>"; + if ($data2["datos"] > 0){ + $string=$string."<img src='images/b_green.gif'>"; + } else { + $string=$string."<img src='images/b_red.gif'>"; + } + $string=$string."<td class='".$tdcolor."f9' width='140'>".$data2["timestamp"]."</td></tr>"; + } + } + else if($ag_group>1) {unset($string);} + } + } + if (isset($string)) { + echo "<table cellpadding='3' cellspacing='3' width='750'><tr><th>".$lang_label["agent"]."</th><th>".$lang_label["type"]."</th><th>".$lang_label["name"]."</th><th>".$lang_label["description"]."</th><th>".$lang_label["max_min"]."</th><th>".$lang_label["interval"]."</th><th>".$lang_label["status"]."</th><th>".$lang_label["timestamp"]."</th>"; + echo $string; //the built table of monitors + echo "<tr><td colspan='8'><div class='raya'></div></td></tr></table>"; + echo "<br><table>"; + echo "<tr><td class='f9i'>"; + echo "<img src='images/b_green.gif'> - ".$lang_label["green_light"]."</td><td> </td>"; + echo "<td class='f9i'>"; + echo "<img src='images/b_red.gif'> - ".$lang_label["red_light"]."</td>"; + echo "</table>"; + } + else { + echo "<font class='red'>".$lang_label["no_monitors_g"]."</font>"; + } + } else { + echo "<font class='red'>".$lang_label["no_agent"]."</font>"; + } + +} //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 @@ +<?php + +// Pandora - the Free monitoring system +// ==================================== +// Copyright (c) 2004-2006 Sancho Lerena, slerena@gmail.com +// Copyright (c) 2005-2006 Artica Soluciones Tecnologicas S.L, info@artica.es +// Copyright (c) 2004-2006 Raul Mateos Martin, raulofpandora@gmail.com +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +// Load global vars +require("include/config.php"); + +if (comprueba_login() == 0) { + if (isset($_GET["id_agente"])){ + + $id_agente = $_GET["id_agente"]; + // get group for this id_agente + $query="SELECT * FROM tagente WHERE id_agente = ".$id_agente; + $res=mysql_query($query); + $row=mysql_fetch_array($res); + $id_grupo = $row["id_grupo"]; + $id_usuario=$_SESSION["id_usuario"]; + if (give_acl($id_usuario, $id_grupo, "AR")==1){ + // Get the user who makes this request + $id_usuario = $_SESSION["id_usuario"]; + + // Check for Network FLAG change request + if (isset($_GET["flag"])){ + if ($_GET["flag"]==1){ + if (give_acl($id_usuario, $id_grupo, "AW")==1){ + $query ="UPDATE tagente_modulo SET flag=1 WHERE id_agente_modulo = ".$_GET["id_agente_modulo"]; + $res=mysql_query($query); + } + } + } + + if (give_acl($id_usuario,$id_grupo, "AR") == 1){ + require "estado_generalagente.php"; + echo "<br>"; + require "estado_ultimopaquete.php"; + echo "<br>"; + require "estado_monitores.php"; + echo "<br>"; + require "estado_alertas.php"; + echo "<br>"; + } 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