From 145ca40616d99ebaf6f5596606c5ec4bfba0eb52 Mon Sep 17 00:00:00 2001 From: slerena <slerena@gmail.com> Date: Thu, 19 Apr 2007 18:50:07 +0000 Subject: [PATCH] 2007-04-19 Sancho Lerena <slerena@artica.es> * pandora.css: added some classes for graphical input buttons. * languages/language_en.php: More strings to go ! * include/config.php: Deleted from repo, now has no sense. * pandoradb.sql: Added `alert_text` to talerta_agent for new text alerts. Added tables for custom graphs and reporting: tgraph, tgraph_source, treport, and treport_content. * operation/users/user.php: Fixed problem with last Raul's commit. * godmode/usuarios/lista_usuarios.php: Fixed problem with last Raul's commit. * operation/agentes/estado_alertas.php: Code cleanup. Implemented render for text alerts. * operation/agentes/datos_agente.php: Fixed small bug with text output. * operation/agentes/datos_agente_calendar.php: Added contribution from Leandro Doctors. Need to work on it before use several problems detected. * operation/servers/view_server.php: Fixed some bugs. * operation/reporting/graph_viewer.php: Added viewer for custom graphs. * operation/reporting/custom_reporting.php: Initial code, not finished yet. * operation/reporting/graph_builder.php: Work for modules in the same agent, several problems, but works. * operation/menu.php: Updated options for new reporting menu. * reporting/stat_win.php: New menu is great :-) * general/login_page.php: Updated login page. * godmode/agentes/alert_manager.php, configurar_agente.php: New code for text alerts and better user help. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@433 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 45 ++ pandora_console/general/login_page.php | 2 +- .../godmode/agentes/alert_manager.php | 80 ++-- .../godmode/agentes/configurar_agente.php | 34 +- .../godmode/usuarios/lista_usuarios.php | 14 +- pandora_console/include/config.php | 108 ----- .../include/languages/language_en.php | 12 + pandora_console/include/styles/pandora.css | 21 +- .../operation/agentes/datos_agente.php | 2 +- .../agentes/datos_agente_calendar.php | 270 ++++++++++++ .../operation/agentes/estado_alertas.php | 395 ++++++++++-------- pandora_console/operation/menu.php | 19 +- .../operation/reporting/custom_reporting.php | 149 +++++++ .../operation/reporting/graph_builder.php | 265 ++++++++---- .../operation/reporting/graph_viewer.php | 153 +++++++ .../operation/servers/view_server.php | 5 +- pandora_console/operation/users/user.php | 2 +- pandora_console/pandoradb.sql | 45 +- pandora_console/reporting/stat_win.php | 5 +- 19 files changed, 1210 insertions(+), 416 deletions(-) delete mode 100644 pandora_console/include/config.php create mode 100644 pandora_console/operation/agentes/datos_agente_calendar.php create mode 100644 pandora_console/operation/reporting/custom_reporting.php create mode 100644 pandora_console/operation/reporting/graph_viewer.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index dd5b732fd1..2cee6011d2 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,48 @@ +2007-04-19 Sancho Lerena <slerena@artica.es> + + * pandora.css: added some classes for graphical input buttons. + + * languages/language_en.php: More strings to go ! + + * include/config.php: Deleted from repo, now has no sense. + + * pandoradb.sql: Added `alert_text` to talerta_agent for new text + alerts. Added tables for custom graphs and reporting: tgraph, + tgraph_source, treport, and treport_content. + + * operation/users/user.php: Fixed problem with last Raul's commit. + + * godmode/usuarios/lista_usuarios.php: Fixed problem with last + Raul's commit. + + * operation/agentes/estado_alertas.php: Code cleanup. Implemented + render for text alerts. + + * operation/agentes/datos_agente.php: Fixed small bug with text output. + + * operation/agentes/datos_agente_calendar.php: Added contribution + from Leandro Doctors. Need to work on it before use several + problems detected. + + * operation/servers/view_server.php: Fixed some bugs. + + * operation/reporting/graph_viewer.php: Added viewer for custom graphs. + + * operation/reporting/custom_reporting.php: Initial code, not + finished yet. + + * operation/reporting/graph_builder.php: Work for modules in the + same agent, several problems, but works. + + * operation/menu.php: Updated options for new reporting menu. + + * reporting/stat_win.php: New menu is great :-) + + * general/login_page.php: Updated login page. + + * godmode/agentes/alert_manager.php, configurar_agente.php: New + code for text alerts and better user help. + 2007-04-18 Raul Mateos <raulofpandora@gmail.com> * pandoradb_data.sql, pandoradb.sql: Fixed small warnings. diff --git a/pandora_console/general/login_page.php b/pandora_console/general/login_page.php index da50dc9205..2bd0b71f9a 100644 --- a/pandora_console/general/login_page.php +++ b/pandora_console/general/login_page.php @@ -28,7 +28,7 @@ <input class="login" type="text" name="nick" value=""> <div class="f9b">Password</div> <input class="login" type="password" name="pass" value=""> - <div><input type="submit" class="sub" value="Login"></div> + <div><input type="submit" class="sub next" value="Login"></div> </form> </div> <div id="logo_box"> diff --git a/pandora_console/godmode/agentes/alert_manager.php b/pandora_console/godmode/agentes/alert_manager.php index d605798d9e..02ac7ee4b8 100644 --- a/pandora_console/godmode/agentes/alert_manager.php +++ b/pandora_console/godmode/agentes/alert_manager.php @@ -43,10 +43,10 @@ $result=mysql_query($sql1); $row2=mysql_fetch_array($result2); //module type modulo is $row2["nombre"]; - $sql3='SELECT id_aam, id_alerta, time_threshold, dis_min, dis_max, - descripcion - FROM talerta_agente_modulo - WHERE id_agente_modulo = '.$row["id_agente_modulo"]; // From all the alerts give me which are from my agent + $sql3='SELECT * + FROM talerta_agente_modulo + WHERE id_agente_modulo = '.$row["id_agente_modulo"]; + // From all the alerts give me which are from my agent $result3=mysql_query($sql3); while ($row3=mysql_fetch_array($result3)){ if ($color == 1){ @@ -79,8 +79,11 @@ $result=mysql_query($sql1); else $mymax = $row3["dis_max"]; $mymax = format_for_graph($mymax ); - - $string = $string."<td class='$tdcolor'>".$mymin." / ".$mymax; + // We have alert text ? + if ($row3["alert_text"] != "") + $string = $string."<td class='$tdcolor'>".$lang_label["text"]; + else + $string = $string."<td class='$tdcolor'>".$mymin." / ".$mymax; $string = $string."<td class='$tdcolor'>".salida_limpia($row3["descripcion"]); $string = $string."<td class='$tdcolor'>"; $id_grupo = dame_id_grupo($id_agente); @@ -133,8 +136,8 @@ if ($update_alert != 1) { } ?> <input type="hidden" name="id_agente" value="<?php echo $id_agente ?>"> -<table width=650 cellpadding="3" cellspacing="3" class="fon" border=0> -<tr><td class='lb' rowspan='9' width='5'> +<table width=600 cellpadding="4" cellspacing="4" class="fon" border=0> +<tr><td class='lb' rowspan='10' width='3'> <td class="datos"><?php echo $lang_label["alert_type"]?> <td class="datos"> <select name="tipo_alerta"> @@ -155,16 +158,39 @@ while ($row=mysql_fetch_array($result)){ <td class="datos2"><input type="text" name="minimo" size="5" value="<?php echo $alerta_dis_min ?>" style="margin-right: 70px;"> <?php echo $lang_label["max_value"] ?> <input type="text" name="maximo" size="5" value="<?php echo $alerta_dis_max ?>"> -<tr><td class="datos"><?php echo $lang_label["description"] ?> -<td class="datos"><input type="text" name="descripcion" size="39" value ="<?php echo $alerta_descripcion ?>"> -<tr><td class="datos2"><?php echo $lang_label["field1"] ?> -<td class="datos2"><input type="text" name="campo_1" size="39" value="<?php echo $alerta_campo1 ?>"> -<tr><td class="datos"><?php echo $lang_label["field2"] ?> -<td class="datos"><input type="text" name="campo_2" size="39" value="<?php echo $alerta_campo2 ?>"> -<tr><td class="datos2"><?php echo $lang_label["field3"] ?> -<td class="datos2"><textarea name="campo_3" cols="36" rows="3"><?php echo $alerta_campo3 ?></textarea> -<tr><td class="datos"><?php echo $lang_label["time_threshold"] ?> -<td class="datos"> + +<!-- FREE TEXT ALERT --> +<tr><td class="datos"><?php echo $lang_label["alert_text"] ?> <a href='#' class='tip'> <span> +Regular Expression Supported +</span></a> +<td class="datos"><input type="text" name="alert_text" size="39" value ="<?php echo $alert_text ?>"> + +<tr><td class="datos2"><?php echo $lang_label["description"] ?> +<td class="datos2"><input type="text" name="descripcion" size="39" value ="<?php echo $alerta_descripcion ?>"> + +<tr><td class="datos"><?php echo $lang_label["field1"] ?> <a href='#' class='tip'> <span> +<b>Macros:</b><br> +_agent_<br> +_timestamp_<br> +_data_<br> +</span></a> +<td class="datos"><input type="text" name="campo_1" size="39" value="<?php echo $alerta_campo1 ?>"> +<tr><td class="datos2"><?php echo $lang_label["field2"] ?> <a href='#' class='tip'> <span> +<b>Macros:</b><br> +_agent_<br> +_timestamp_<br> +_data_<br> +</span></a> +<td class="datos2"><input type="text" name="campo_2" size="39" value="<?php echo $alerta_campo2 ?>"> +<tr><td class="datos"><?php echo $lang_label["field3"] ?> <a href='#' class='tip'> <span> +<b>Macros:</b><br> +_agent_<br> +_timestamp_<br> +_data_<br> +</span></a> +<td class="datos"><textarea name="campo_3" style='height:55px;' cols="36" rows="2"><?php echo $alerta_campo3 ?></textarea> +<tr><td class="datos2"><?php echo $lang_label["time_threshold"] ?> +<td class="datos2"> <select name="time_threshold" style="margin-right: 60px;"> <?php if ($alerta_time_threshold != ""){ @@ -188,17 +214,19 @@ while ($row=mysql_fetch_array($result)){ <input type="text" name="other" size="5"> -<tr><td class="datos2"><?php echo $lang_label["min_alerts"] ?> -<td class="datos2"> +<tr><td class="datos"><?php echo $lang_label["min_alerts"] ?> +<td class="datos"> <input type="text" name="min_alerts" size="5" value="<?php if (isset($alerta_min_alerts)) {echo$alerta_min_alerts;} ?>" style="margin-right: 10px;"> <?php echo $lang_label["max_alerts"] ?> <input type="text" name="max_alerts" size="5" value="<?php if (isset($alerta_max_alerts)) {echo $alerta_max_alerts;} ?>"> -<tr><td class="datos"><?php echo $lang_label["assigned_module"] ?> -<td class="datos"> -<?php if ($update_alert != 1) { +<tr><td class="datos2"><?php echo $lang_label["assigned_module"] ?> +<td class="datos2"> +<?php + +if ($update_alert != 1) { echo '<select name="agente_modulo"> '; $sql2='SELECT id_agente_modulo, id_tipo_modulo, nombre FROM tagente_modulo WHERE id_agente = '.$id_agente; $result2=mysql_query($sql2); @@ -222,12 +250,10 @@ while ($row=mysql_fetch_array($result)){ echo '<tr><td colspan="3"><div class="raya"></div></td></tr>'; echo '<tr><td colspan="3" align="right">'; if ($update_alert== "1"){ - echo '<input name="updbutton" type="submit" class="sub" value="'.$lang_label["update"].'">'; + echo '<input name="updbutton" type="submit" class="sub upd" value="'.$lang_label["update"].'">'; } else { - echo '<input name="crtbutton" type="submit" class="sub" value="'.$lang_label["add"].'">'; + echo '<input name="crtbutton" type="submit" class="sub wand" value="'.$lang_label["add"].'">'; } echo '</form>'; - - echo "<form method='post' action='index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=".$id_agente."'><input type='submit' class='sub' name='crt' value='".$lang_label["cancel"]."'></form>"; echo '</td></tr></table>'; diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 5d1824e133..1a3fc4a56a 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -81,6 +81,7 @@ $snmp_community=""; $combo_snmp_oid=""; $agent_created_ok = 0; $create_agent = 0; +$alert_text = ""; // ================================ // Create AGENT @@ -200,6 +201,7 @@ if (isset($_POST["insert_alert"])){ // if created alert $maximo = entrada_limpia($_POST["maximo"]); $minimo = entrada_limpia($_POST["minimo"]); $tipo_alerta = entrada_limpia($_POST["tipo_alerta"]); + $alert_text = entrada_limpia($_POST["alert_text"]); $time_threshold = entrada_limpia($_POST["time_threshold"]); $max_alerts = entrada_limpia($_POST["max_alerts"]); $min_alerts = entrada_limpia($_POST["min_alerts"]); @@ -207,7 +209,21 @@ if (isset($_POST["insert_alert"])){ // if created alert if ($time_threshold == -1) { $time_threshold = $other; } - $sql_insert="INSERT INTO talerta_agente_modulo (id_agente_modulo,id_alerta,al_campo1,al_campo2,al_campo3,descripcion,dis_max,dis_min,time_threshold,max_alerts, min_alerts) VALUES ('".$id_agente_modulo."','".$tipo_alerta."','".$campo_1."','".$campo_2."','".$campo_3."','".$descripcion."','".$maximo."','".$minimo."','".$time_threshold."','".$max_alerts."','".$min_alerts."')"; + $sql_insert="INSERT INTO talerta_agente_modulo + (id_agente_modulo,id_alerta,al_campo1,al_campo2,al_campo3,descripcion,dis_max,dis_min,time_threshold,max_alerts, min_alerts, alert_text) VALUES + ('$id_agente_modulo', + '$tipo_alerta', + '$campo_1', + '$campo_2', + '$campo_3', + '$descripcion', + '$maximo', + '$minimo', + '$time_threshold', + '$max_alerts', + '$min_alerts', + '$alert_text')"; + $result=mysql_query($sql_insert); if (! $result) echo "<h3 class='error'>".$lang_label["create_alert_no"]."</h3>"; @@ -234,11 +250,24 @@ if (isset($_POST["update_alert"])){ // Update an existing alert $max_alerts = entrada_limpia($_POST["max_alerts"]); $min_alerts = entrada_limpia($_POST["min_alerts"]); $other = entrada_limpia($_POST["other"]); + $alert_text = entrada_limpia($_POST["alert_text"]); if ($time_threshold == -1) { $time_threshold = $other; } - $sql_insert="UPDATE talerta_agente_modulo SET id_alerta = ".$tipo_alerta.", max_alerts = '".$max_alerts."', min_alerts = '".$min_alerts."' ,time_threshold = '".$time_threshold."' ,dis_min = '".$minimo."' ,dis_max = '".$maximo."' ,al_campo3 = '".$campo_3."' ,al_campo2 = '".$campo_2."' ,al_campo1 = '".$campo_1."' , descripcion = '".$descripcion."' WHERE id_aam = ".$id_aam; + $sql_insert="UPDATE talerta_agente_modulo SET + id_alerta = $tipo_alerta, + max_alerts = '$max_alerts', + min_alerts = '$min_alerts' , + time_threshold = '$time_threshold', + dis_min = '$minimo' , + dis_max = '$maximo' , + al_campo3 = '$campo_3' , + al_campo2 = '$campo_2' , + al_campo1 = '$campo_1' , + descripcion = '$descripcion', + alert_text = '$alert_text' + WHERE id_aam = ".$id_aam; $result=mysql_query($sql_insert); if (! $result) { echo "<h3 class='error'>".$lang_label["update_alert_no"]."</h3>"; @@ -379,6 +408,7 @@ if (isset($_GET["update_alert"])){ $alerta_dis_max = $row["dis_max"]; $alerta_dis_min = $row["dis_min"]; $tipo_alerta = $row["id_alerta"]; + $alert_text = $row["alert_text"]; $alerta_max_alerts = $row["max_alerts"]; $alerta_min_alerts = $row["min_alerts"]; $alerta_time_threshold = $row["time_threshold"]; diff --git a/pandora_console/godmode/usuarios/lista_usuarios.php b/pandora_console/godmode/usuarios/lista_usuarios.php index 633f43a492..6534470fa2 100644 --- a/pandora_console/godmode/usuarios/lista_usuarios.php +++ b/pandora_console/godmode/usuarios/lista_usuarios.php @@ -48,11 +48,11 @@ $fecha_registro = ""; $color=1; while ($rowdup=mysql_fetch_array($resq1)){ - $name=$rowdup["id_usuario"]; - $nivel=$rowdup["nivel"]; - $real_name=$rowdup["nombre_real"]; - $comments=$rowdup["comentarios"]; - $fecha_registro =$rowdup["fecha_registro"]; + $name = $rowdup["id_usuario"]; + $nivel = $rowdup["nivel"]; + $real_name = $rowdup["nombre_real"]; + $comments = $rowdup["comentarios"]; + $fecha_registro = $rowdup["fecha_registro"]; if ($color == 1){ $tdcolor = "datos"; $color = 0; @@ -62,7 +62,7 @@ while ($rowdup=mysql_fetch_array($resq1)){ $color = 1; } echo "<tr><td class='$tdcolor'>"; - echo "<a href='index.php?sec=gusuarios&sec2=godmode/usuarios/configurar_usuarios&id_usuario_mio=".$nombre."'><b>".$name."</b></a>"; + echo "<a href='index.php?sec=gusuarios&sec2=godmode/usuarios/configurar_usuarios&id_usuario_mio=".$name."'><b>".$name."</b></a>"; echo "<td class='$tdcolor'>".$fecha_registro; echo "<td class='$tdcolor'>"; if ($nivel == 1) @@ -84,7 +84,7 @@ while ($rowdup=mysql_fetch_array($resq1)){ echo "<td class='$tdcolor' width='100'>".substr($real_name,0,16)."</td>"; echo "<td class='$tdcolor'>".$comments."</td>"; - echo "<td class='$tdcolor' align='center'><a href='index.php?sec=gagente&sec2=godmode/usuarios/lista_usuarios&borrar_usuario=".$nombre."' onClick='if (!confirm(\' ".$lang_label["are_you_sure"]."\')) return false;'><img border='0' src='images/cross.png'></a>"; + echo "<td class='$tdcolor' align='center'><a href='index.php?sec=gagente&sec2=godmode/usuarios/lista_usuarios&borrar_usuario=".$name."' onClick='if (!confirm(\' ".$lang_label["are_you_sure"]."\')) return false;'><img border='0' src='images/cross.png'></a>"; } echo "<tr><td colspan='6'><div class='raya'></div></td></tr>"; echo "<tr><td colspan='6' align='right'>"; diff --git a/pandora_console/include/config.php b/pandora_console/include/config.php deleted file mode 100644 index d4f634377e..0000000000 --- a/pandora_console/include/config.php +++ /dev/null @@ -1,108 +0,0 @@ -<?PHP -// Begin of automatic config file -$dbname="pandora"; // MySQL DataBase name -$dbuser="pandora"; -$dbpassword="pandora"; -$dbhost="localhost"; // DB Host -$config_homedir="/var/www/pandora_console/"; // Config homedir -$BASE_URL="http://localhost/pandora_console"; // Base URL -// End of automatic config file -?><?php -// Pandora FMS - the Free monitoring system -// ======================================== -// Copyright (c) 2004-2007 Sancho Lerena, slerena@openideas.info -// Copyright (c) 2005-2007 Artica Soluciones Tecnologicas -// Copyright (c) 2004-2007 Raul Mateos Martin, raulofpandora@gmail.com -// Copyright (c) 2006-2007 Jose Navarro jose@jnavarro.net -// Copyright (c) 2006-2007 Jonathan Barajas, jonathan.barajas[AT]gmail[DOT]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 version 2 -// 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. -// This is the base config file - -//Pandora Version -$build_version="PC070224"; //PCyymmdd -$pandora_version="v1.3 devel"; - -// Database configuration (default ones) -//$dbname="pandora"; // MySQL DataBase -//$dbuser="pandora"; // DB User -//$dbpassword="pandora"; // Password -//$dbhost="localhost"; // MySQL Host - -// This is used for reporting, please add "/" character at the end -//$config_homedir = "/var/www/babel_console/"; - -// Do not display any ERROR -//error_reporting(0); - -// Display ALL errors -error_reporting(E_ALL); - -//This is directory where placed "attachment" directory, to upload files stores. -// This MUST be writtable by http server user, and should be in pandora root. -// Please append "/" to the end. -$attachment_store=$config_homedir; - -// Default font used for graphics (a Free TrueType font included with Pandora FMS) -$config_fontpath = $config_homedir."reporting/FreeSans.ttf"; - -// Read remaining config tokens from DB -if (! mysql_connect($dbhost,$dbuser,$dbpassword)){ - -//Non-persistent connection. If you want persistent conn change it to mysql_pconnect() - exit ('<html><head><title>Pandora Error</title> - <link rel="stylesheet" href="./include/styles/pandora.css" type="text/css"> - </head><body><div align="center"> - <div id="db_f"> - <div> - <a href="index.php"><img src="images/logo_menu.gif" border="0"></a> - </div> - <div id="db_ftxt"> - <h1 id="db_fh1" class="error">Pandora Console Error DB-001</h1> - Cannot connect with Database, please check your database setup in the - <b>./include/config.php</b> file and read documentation.<i><br><br> - Probably any of your user/database/hostname values are incorrect or - database is not running.</i><br><br><font class="error"> - <b>MySQL ERROR:</b> '. mysql_error().'</font> - <br> - </div> - </div></body></html>'); -} -mysql_select_db($dbname); -$result2=mysql_query("SELECT * FROM tconfig"); -while ($row2=mysql_fetch_array($result2)){ - switch ($row2["token"]) { - case "language_code": $language_code=$row2["value"]; - break; - case "block_size": $block_size=$row2["value"]; - break; - case "days_purge": $days_purge=$row2["value"]; - break; - case "days_compact": $days_compact=$row2["value"]; - break; - case "graph_res": $config_graph_res=$row2["value"]; - break; - case "step_compact": $config_step_compact=$row2["value"]; - break; - case "truetype": $config_truetype=$row2["value"]; - break; - case "graph_order": $config_graph_order=$row2["value"]; - break; - case "bgimage": $config_bgimage=$row2["value"]; - break; - } -} -if ($language_code == 'ast_es') { - $help_code='ast'; - } -else $help_code = substr($language_code,0,2); -?> diff --git a/pandora_console/include/languages/language_en.php b/pandora_console/include/languages/language_en.php index 59d31a5ad2..18e834c2df 100644 --- a/pandora_console/include/languages/language_en.php +++ b/pandora_console/include/languages/language_en.php @@ -753,6 +753,18 @@ $lang_label["says"]="says"; $lang_label["delete_sel"]="Delete selected"; $lang_label["available_templates"]="Available templates"; $lang_label["assign"]="Assign"; + +$lang_label["graph_store"]="Custom graph store"; +$lang_label["private"]="Private"; +$lang_label["store"]="Store"; +$lang_label["store_graph_suc"]="Graph store successful"; +$lang_label["store_graph_error"]="Graph store error"; +$lang_label["custom_graph_viewer"]="Custom graph viewer"; +$lang_label["graph_name"]="Graph name"; +$lang_label["custom_graphs"]="Custom graphs"; +$lang_label["custom_reporting"]="Custom reporting"; +$lang_label["alert_text"]="Alert text"; +$lang_label["text"]="Text"; global $lang_label; global $help_label; ?> \ No newline at end of file diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 98d63e041a..9cf1fa13c6 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -211,13 +211,26 @@ input.sub { font-size: 11px; } input.next { - padding-right: 15px; - background: #e5e5e5 url(../../images/go.png) no-repeat right 2px; + padding-right: 21px; + background: #e5e5e5 url(../../images/go.png) no-repeat right 4px; } + input.upd { - padding-right: 15px; - background: #e5e5e5 url(../../images/upd.png) no-repeat right 2px; + padding-right: 21px; + background: #e5e5e5 url(../../images/upd.png) no-repeat right 5px; } + +input.wand { + padding-right: 21px; + background: #e5e5e5 url(../../images/wand.png) no-repeat right 4px; +} + +input.delete { + padding-right: 21px; + background: #e5e5e5 url(../../images/cross.png) no-repeat right 4px; +} + + table, img { border: 0px; } diff --git a/pandora_console/operation/agentes/datos_agente.php b/pandora_console/operation/agentes/datos_agente.php index f28066adea..6e110412d2 100644 --- a/pandora_console/operation/agentes/datos_agente.php +++ b/pandora_console/operation/agentes/datos_agente.php @@ -87,7 +87,7 @@ function datos_raw($id_agente_modulo, $periodo){ $myvalue = $row["datos"]; echo format_for_graph($myvalue ); } else - echo substr($row["datos"],0,12); + echo salida_limpia($row["datos"]); } echo "<tr><td colspan='3'><div class='raya'></div></td></tr>"; echo "</table>"; diff --git a/pandora_console/operation/agentes/datos_agente_calendar.php b/pandora_console/operation/agentes/datos_agente_calendar.php new file mode 100644 index 0000000000..97ac07b75f --- /dev/null +++ b/pandora_console/operation/agentes/datos_agente_calendar.php @@ -0,0 +1,270 @@ +<?php + +// Pandora - the Free monitoring system +// ==================================== +// +// report_matrix.php +// +// This file is Copyright (c) 2007 Leandro Doctors, ldoctors@gusila.org.ar. +// +// This file contains code from exportdata.php, which is +// 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. + + +/********** Some necesary functions ********************/ + +function dame_promedio_de_un_modulo_de_un_agente_para_una_hora_det_de_un_dia_de_la_semana ($id_de_mi_agente, $mod_de_mi_agente, $hora_det, $dia_de_la_semana) +// Genera el contenido de c/u de las celdas de datos de la matriz de promedios. Válida sólo para módulos no-string + { + require ("include/config.php"); + $query1="SELECT AVG(datos) + FROM tagente_datos + WHERE id_agente=".$id_de_mi_agente." + AND HOUR(timestamp)=".$hora_det." + AND WEEKDAY(timpestamp)=".$dia_de_la_semana." + AND 'timestamp' >=".$fecha_inicio." + AND 'timestamp' <=".$fecha_fin; + $resq1=mysql_query($query1); + return($resq1); + } + +function generar_tabla_de_promedios_de_datos_no_string ($id_de_mi_agente, $id_de_mi_mod,$fecha_inicio,$fecha_fin) +// Genera una tabla con los promedios de los datos de un módulo no-string +{ + $dias_de_la_semana=array ("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado"); + $nombre_modulo=dame_nombre_modulo_agentemodulo($id_de_mi_mod); + echo "<br>Módulo: ".$nombre_modulo."<br>"; + + // Encabezado de la tabla + echo "<TABLE BORDER=1> + <TBODY> + <TR> + <TH ROWSPAN=\"2\">Hora</TH> + <TH COLSPAN=\"7\">Día</TH> + </TR> + <TR>"; + for ($dia=0;$dia<7;++$dia) + echo " + <TH>".$dias_de_la_semana[$dia]."</TH>"; + echo + "</TR>"; + + for ($hora=0;$hora<24;++$hora) + { + echo" + <TR> + <TH>".$hora." h.</TH>"; + for ($dia=1;$dia<8;++$dia) + echo "<TD>".dame_promedio_de_un_modulo_no_string_de_un_agente_para_una_hora_det_de_un_dia_de_la_semana_en_un_rango_de_fechas_det($id_de_mi_agente, $id_de_mi_mod, $hora, $dia, $fecha_inicio, $fecha_fin)."</TD>"; + echo + "</TR>"; + } + echo "</TBODY></TABLE>"; +} + + +/************** Main program *******************************/ + + +// Load global vars +require("include/config.php"); + +if (comprueba_login() != 0) { + echo "NO PERM"; + exit; +} + +$id_user = $_SESSION["id_usuario"]; +if ( (give_acl($id_user, 0, "AR")==0) AND (give_acl($id_user, 0, "AW")==0) ){ + echo "NO PERM"; + exit; +} + +if ((isset($_GET["operacion"])) AND (! isset($_POST["update_agent"]))){ + if (isset ($_POST["copiar"])){ + // Option A: Print exported data + // 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"])){ + $origen = $_POST["origen"]; + + /* Comentado sólo para propósitos de prueba (Si no, no anda) + 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"]; + + // Imprime encabezado + 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>"; + + // Esto podría reutilizarse + 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>"; + + + // For each module + for ($a=0;$a <count($origen_modulo); $a++){ + $id_modulo = $origen_modulo[$a]; + $tipo = dame_nombre_tipo_modulo(dame_id_tipo_modulo_agentemodulo($id_modulo)); + + if ($tipo != "generic_data_string") + echo "<br>". generar_tabla_de_promedios_de_datos_no_string ($origen,$id_modulo,$from_date,$to_date); + } + } + } // End Option A +} else { +// Option B: Print Form +// 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 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;} +echo "<tr><td class='datost'>".$lang_label["from"]." <input type=\"text\" class=\"sub\" name=\"from_date\" value=\"".$date_from." size=\"21\"><br><br>"; + + //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>".$lang_label["to"]." <input type=\"text\" class=\"sub\" name=\"to_date\" value=\"".$date_to."\" size=\"21\"><br><br>"; + + //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><td></td></tr> + <tr><td colspan=2 class=\"datos2b\" align=\"right\"> + <input type=submit name=\"copiar\" class=sub value=".$lang_label["export"]."> + </table></td></tr> + </table>"; +} + + +?> + + diff --git a/pandora_console/operation/agentes/estado_alertas.php b/pandora_console/operation/agentes/estado_alertas.php index 0241b5393a..95a9036842 100644 --- a/pandora_console/operation/agentes/estado_alertas.php +++ b/pandora_console/operation/agentes/estado_alertas.php @@ -18,196 +18,221 @@ // 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"]; - - $mytempdata = fmod($data["dis_min"], 1); - if ($mytempdata == 0) - $mymin = intval($data["dis_min"]); - else - $mymin = $data["dis_min"]; - $mymin = format_for_graph($mymin ); - $mytempdata = fmod($data["dis_max"], 1); - if ($mytempdata == 0) - $mymax = intval($data["dis_max"]); - else - $mymax = $data["dis_max"]; - $mymax = format_for_graph($mymax ); - - echo "<td class='".$tdcolor."'>".$mymin." / ".$mymax; - echo "<td class='".$tdcolor."'>".$data["time_threshold"]; - if ($data["last_fired"] == "0000-00-00 00:00:00") { - echo "<td class='".$tdcolor."f9'>".$lang_label["never"]; - } - else { - 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 "<div class='nf'>".$lang_label["no_alerts"]."</div>"; - } - 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 cellpadding='3' cellspacing='3'><tr>"; - echo "<td>".$lang_label["group"]."</td>"; - echo "<td valign='middle'>"; - echo "<select name='ag_group' onChange='javascript:this.form.submit();' class='w130'>"; - - if ( $ag_group > 1 ){ - echo "<option value='".$ag_group."'>".dame_nombre_grupo($ag_group)."</option>"; - } - echo "<option value=1>".dame_nombre_grupo(1)."</option>"; - list_group ($id_user); - echo "</select></td>"; - echo "<td valign='middle'><noscript><input name='uptbutton' type='submit' class='sub' value='".$lang_label["show"]."'></noscript></td></form>"; - // Show only selected groups - - if ($ag_group > 1) - $sql='SELECT id_agente, nombre, disabled FROM tagente WHERE id_grupo='.$ag_group.' ORDER BY nombre'; - else - $sql='SELECT id_agente, nombre, disabled 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"])."</td>"; - $string=$string."<td class='".$tdcolor."'>". - $data["descripcion"]."</td>"; - if ($data["last_fired"] == "0000-00-00 00:00:00") { - $string=$string."<td class='".$tdcolor."'>". - $lang_label["never"]."</td>"; - } - else { - $string=$string."<td class='".$tdcolor."'>". - $data["last_fired"]."</td>"; - } - $string=$string."<td class='".$tdcolor."'>". - $data["times_fired"]."</td>"; - if ($data["times_fired"] <> 0) - $string=$string."<td class='".$tdcolor."' - align='center'> - <img src='images/dot_red.gif'></td>"; - else - $string=$string."<td class='".$tdcolor."' - align='center'> - <img src='images/dot_green.gif'></td>"; - } - } - 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>"; - 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>"; +// Login check +$id_usuario=$_SESSION["id_usuario"]; +global $REMOTE_ADDR; + +if (comprueba_login() != 0) { + audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access alert view"); + include ("general/noaccess.php"); + exit; +} + + if ((give_acl($id_user, 0, "AR")!=1) AND (!give_acl($id_user,0,"AW")) AND (dame_admin($id_user)!=1)) { + audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access alert view"); + include ("general/noaccess.php"); + exit; + } + + +// ------------------------------- +// Show alerts for specific agent +// ------------------------------- +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.alert_text, 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 { - echo "</table><br><div class='nf'>". - $lang_label["no_alert"]."</div>"; + $tdcolor = "datos2"; + $color = 1; } - } else echo "</table><br><div class='nf'>". - $lang_label["no_agent"].$lang_label["no_agent_alert"]."</div>"; + echo "<tr>"; + echo "<td class='".$tdcolor."'>".dame_nombre_alerta($data["id_alerta"]); + echo "<td class='".$tdcolor."'>".$data["nombre"]; + echo "<td class='".$tdcolor."'>".$data["descripcion"]; + + $mytempdata = fmod($data["dis_min"], 1); + if ($mytempdata == 0) + $mymin = intval($data["dis_min"]); + else + $mymin = $data["dis_min"]; + $mymin = format_for_graph($mymin ); + + $mytempdata = fmod($data["dis_max"], 1); + if ($mytempdata == 0) + $mymax = intval($data["dis_max"]); + else + $mymax = $data["dis_max"]; + $mymax = format_for_graph($mymax ); + // Text alert ? + if ($data["alert_text"] != "") + echo "<td class='".$tdcolor."'>".$lang_label["text"]; + else + echo "<td class='".$tdcolor."'>".$mymin." / ".$mymax; + echo "<td class='".$tdcolor."'>".$data["time_threshold"]; + if ($data["last_fired"] == "0000-00-00 00:00:00") { + echo "<td class='".$tdcolor."f9'>".$lang_label["never"]; + } + else { + 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>'; } -} //end acl -} //end login + else echo "<div class='nf'>".$lang_label["no_alerts"]."</div>"; + +} else { + // ------------------------------- + // SHOW ALL ALERTS (GENERAL PAGE) + // ------------------------------- + + 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 cellpadding='3' cellspacing='3'><tr>"; + echo "<td>".$lang_label["group"]."</td>"; + echo "<td valign='middle'>"; + echo "<select name='ag_group' onChange='javascript:this.form.submit();' class='w130'>"; + + if ( $ag_group > 1 ){ + echo "<option value='".$ag_group."'>".dame_nombre_grupo($ag_group)."</option>"; + } + echo "<option value=1>".dame_nombre_grupo(1)."</option>"; + list_group ($id_user); + echo "</select></td>"; + echo "<td valign='middle'><noscript><input name='uptbutton' type='submit' class='sub' value='".$lang_label["show"]."'></noscript></td></form>"; + // Show only selected groups + + if ($ag_group > 1) + $sql='SELECT id_agente, nombre, disabled FROM tagente WHERE id_grupo='.$ag_group.' ORDER BY nombre'; + else + $sql='SELECT id_agente, nombre, disabled 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"])."</td>"; + $string=$string."<td class='".$tdcolor."'>". + $data["descripcion"]."</td>"; + if ($data["last_fired"] == "0000-00-00 00:00:00") { + $string=$string."<td class='".$tdcolor."'>". + $lang_label["never"]."</td>"; + } + else { + $string=$string."<td class='".$tdcolor."'>". + $data["last_fired"]."</td>"; + } + $string=$string."<td class='".$tdcolor."'>". + $data["times_fired"]."</td>"; + if ($data["times_fired"] <> 0) + $string=$string."<td class='".$tdcolor."' + align='center'> + <img src='images/dot_red.gif'></td>"; + else + $string=$string."<td class='".$tdcolor."' + align='center'> + <img src='images/dot_green.gif'></td>"; + } + } + 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>"; + 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 "</table><br><div class='nf'>". + $lang_label["no_alert"]."</div>"; + } + } else echo "</table><br><div class='nf'>". + $lang_label["no_agent"].$lang_label["no_agent_alert"]."</div>"; +} ?> \ No newline at end of file diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index c1ecfabc5f..fa29985610 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -210,17 +210,28 @@ if (give_acl($_SESSION["id_usuario"], 0, "AR")==1) { } else { echo '<div id="op8">'; } - echo '<ul class="mn"><li><a href="index.php?sec=reporting&sec2=operation/reporting/reporting" class="mn">'. $lang_label["reporting"].'</a></li></ul></div>'; + echo '<ul class="mn"><li><a href="index.php?sec=reporting&sec2=operation/reporting/custom_reporting" class="mn">'. $lang_label["reporting"].'</a></li></ul></div>'; - // Agent general reporting + // Custom reporting if (isset($_GET["sec"]) && $_GET["sec"] == "reporting"){ - if (isset($_GET["sec2"]) && $_GET["sec2"] == "operation/reporting/agent_overview"){ + if (isset($_GET["sec2"]) && $_GET["sec2"] == "operation/reporting/custom_reporting"){ echo "<div class='arrows'>"; } else { echo "<div class='arrow'>"; } - echo "<ul class='mn'><li><a href='index.php?sec=reporting&sec2=operation/reporting/agent_overview' class='mn'>".$lang_label["agent_general_reporting"]."</a></li></ul></div>"; + echo "<ul class='mn'><li><a href='index.php?sec=reporting&sec2=operation/reporting/custom_reporting' class='mn'>".$lang_label["custom_reporting"]."</a></li></ul></div>"; } + + // Custom graph viewer + if (isset($_GET["sec"]) && $_GET["sec"] == "reporting"){ + if (isset($_GET["sec2"]) && $_GET["sec2"] == "operation/reporting/graph_viewer"){ + echo "<div class='arrows'>"; + } else { + echo "<div class='arrow'>"; + } + echo "<ul class='mn'><li><a href='index.php?sec=reporting&sec2=operation/reporting/graph_viewer' class='mn'>".$lang_label["custom_graphs"]."</a></li></ul></div>"; + } + // Custom graph builder if (isset($_GET["sec"]) && $_GET["sec"] == "reporting"){ if (isset($_GET["sec2"]) && $_GET["sec2"] == "operation/reporting/graph_builder"){ diff --git a/pandora_console/operation/reporting/custom_reporting.php b/pandora_console/operation/reporting/custom_reporting.php new file mode 100644 index 0000000000..d2563d7bc7 --- /dev/null +++ b/pandora_console/operation/reporting/custom_reporting.php @@ -0,0 +1,149 @@ +<?PHP + +// 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) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es +// +// 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; version 2 +// 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. + +// Login check +$id_usuario=$_SESSION["id_usuario"]; +global $REMOTE_ADDR; + +if (comprueba_login() != 0) { + audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access graph builder"); + include ("general/noaccess.php"); + exit; +} + +if (isset($_GET["view_report"])){ + $id_report = $_GET["view_report"]; + $sql="SELECT * FROM treport WHERE id_report = $id_report"; + $res=mysql_query($sql); + if ($row = mysql_fetch_array($res)){ + $id_user = $row["id_user"]; + $private = $row["private"]; + $description = $row["description"]; + $name = $row["name"]; + if (($row["private"]==1) && ($row["id_user"] != $id_user)){ + audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access to a custom graph not allowed"); + include ("general/noaccess.php"); + exit; + } + + + $sql2="SELECT * FROM tgraph_source WHERE id_graph = $id_graph"; + $res2=mysql_query($sql2); + while ( $row2 = mysql_fetch_array($res2)){ + $weight = $row2["weight"]; + $id_agent_module = $row2["id_agent_module"]; + if (!isset($modules)){ + $modules = $id_agent_module; + $weights = $weight; + } else { + $modules = $modules.",".$id_agent_module; + $weights = $weights.",".$weight; + } + } + + echo "<h3>".$lang_label["combined_image"]."</h3>"; + echo "<table class='databox_frame'>"; + echo "<tr><td>"; + echo "<img src='reporting/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&label=$name&height=$height&width=$width&period=$period' border=1 alt=''>"; + echo "</td></tr></table>"; + + + switch ($period) { + case 3600: $period_label = "Hour"; + break; + case 21600: $period_label = "6 Hours"; + break; + case 43200: $period_label = "12 Hours"; + break; + case 86400: $period_label = "Day"; + break; + case 172800: $period_label = "Two days"; + break; + case 604800: $period_label = "Last Week"; + break; + case 1296000: $period_label = "15 Days"; + break; + case 2592000: $period_label = "Last Month"; + break; + case 5184000: $period_label = "Two Month"; + break; + case 15552000: $period_label = "Six Months"; + break; + default: $period_label = "Day"; + } + echo "<form method='POST' action='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=$id_graph'>"; + echo "<table class='databox_frame'>"; + echo "<tr><td class='datos'>"; + echo "<b>Period</b>"; + echo "<td class='datos'>"; + echo "<select name='period'>"; + if ($period==0) + echo "<option value=86400>".$period_label; + else + echo "<option value=$period>".$period_label; + echo "<option value=3600>"."Hour"; + echo "<option value=21600>"."6 Hours"; + echo "<option value=43200>"."12 Hours"; + echo "<option value=86400>"."Last day"; + echo "<option value=172800>"."Two days"; + echo "<option value=604800>"."Last Week"; + echo "<option value=1296000>"."15 days"; + echo "<option value=2592000>"."Last Month"; + echo "<option value=5184000>"."Two Month"; + echo "<option value=15552000>"."Six Months"; + echo "</select>"; + + echo "<td class='datos'>"; + echo "<input type=submit value='".$lang_label["update"]."' class='sub upd'>"; + echo "</table>"; + echo "</form>"; + } +} + +echo "<h3>".$lang_label["custom_report_builder"]."</h3>"; +echo "<table width='500' cellpadding=4 cellpadding=4 class='databox_frame'>"; +echo "<tr><th>".$lang_label["report_name"]."<th>".$lang_label["description"]."<th>".$lang_label["view"]; +$color=1; +$sql="SELECT * FROM treport"; +$res=mysql_query($sql); +while ($row = mysql_fetch_array($res)){ + if (($row["private"]==0) || ($row["id_user"] == $id_user)){ + // Calculate table line color + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + echo "<tr>"; + echo "<td valign='top' class='$tdcolor'>".$row["name"]; + echo "<td class='$tdcolor'>".$row["description"]; + $id_graph = $row["id_graph"]; + echo "<td valign='middle' class='$tdcolor' align='center'><a href='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=$id_graph'><img src='images/images.png'></A>"; + } +} +echo "</table>"; + + + + + +?> diff --git a/pandora_console/operation/reporting/graph_builder.php b/pandora_console/operation/reporting/graph_builder.php index 7c30ac32c7..9f4a2d242e 100644 --- a/pandora_console/operation/reporting/graph_builder.php +++ b/pandora_console/operation/reporting/graph_builder.php @@ -1,4 +1,5 @@ -<?PHP +// <?PHP + // Pandora FMS - the Free monitoring system // ======================================== // Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com @@ -22,13 +23,65 @@ $name = "Pandora FMS combined graph"; $width = 550; $height = 210; $period = ""; -$alerts= ""; +//$alerts= ""; $events = ""; $factor = 1; +$render=1; // by default + +// Login check +$id_usuario=$_SESSION["id_usuario"]; +global $REMOTE_ADDR; + +if (comprueba_login() != 0) { + audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access graph builder"); + include ("general/noaccess.php"); + exit; +} + +if (isset($_GET["store_graph"])){ + $name = entrada_limpia($_POST["name"]); + $description = entrada_limpia($_POST["description"]); + $module_number = entrada_limpia($_POST["module_number"]); + $private = entrada_limpia($_POST["private"]); + $width = entrada_limpia($_POST["width"]); + $height = entrada_limpia($_POST["height"]); + $events = entrada_limpia($_POST["events"]); + $period = entrada_limpia($_POST["period"]); + // Create graph + $sql = "INSERT INTO tgraph + (id_user, name, description, period, width, height, private, events) VALUES + ('$id_user', + '$name', + '$description', + $period, + $width, + $height, + $private, + $events)"; + //echo "DEBUG $sql<br>"; + $res = mysql_query($sql); + if ($res){ + $id_graph = mysql_insert_id(); + if ($id_graph){ + for ($a=0; $a < $module_number; $a++){ + $id_agentemodulo = entrada_limpia($_POST["module_".$a]); + $id_agentemodulo_w = entrada_limpia($_POST["module_weight_".$a]); + $sql = "INSERT INTO tgraph_source (id_graph, id_agent_module, weight) VALUES + ($id_graph, $id_agentemodulo, $id_agentemodulo_w)"; + //echo "DEBUG $sql<br>"; + mysql_query($sql); + } + echo "<h3 class='suc'>".$lang_label["store_graph_suc"]."</h3>"; + } else + echo "<h3 class='error'>".$lang_label["store_graph_error"]."</h3>"; + } else + echo "<h3 class='error'>".$lang_label["store_graph_error"]."</h3>"; +} if (isset($_GET["get_agent"])) { $id_agent = $_POST["id_agent"]; - $chunkdata = $_POST["chunk"]; + if (isset($_POST["chunk"])) + $chunkdata = isset($_POST["chunk"]); } if (isset($_GET["delete_module"] )) { @@ -87,10 +140,10 @@ if ( (isset($_GET["add_module"]))){ else $factor = 1; $period = $_POST["period"]; - $graphname = $_POST["graphname"]; $render = $_POST["render"]; - $alerts = $_POST["alerts"]; - $chunkdata = $_POST["chunk"]; +// $alerts = $_POST["alerts"]; + if (isset($_POST["chunk"])) + $chunkdata = $_POST["chunk"]; $events = $_POST["events"]; $factor = $_POST["factor"]; if ($_POST["width"]!= "") @@ -98,7 +151,7 @@ if ( (isset($_GET["add_module"]))){ if ($_POST["height"]!= "") $height = $_POST["height"]; if ($id_module > 0){ - if ($chunkdata == "") + if (!isset($chunkdata) OR ($chunkdata == "")) $chunkdata = "$id_agent,$id_module,$factor"; else $chunkdata = $chunkdata."|$id_agent,$id_module,$factor"; @@ -143,8 +196,9 @@ if (isset($chunk1)) { echo "<input type='hidden' name='chunk' value='$chunkdata'>"; if (isset($id_agent)) echo "<input type='hidden' name='id_agent' value='$id_agent'>"; - echo "<table width='500' cellpadding=4 cellpadding=4>"; + echo "<table width='500' cellpadding=4 cellpadding=4 class='databox_frame'>"; echo "<tr><th>Agent<th>Module<th>Weight<th>Delete"; + $color=0; for ($a=0; $a < count($module_array); $a++){ // Calculate table line color if ($color == 1){ @@ -165,7 +219,7 @@ if (isset($chunk1)) { echo "<td class='$tdcolor'>"; echo "<input style='height=2px;' type=checkbox name='delete_$a' value='".$module_array[$a]."'>"; } - echo "<tr><td colspan=4 align='right'><input type=submit name='update_agent' class=sub value='".$lang_label["delete"]."'>"; + echo "<tr><td class=datos colspan=4 align='right'><input type=submit name='update_agent' class='sub delete' value='".$lang_label["delete"]."'>"; echo "</table>"; echo "</form>"; } @@ -174,14 +228,14 @@ if (isset($chunk1)) { // SOURCE AGENT TABLE/FORM // ----------------------- echo "<h3>".$lang_label["graph_builder"]."</h3>"; -echo "<table width='500' cellpadding=4 cellpadding=4>"; +echo "<table width='500' cellpadding=4 cellpadding=4 class='databox_frame'>"; echo "<form method='post' action='index.php?sec=reporting&sec2=operation/reporting/graph_builder&get_agent=1'>"; echo "<tr>"; echo "<td class='datos'><b>".$lang_label["source_agent"]; echo "</b>"; // Show combo with agents -echo "<td class='datos'><select name='id_agent' style='width:180px;'>"; +echo "<td class='datos' colspan=2><select name='id_agent' style='width:180px;'>"; if ($id_agent != 0) echo "<option value='$id_agent'>".dame_nombre_agente($id_agent); $sql1='SELECT * FROM tagente order by nombre'; @@ -194,7 +248,7 @@ echo '</select>'; if (isset($chunkdata)) echo "<input type='hidden' name='chunk' value='$chunkdata'>"; -echo "<td class='datos' colspan=2 align='right'><input type=submit name='update_agent' class=sub value='".$lang_label["get_info"]."'>"; +echo "<td class='datos' colspan=1 align='right'><input type=submit name='update_agent' class='sub upd' value='".$lang_label["get_info"]."'>"; echo "</form>"; // ----------------------- @@ -232,52 +286,9 @@ echo "<td class='datos'>"; echo "<input type='text' name='width' value='$width' size=6>"; -echo "<tr><td class='datos2'>"; -echo "<b>Graph Name</b>"; -echo "<td class='datos2'>"; -echo "<input type='text' name='graphname' value='$name' size=25>"; -echo "<td class='datos2'>"; -echo "<b>Height</b>"; -echo "<td class='datos2'>"; -echo "<input type='text' name='height' value='$height' size=6>"; - - -echo "<tr><td class='datos'>"; -echo "<b>Period</b>"; -echo "<td class='datos'>"; -echo "<select name='period'>"; -if ($period != ""){ - if ($period == 3600) - echo "<option value='".$period."'>Last Hour"; - elseif ($period == 86400) - echo "<option value='".$period."'>Last day"; - elseif ($period == 604800) - echo "<option value='".$period."'>Last week"; - elseif ($period == 2592000) - echo "<option value='".$period."'>Last month"; -} -echo "<option value=86400>Last day"; -echo "<option value=3600>Last hour"; -echo "<option value=604800>Last week"; -echo "<option value=2592000>Last month"; -echo "</select>"; - -echo "<td class='datos'>"; -echo "<b>Show alert limit</b>"; -echo "<td class='datos'>"; -echo "<select name='alerts'>"; -if ($alerts == 1){ - echo "<option value=1>Yes"; - echo "<option value=0>No"; -} else { - echo "<option value=0>No"; - echo "<option value=1>Yes"; -} -echo "</select>"; - echo "<tr><td class='datos2'>"; echo "<b>Render now</b>"; -echo "<td class='datos2'>"; +echo "<td class='datos2' >"; echo "<select name='render'>"; if ($render == 1){ echo "<option value=1>Yes"; @@ -287,6 +298,58 @@ if ($render == 1){ echo "<option value=1>Yes"; } echo "</select>"; +echo "<td class='datos2'>"; +echo "<b>Height</b>"; +echo "<td class='datos2'>"; +echo "<input type='text' name='height' value='$height' size=6>"; + + +switch ($period) { + case 3600: $period_label = "Hour"; + break; + case 21600: $period_label = "6 Hours"; + break; + case 43200: $period_label = "12 Hours"; + break; + case 86400: $period_label = "Day"; + break; + case 172800: $period_label = "Two days"; + break; + case 604800: $period_label = "Last Week"; + break; + case 1296000: $period_label = "15 Days"; + break; + case 2592000: $period_label = "Last Month"; + break; + case 5184000: $period_label = "Two Month"; + break; + case 15552000: $period_label = "Six Months"; + break; + default: $period_label = "Day"; +} + + +echo "<tr><td class='datos'>"; +echo "<b>Period</b>"; +echo "<td class='datos'>"; + +echo "<select name='period'>"; +if ($period==0) + echo "<option value=86400>".$period_label; +else + echo "<option value=$period>".$period_label; +echo "<option value=3600>"."Hour"; +echo "<option value=21600>"."6 Hours"; +echo "<option value=43200>"."12 Hours"; +echo "<option value=86400>"."Last day"; +echo "<option value=172800>"."Two days"; +echo "<option value=604800>"."Last Week"; +echo "<option value=1296000>"."15 days"; +echo "<option value=2592000>"."Last Month"; +echo "<option value=5184000>"."Two Month"; +echo "<option value=15552000>"."Six Months"; +echo "</select>"; + echo "<td class='datos2'>"; echo "<b>Show events</b>"; echo "<td class='datos2'>"; @@ -300,27 +363,85 @@ if ($events == 1){ } echo "</select>"; -echo "<tr><td colspan=4 align='right'><input type=submit name='update_agent' class=sub value='".$lang_label["add"]."/".$lang_label["redraw"]."'>"; +/* +echo "<td class='datos'>"; +echo "<b>Show alert limit</b>"; +echo "<td class='datos'>"; +echo "<select name='alerts'>"; +if ($alerts == 1){ + echo "<option value=1>Yes"; + echo "<option value=0>No"; +} else { + echo "<option value=0>No"; + echo "<option value=1>Yes"; +} +echo "</select>"; +*/ + +echo "<tr><td colspan=4 class=datos align='right'><input type=submit name='update_agent' class='sub upd' value='".$lang_label["add"]."/".$lang_label["redraw"]."'>"; echo "</form>"; echo "</table>"; -// Parse chunkdata and render graph -if ($render == 1){ - // parse chunk - echo "<h3>".$lang_label["combined_image"]."</h3>"; - echo "<img src='reporting/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&label=$graphname&height=$height&width=$width&period=$period' border=1 alt=''>"; +// ----------------------- +// STORE GRAPH FORM +// ----------------------- -} -/* -if (isset($chunkdata)){ - echo "<form method='post' action='index.php?sec=reporting&sec2=operation/reporting/graph_builder&save_graph=1'>"; - echo "<input type='hidden' name='chunk' value='$chunkdata'>"; - echo "<table width='500' cellpadding=4 cellpadding=4>"; - echo "<tr><td class='datos2'>".$lang_name["custom_graph_name"]; - echo "<td class='datos2'><input type='text' value='' size=20 name='graph_name'>"; - echo "<td class='datos2'><input type=submit name='save' class=sub value='".$lang_label["save"]."'>"; +// If we have something to save.. +if (isset($module_array)){ + echo "<h3>".$lang_label["graph_store"]."</h3>"; + echo "<table width='500' cellpadding=4 cellpadding=4 class='databox_frame'>"; + echo "<form method='post' action='index.php?sec=reporting&sec2=operation/reporting/graph_builder&store_graph=1'>"; + + // hidden fields with data begin + echo "<input type='hidden' name='module_number' value='".count($module_array)."'>"; + echo "<input type='hidden' name='width' value='$width'>"; + echo "<input type='hidden' name='height' value='$height'>"; + echo "<input type='hidden' name='period' value='$period'>"; + echo "<input type='hidden' name='events' value='$events'>"; + + for ($a=0; $a < count($module_array); $a++){ + $id_agentemodulo = $module_array[$a]; + $id_agentemodulo_w = $weight_array[$a]; + echo "<input type='hidden' name='module_$a' value='$id_agentemodulo'>"; + echo "<input type='hidden' name='module_weight_$a' value='$id_agentemodulo_w'>"; + } + // hidden fields end + + echo "<tr>"; + echo "<td class='datos'><b>".$lang_label["name"]; + echo "</b>"; + echo "<td class='datos'><input type='text' name='name' size='35'>"; + + echo "<td class='datos'><b>".$lang_label["private"]; + echo "</b>"; + echo "<td class='datos'><select name='private'>"; + echo "<option value=0>".$lang_label["no"]; + echo "<option value=1>".$lang_label["yes"]; + echo "</select>"; + + echo "<tr>"; + echo "<td class='datos2'><b>".$lang_label["description"]; + echo "</b>"; + echo "<td class='datos2' colspan=4><textarea name='description' style='height:45px;' cols=55 rows=2>"; + echo "</textarea>"; + + echo "<tr><td class=datos colspan=4 align='right'><input type=submit name='store' class='sub wand' value='".$lang_label["store"]."'>"; + + + echo "</form>"; echo "</table>"; } -*/ +// -------------------------------------- +// Parse chunkdata and render graph +// -------------------------------------- +if (($render == 1) && (isset($modules))) { + // parse chunk + echo "<h3>".$lang_label["combined_image"]."</h3>"; + echo "<table class='databox_frame'>"; + echo "<tr><td>"; + echo "<img src='reporting/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&label=Combined%20Sample%20Graph&height=$height&width=$width&period=$period' border=1 alt=''>"; + echo "</td></tr></table>"; + +} ?> diff --git a/pandora_console/operation/reporting/graph_viewer.php b/pandora_console/operation/reporting/graph_viewer.php new file mode 100644 index 0000000000..bb64c593d7 --- /dev/null +++ b/pandora_console/operation/reporting/graph_viewer.php @@ -0,0 +1,153 @@ +<?PHP + +// 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) 2005-2007 Artica Soluciones Tecnologicas, info@artica.es +// +// 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; version 2 +// 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. + +// Login check +$id_usuario=$_SESSION["id_usuario"]; +global $REMOTE_ADDR; + +if (comprueba_login() != 0) { + audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access graph builder"); + include ("general/noaccess.php"); + exit; +} + +if (isset($_GET["view_graph"])){ + $id_graph = $_GET["view_graph"]; + $sql="SELECT * FROM tgraph WHERE id_graph = $id_graph"; + $res=mysql_query($sql); + if ($row = mysql_fetch_array($res)){ + $id_user = $row["id_user"]; + $private = $row["private"]; + $width = $row["width"]; + $height = $row["height"]; + $period = $row["period"]; + if (isset($_POST["period"])) + $period = $_POST["period"]; + $events = $row["events"]; + $description = $row["description"]; + $name = $row["name"]; + if (($row["private"]==1) && ($row["id_user"] != $id_user)){ + audit_db($id_usuario,$REMOTE_ADDR, "ACL Violation","Trying to access to a custom graph not allowed"); + include ("general/noaccess.php"); + exit; + } + + $sql2="SELECT * FROM tgraph_source WHERE id_graph = $id_graph"; + $res2=mysql_query($sql2); + while ( $row2 = mysql_fetch_array($res2)){ + $weight = $row2["weight"]; + $id_agent_module = $row2["id_agent_module"]; + if (!isset($modules)){ + $modules = $id_agent_module; + $weights = $weight; + } else { + $modules = $modules.",".$id_agent_module; + $weights = $weights.",".$weight; + } + } + + echo "<h3>".$lang_label["combined_image"]."</h3>"; + echo "<table class='databox_frame'>"; + echo "<tr><td>"; + echo "<img src='reporting/fgraph.php?tipo=combined&id=$modules&weight_l=$weights&label=$name&height=$height&width=$width&period=$period' border=1 alt=''>"; + echo "</td></tr></table>"; + + switch ($period) { + case 3600: $period_label = "Hour"; + break; + case 21600: $period_label = "6 Hours"; + break; + case 43200: $period_label = "12 Hours"; + break; + case 86400: $period_label = "Day"; + break; + case 172800: $period_label = "Two days"; + break; + case 604800: $period_label = "Last Week"; + break; + case 1296000: $period_label = "15 Days"; + break; + case 2592000: $period_label = "Last Month"; + break; + case 5184000: $period_label = "Two Month"; + break; + case 15552000: $period_label = "Six Months"; + break; + default: $period_label = "Day"; + } + echo "<form method='POST' action='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=$id_graph'>"; + echo "<table class='databox_frame'>"; + echo "<tr><td class='datos'>"; + echo "<b>Period</b>"; + echo "<td class='datos'>"; + echo "<select name='period'>"; + if ($period==0) + echo "<option value=86400>".$period_label; + else + echo "<option value=$period>".$period_label; + echo "<option value=3600>"."Hour"; + echo "<option value=21600>"."6 Hours"; + echo "<option value=43200>"."12 Hours"; + echo "<option value=86400>"."Last day"; + echo "<option value=172800>"."Two days"; + echo "<option value=604800>"."Last Week"; + echo "<option value=1296000>"."15 days"; + echo "<option value=2592000>"."Last Month"; + echo "<option value=5184000>"."Two Month"; + echo "<option value=15552000>"."Six Months"; + echo "</select>"; + + echo "<td class='datos'>"; + echo "<input type=submit value='".$lang_label["update"]."' class='sub upd'>"; + echo "</table>"; + echo "</form>"; + } +} + +echo "<h3>".$lang_label["custom_graph_viewer"]."</h3>"; +echo "<table width='500' cellpadding=4 cellpadding=4 class='databox_frame'>"; +echo "<tr><th>".$lang_label["graph_name"]."<th>".$lang_label["description"]."<th>".$lang_label["view"]; +$color=1; +$sql="SELECT * FROM tgraph"; +$res=mysql_query($sql); +while ($row = mysql_fetch_array($res)){ + if (($row["private"]==0) || ($row["id_user"] == $id_user)){ + // Calculate table line color + if ($color == 1){ + $tdcolor = "datos"; + $color = 0; + } + else { + $tdcolor = "datos2"; + $color = 1; + } + echo "<tr>"; + echo "<td valign='top' class='$tdcolor'>".$row["name"]; + echo "<td class='$tdcolor'>".$row["description"]; + $id_graph = $row["id_graph"]; + echo "<td valign='middle' class='$tdcolor' align='center'><a href='index.php?sec=reporting&sec2=operation/reporting/graph_viewer&view_graph=$id_graph'><img src='images/images.png'></A>"; + } +} +echo "</table>"; + + + + + +?> diff --git a/pandora_console/operation/servers/view_server.php b/pandora_console/operation/servers/view_server.php index ee8982c8c0..a41d10857b 100644 --- a/pandora_console/operation/servers/view_server.php +++ b/pandora_console/operation/servers/view_server.php @@ -193,12 +193,13 @@ if (comprueba_login() == 0) { $sql1 = "SELECT * FROM trecon_task WHERE id_network_server = $id_server"; $result1=mysql_query($sql1); $nowtime = time(); - $maxlag=0; + $maxlag=0;$maxlag2=0; while ($row1=mysql_fetch_array($result1)){ - if (($row1["utimestamp"] + $row1["interval_sweep"]) < $nowtime) + if (($row1["utimestamp"] + $row1["interval_sweep"]) < $nowtime){ $maxlag2 = $nowtime - ($row1["utimestamp"] + $row1["interval_sweep"]); if ($maxlag2 > $maxlag) $maxlag = $maxlag2; + } } if ($maxlag < 60) echo $maxlag." sec"; diff --git a/pandora_console/operation/users/user.php b/pandora_console/operation/users/user.php index 2f148bc9f9..58cdf7d18e 100644 --- a/pandora_console/operation/users/user.php +++ b/pandora_console/operation/users/user.php @@ -54,7 +54,7 @@ while ($rowdup=mysql_fetch_array($resq1)){ $color = 1; $tip = "tip2"; } - echo "<tr><td class='$tdcolor'><a href='index.php?sec=usuarios&sec2=operation/users/user_edit&ver=".$nombre."'><b>".$name."</b></a>"; + echo "<tr><td class='$tdcolor'><a href='index.php?sec=usuarios&sec2=operation/users/user_edit&ver=".$name."'><b>".$name."</b></a>"; echo "<td class='$tdcolor'><font size=1>".$fecha_registro."</font>"; echo "<td class='$tdcolor'>"; if ($nivel == 1) diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 5b7342e5f4..6af5cb7815 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -237,6 +237,7 @@ CREATE TABLE `talerta_agente_modulo` ( `module_type` int(11) NOT NULL default '0', `min_alerts` int(4) NOT NULL default '0', `internal_counter` int(4) default '0', + `alert_text` varchar(255) default '', PRIMARY KEY (`id_aam`) ) ENGINE=InnoDB; @@ -533,4 +534,46 @@ CREATE TABLE `tnews` ( `text` TEXT NOT NULL, `utimestamp` DATETIME NOT NULL DEFAULT 0, PRIMARY KEY(`id_news`) -) ENGINE = InnoDB; \ No newline at end of file +) ENGINE = InnoDB; + +CREATE TABLE `tgraph` ( + `id_graph` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `id_user` varchar(100) NOT NULL default '', + `name` varchar(150) NOT NULL default '', + `description` TEXT NOT NULL, + `period` int(11) NOT NULL default '0', + `width` smallint(5) UNSIGNED NOT NULL DEFAULT 0, + `height` smallint(5) UNSIGNED NOT NULL DEFAULT 0, + `private` tinyint(1) UNSIGNED NOT NULL default 0, + `events` tinyint(1) UNSIGNED NOT NULL default 0, + PRIMARY KEY(`id_graph`) +) ENGINE = InnoDB; + +CREATE TABLE `tgraph_source` ( + `id_gs` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `id_graph` int(11) NOT NULL default 0, + `id_agent_module` int(11) NOT NULL default 0, + `weight` smallint(5) UNSIGNED NOT NULL DEFAULT 0, + PRIMARY KEY(`id_gs`) +) ENGINE = InnoDB; + + +CREATE TABLE `treport` ( + `id_report` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `id_user` varchar(100) NOT NULL default '', + `name` varchar(150) NOT NULL default '', + `description` TEXT NOT NULL, + `private` tinyint(1) UNSIGNED NOT NULL default 0, + PRIMARY KEY(`id_report`) +) ENGINE = InnoDB; + +CREATE TABLE `treport_content` ( + `id_rc` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `id_report` INTEGER UNSIGNED NOT NULL default 0, + `id_gs` INTEGER UNSIGNED NOT NULL default 0, + `id_agent_module` int(11) NOT NULL default 0, + `type` tinyint(1) UNSIGNED NOT NULL default 0, + `period` int(11) NOT NULL default 0, + PRIMARY KEY(`id_rc`) +) ENGINE = InnoDB; + diff --git a/pandora_console/reporting/stat_win.php b/pandora_console/reporting/stat_win.php index 6abe936934..7408cef64f 100644 --- a/pandora_console/reporting/stat_win.php +++ b/pandora_console/reporting/stat_win.php @@ -69,10 +69,12 @@ switch ($period) { break; case 21600: $period_label = "6 Hours"; break; - case 43200: $period_label = "12 Hous"; + case 43200: $period_label = "12 Hours"; break; case 86400: $period_label = "Day"; break; + case 172800: $period_label = "Two days"; + break; case 604800: $period_label = "Last Week"; break; case 1296000: $period_label = "15 Days"; @@ -231,6 +233,7 @@ echo "<img src='fgraph.php?tipo=sparse&draw_alerts=$draw_alerts&draw_events=$dra echo "<option value=21600>"."6 Hours"; echo "<option value=43200>"."12 Hours"; echo "<option value=86400>"."Last day"; + echo "<option value=172800>"."Two days"; echo "<option value=604800>"."Last Week"; echo "<option value=1296000>"."15 days"; echo "<option value=2592000>"."Last Month";