2006-06-29 21:31:53 +02:00
< ? PHP
2007-03-12 18:58:52 +01:00
// Pandora FMS - the Free monitoring system
// ========================================
// Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com
// Main PHP/SQL code development and project architecture and management
// Copyright (c) 2004-2007 Raul Mateos Martin, raulofpandora@gmail.com
// CSS and some PHP additions
// Copyright (c) 2006-2007 Jonathan Barajas, jonathan.barajas[AT]gmail[DOT]com
// Javascript Active Console code.
// Copyright (c) 2006 Jose Navarro <contacto@indiseg.net>
// Additions to Pandora FMS 1.2 graph code and new XML reporting template management
// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es
//
2006-06-29 21:31:53 +02:00
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
2007-03-12 18:58:52 +01:00
// as published by the Free Software Foundation; version 2
2006-06-29 21:31:53 +02:00
// 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.
?>
2006-03-27 05:37:27 +02:00
<!-- Javascript -->
< script language = " javascript1.2 " type = " text/javascript " >
<!--
function winopeng ( url , wid ) {
2007-06-12 13:57:03 +02:00
nueva_ventana = open ( url , wid , " width=530,height=275,status=no,toolbar=no,menubar=no " );
2006-03-27 05:37:27 +02:00
// WARNING !! Internet Explorer DOESNT SUPPORT "-" CARACTERS IN WINDOW HANDLE VARIABLE
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
require ( " include/config.php " );
if ( comprueba_login () == 0 ) {
if ( isset ( $_GET [ " id_agente " ])){
$id_agente = $_GET [ " id_agente " ];
}
// 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
2006-07-02 23:25:53 +02:00
$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' ;
2006-03-27 05:37:27 +02:00
$label_group = 0 ;
$last_label = " " ;
2007-05-28 21:15:44 +02:00
echo " <h2> " . $lang_label [ " ag_title " ] . " > " ;
echo $lang_label [ " last_data_chunk " ] . " <a href='help/ " . $help_code . " /chap3.php#3322' target='_help' class='help'> <span> " . $lang_label [ " help " ] . " </span></a></h2> " ;
2006-03-27 05:37:27 +02:00
$result3 = mysql_query ( $sql3 );
if ( mysql_num_rows ( $result3 )) {
2007-05-18 14:56:05 +02:00
echo " <table width='750' cellpadding='3' cellspacing='3' class='databox'> " ;
echo " <th></th> " ;
2006-11-21 20:10:23 +01:00
echo " <th> " . $lang_label [ " module_name " ] . " </th> " ;
echo " <th> " . $lang_label [ " type " ] . " </th> " ;
echo " <th> " . $lang_label [ " int " ] . " </th> " ;
echo " <th> " . $lang_label [ " description " ] . " </th> " ;
echo " <th> " . $lang_label [ " data " ] . " </th> " ;
echo " <th> " . $lang_label [ " graph " ] . " </th> " ;
echo " <th> " . $lang_label [ " raw_data " ] . " </th> " ;
echo " <th> " . $lang_label [ " timestamp " ] . " </th> " ;
2007-03-28 18:07:29 +02:00
$texto = '' ; $last_modulegroup = 0 ;
2006-07-01 03:48:56 +02:00
$color = 1 ;
2006-03-27 05:37:27 +02:00
while ( $row3 = mysql_fetch_array ( $result3 )){
2006-07-01 03:48:56 +02:00
// Calculate table line color
if ( $color == 1 ){
$tdcolor = " datos " ;
$color = 0 ;
}
else {
$tdcolor = " datos2 " ;
$color = 1 ;
}
2007-03-28 18:07:29 +02:00
if ( $row3 [ " id_module_group " ] != $last_modulegroup ){
// Render module group names (fixed code)
$nombre_grupomodulo = dame_nombre_grupomodulo ( $row3 [ " id_module_group " ]);
$last_modulegroup = $row3 [ " id_module_group " ];
2007-06-17 17:05:30 +02:00
echo " <tr><td class='datos3' align='center' colspan='9'>
< b > " . $nombre_grupomodulo . " </ b ></ td ></ tr > " ;
2006-03-27 05:37:27 +02:00
}
2007-03-28 18:07:29 +02:00
2006-07-01 03:48:56 +02:00
// Begin to render data ...
echo " <tr><td class=' $tdcolor '> " ;
2006-03-27 05:37:27 +02:00
// 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 ){
2006-12-31 01:29:40 +01:00
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 &
2007-03-12 18:58:52 +01:00
tab = data &
2006-12-31 01:29:40 +01:00
refr = 60 ' >
< img src = 'images/target.gif' border = 0 ></ a > " ;
2006-03-27 05:37:27 +02:00
} else {
2006-12-31 01:29:40 +01:00
echo " <a href='index.php?sec=estado&
sec2 = operation / agentes / ver_agente &
id_agente = " . $id_agente . " &
id_agente_modulo = " . $row3["id_agente_modulo"] . " &
2007-03-12 18:58:52 +01:00
tab = data &
2006-12-31 01:29:40 +01:00
refr = 60 ' >
< img src = 'images/refresh.gif' border = 0 ></ a > " ;
2006-03-27 05:37:27 +02:00
}
}
2007-06-17 17:05:30 +02:00
}
echo " </td> " ;
2006-03-27 05:37:27 +02:00
$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 ;
2006-12-31 01:29:40 +01:00
$texto = $texto . "
2007-06-17 17:05:30 +02:00
< td class = '$tdcolor' align = 'center' colspan = '7' >
< b > " . $nombre_grupomodulo . " </ b ></ td > " ;
2006-03-27 05:37:27 +02:00
}
}
$nombre_tipo_modulo = dame_nombre_tipo_modulo ( $row3 [ " id_tipo_modulo " ]);
2007-05-08 13:24:57 +02:00
echo " <td class=' " . $tdcolor . " _id' title=' " . salida_limpia ( $row3 [ " nombre " ]) . " '> " ;
2006-03-27 05:37:27 +02:00
echo salida_limpia ( substr ( $row3 [ " nombre " ], 0 , 15 ));
2007-06-17 17:05:30 +02:00
echo " </td><td class=' " . $tdcolor . " '> " ;
2006-12-31 01:29:40 +01:00
echo " <img src='images/ " . show_icon_type ( $row3 [ " id_tipo_modulo " ]) . " ' border=0> " ;
2007-06-17 17:05:30 +02:00
echo " </td><td class=' " . $tdcolor . " '> " ;
2007-03-28 18:07:29 +02:00
if ( $row3 [ " module_interval " ] != 0 ){
2006-03-27 05:37:27 +02:00
echo $row3 [ " module_interval " ];
2007-03-28 18:07:29 +02:00
$real_interval = $row3 [ " module_interval " ];
} else {
2006-03-27 05:37:27 +02:00
echo $intervalo_agente ;
2007-03-28 18:07:29 +02:00
$real_interval = $intervalo_agente ;
}
2006-03-27 05:37:27 +02:00
//echo $nombre_tipo_modulo;
2007-06-17 17:05:30 +02:00
echo " </td><td class=' " . $tdcolor . " f9' title=' " . salida_limpia ( $row3 [ " descripcion " ]) . " '> " ;
2006-03-27 05:37:27 +02:00
echo salida_limpia ( substr ( $row3 [ " descripcion " ], 0 , 32 ));
if ( strlen ( $row3 [ " descripcion " ]) > 32 ){
echo " ... " ;
}
2007-06-17 17:05:30 +02:00
echo " </td> " ;
2006-03-27 05:37:27 +02:00
// For types not string type (3 data_string, 9 tcp_string, 14 snmp_string)
2006-12-31 01:29:40 +01:00
if (( $row3 [ " id_tipo_modulo " ] != 3 )
AND ( $row3 [ " id_tipo_modulo " ] != 10 )
2007-02-20 19:09:54 +01:00
AND ( $row3 [ " id_tipo_modulo " ] != 17 )){
2006-11-22 19:26:23 +01:00
echo " <td class= " . $tdcolor . " > " ;
2007-04-18 11:58:26 +02:00
if ( is_numeric ( $row3 [ " datos " ])) {
2007-03-12 18:58:52 +01:00
$mytempdata = fmod ( $row3 [ " datos " ], 1 );
2007-04-18 11:58:26 +02:00
if ( $mytempdata == 0 )
2006-11-22 19:26:23 +01:00
$myvalue = intval ( $row3 [ " datos " ]);
else
$myvalue = $row3 [ " datos " ];
2007-04-18 11:58:26 +02:00
echo format_for_graph ( $myvalue );
} else
2007-05-18 14:56:05 +02:00
echo substr ( salida_limpia ( $row3 [ " datos " ]), 0 , 12 );
2007-04-18 11:58:26 +02:00
2007-04-11 05:12:48 +02:00
$handle = " stat " . $nombre_tipo_modulo . " _ " . $row3 [ " id_agente_modulo " ];
$url = 'reporting/procesos.php?agente=' . $row3 [ " id_agente_modulo " ];
$win_handle = dechex ( crc32 ( $row3 [ " id_agente_modulo " ] . $row3 [ " nombre " ]));
2006-07-01 03:48:56 +02:00
echo " <td class= " . $tdcolor . " width='78'> " ;
2007-04-21 18:14:11 +02:00
$graph_label = output_clean_strict ( $row3 [ " nombre " ]);
2006-03-27 05:37:27 +02:00
2007-02-20 19:09:54 +01:00
echo " <a href='javascript:winopeng( \" reporting/stat_win.php?period=2419200&id= " . $row3 [ " id_agente_modulo " ] . " &label= " . $graph_label . " refresh=180000 \" , \" month_ " . $win_handle . " \" )'><img src='images/grafica_m.gif' border=0></a> " ;
2006-03-27 05:37:27 +02:00
2007-02-20 19:09:54 +01:00
$link = " winopeng('reporting/stat_win.php?period=604800&id= " . $row3 [ " id_agente_modulo " ] . " &label= " . $graph_label . " &refresh=6000','week_ " . $win_handle . " ') " ;
2006-11-23 13:29:02 +01:00
echo '<a href="javascript:' . $link . '"><img src="images/grafica_w.gif" border=0></a> ' ;
2006-03-27 05:37:27 +02:00
2007-02-20 19:09:54 +01:00
$link = " winopeng('reporting/stat_win.php?period=86400&id= " . $row3 [ " id_agente_modulo " ] . " &label= " . $graph_label . " &refresh=600','day_ " . $win_handle . " ') " ;
2006-11-23 13:29:02 +01:00
echo '<a href="javascript:' . $link . '"><img src="images/grafica_d.gif" border=0></a> ' ;
2006-03-27 05:37:27 +02:00
2007-02-20 19:09:54 +01:00
$link = " winopeng('reporting/stat_win.php?period=3600&id= " . $row3 [ " id_agente_modulo " ] . " &label= " . $graph_label . " &refresh=60','hour_ " . $win_handle . " ') " ;
2006-11-23 13:29:02 +01:00
echo '<a href="javascript:' . $link . '"><img src="images/grafica_h.gif" border=0></a>' ;
2006-03-27 05:37:27 +02:00
}
2007-03-12 18:58:52 +01:00
// STRING DATA
2006-03-27 05:37:27 +02:00
else { # Writing string data in different way :)
2006-11-21 20:10:23 +01:00
echo " <td class=' " . $tdcolor . " f9' colspan='2' title=' " . $row3 [ " datos " ] . " '> " ;
2006-03-27 05:37:27 +02:00
echo salida_limpia ( substr ( $row3 [ " datos " ], 0 , 42 ));
}
2006-07-01 03:48:56 +02:00
echo " <td class= " . $tdcolor . " width=70> " ;
2006-12-31 01:29:40 +01:00
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'></a> " ;
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'></a> " ;
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'></a> " ;
echo " <td class=' " . $tdcolor . " f9'> " ;
if ( $row3 [ " timestamp " ] == " 0000-00-00 00:00:00 " ){
echo $lang_label [ " never " ];
} else {
2007-03-28 18:07:29 +02:00
$ahora = time ();
if ( ( $ahora - $row3 [ " utimestamp " ]) > ( $real_interval * 2 )) {
echo " <font color='red'> " ;
2007-06-12 13:57:03 +02:00
echo human_time_comparation ( $row3 [ " timestamp " ]);
2007-03-28 18:07:29 +02:00
echo " </font> " ;
} else
2007-06-12 13:57:03 +02:00
echo human_time_comparation ( $row3 [ " timestamp " ]);
2006-12-31 01:29:40 +01:00
}
echo " </td></tr> " ;
2006-03-27 05:37:27 +02:00
//}
}
2007-05-18 14:56:05 +02:00
echo '</table>' ;
2006-03-27 05:37:27 +02:00
}
2006-12-08 17:57:43 +01:00
else {
echo " <div class='nf'> " . $lang_label [ " no_modules " ] . " </div> " ;
}
}
2006-07-09 01:32:38 +02:00
?>