From b4a87a0eef7c0f21855b215f6b6d9ca46939f4aa Mon Sep 17 00:00:00 2001 From: slerena Date: Thu, 10 Jan 2008 16:40:00 +0000 Subject: [PATCH] 2008-01-10 Sancho Lerena Code merged from 1.3.1 branch: * functions_db.php: Some changes in future generic SQL interface access. * pandora_console/include/functions.php: Added generic acces to HTTP parameters. * status_monitor.php: Fixed problems detected by Pierre Gaxatte. * estado_agente.php: Fixed the same kind of problems (ACL / Group acces) and added a Agent search field as request by J.Corona. * tactical.php: Rename of generic SQL function access. * view_server.php: Rename of generic SQL function access. * modificar_agente.php: Fixed some render problems, added a Agent search option and better formatting. * configurar_agente.php: New management for KeepAlive module. New code for 1.4 development branch (trunk) * pandoradbdata_13_to_14.sql: Migration SQL (data) code from 1.3 to 1.4 * pandoradb_13_to_14.sql: Migration SQL (schema) code frrom 1.3 to 1.4 * pandoradb_data.sql: Modified code to fresh install SQL data. * pandoradb.sql: Modified code to fresh install SQL schema. * index.php, * install.php: new version info. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@700 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 36 ++ .../godmode/agentes/configurar_agente.php | 28 +- .../godmode/agentes/modificar_agente.php | 117 ++++--- pandora_console/include/functions.php | 39 +-- pandora_console/include/functions_db.php | 53 ++- pandora_console/include/styles/pandora.css | 2 +- pandora_console/index.php | 6 +- pandora_console/install.php | 10 +- .../operation/agentes/estado_agente.php | 99 +++--- .../agentes/estado_ultimopaquete.php | 37 +- .../operation/agentes/status_monitor.php | 331 +++++++++--------- .../operation/agentes/tactical.php | 48 +-- .../operation/servers/view_server.php | 60 +--- .../operation/servers/view_server_detail.php | 10 +- pandora_console/pandoradb.sql | 85 +++-- pandora_console/pandoradb_13_to_14.sql | 72 ++++ pandora_console/pandoradb_data.sql | 2 +- pandora_console/pandoradbdata_13_to_14.sql | 12 + 18 files changed, 560 insertions(+), 487 deletions(-) create mode 100644 pandora_console/pandoradb_13_to_14.sql create mode 100644 pandora_console/pandoradbdata_13_to_14.sql diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 9bcac4dd3e..a3ab4db702 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,39 @@ +2008-01-10 Sancho Lerena + + Code merged from 1.3.1 branch: + + * functions_db.php: Some changes in future generic SQL interface access. + + * pandora_console/include/functions.php: Added generic acces to HTTP + parameters. + + * status_monitor.php: Fixed problems detected by Pierre Gaxatte. + + * estado_agente.php: Fixed the same kind of problems (ACL / Group acces) + and added a Agent search field as request by J.Corona. + + * tactical.php: Rename of generic SQL function access. + + * view_server.php: Rename of generic SQL function access. + + * modificar_agente.php: Fixed some render problems, added a Agent search + option and better formatting. + + * configurar_agente.php: New management for KeepAlive module. + + New code for 1.4 development branch (trunk) + + * pandoradbdata_13_to_14.sql: Migration SQL (data) code from 1.3 to 1.4 + + * pandoradb_13_to_14.sql: Migration SQL (schema) code frrom 1.3 to 1.4 + + * pandoradb_data.sql: Modified code to fresh install SQL data. + + * pandoradb.sql: Modified code to fresh install SQL schema. + + * index.php, + * install.php: new version info. + 2008-01-09 Sancho Lerena * fgraph.php: Solved problem in combined area render (ugly graphs most of times). diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index bd5e5ff488..9e66001c32 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1,27 +1,11 @@ -// Additions to Pandora FMS 1.2 graph code and new XML reporting template 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. +// CSS and some PHP code additions +// Please see http://pandora.sourceforge.net for full contribution list // Load global vars require("include/config.php"); @@ -123,7 +107,7 @@ if (isset($_POST["create_agent"])) { // Create a new and shining agent $id_agent_module = mysql_insert_id(); // And create MODULE agent_keepalive in tagente_estado table - $sql_insert2 ="INSERT INTO tagente_estado (id_agente_modulo, datos, timestamp, cambio, estado, id_agente, last_try, utimestamp, current_interval, running_by, last_execution_try) VALUES ($id_agent_module, 1, '', 0, 1, $id_agente, 0,0,0,0,0)"; + $sql_insert2 ="INSERT INTO tagente_estado (id_agente_modulo, datos, timestamp, cambio, estado, id_agente, last_try, utimestamp, current_interval, running_by, last_execution_try) VALUES ($id_agent_module, 1, '', 0, 0, $id_agente, 0,0,0,0,0)"; $result = mysql_query ($sql_insert2); // Create address for this agent in taddress diff --git a/pandora_console/godmode/agentes/modificar_agente.php b/pandora_console/godmode/agentes/modificar_agente.php index 4d24f2cad1..7d76a29709 100644 --- a/pandora_console/godmode/agentes/modificar_agente.php +++ b/pandora_console/godmode/agentes/modificar_agente.php @@ -1,26 +1,11 @@ -// Additions to Pandora FMS 1.2 graph code and new XML reporting template 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. +// CSS and some PHP code additions +// Please see http://pandora.sourceforge.net for full contribution list // Load global vars require("include/config.php"); @@ -32,22 +17,16 @@ if (give_acl($id_user, 0, "AW") != 1) { exit; } -if (isset($_GET["offset"])) - $offset = entrada_limpia($_GET["offset"]); -else - $offset = 0; - -if (isset($_GET["group_id"])) - $group_id = entrada_limpia($_GET["group_id"]); - else - $group_id = 0; - - if (isset($_POST["ag_group"])) - $ag_group = $_POST["ag_group"]; - elseif (isset($_GET["group_id"])) - $ag_group = $_GET["group_id"]; - else - $ag_group = -1; +// Take some parameters (GET) +$offset = get_parameter ("offset", 0); +$group_id = get_parameter ("group_id", 0); +$ag_group = get_parameter ("ag_group", -1); +if (($ag_group == -1) && ($group_id != 0)) + $ag_group = $group_id; +if (isset($_GET["ag_group_refresh"])){ + $ag_group = $_GET["ag_group_refresh"]; +} +$search = get_parameter ("search", ""); if (isset($_GET["borrar_agente"])){ // if delete agent $id_agente = entrada_limpia($_GET["borrar_agente"]); @@ -120,9 +99,9 @@ if (isset($_POST["ag_group"])){ action='index.php?sec=gagente&sec2=godmode/agentes/modificar_agente'>"; } -echo ""; -echo ""; -echo "
".$lang_label["group"].""; +echo ""; +echo ""; +echo " -
".$lang_label["group"].""; echo ""; -echo " +echo "
"; -if (isset($ag_group) && $ag_group> 1){ - $sql1="SELECT id_agente, nombre, id_grupo, comentarios, id_os - FROM tagente WHERE id_grupo = $ag_group ORDER BY nombre LIMIT $offset, $block_size"; - $sql2="SELECT COUNT(id_agente) FROM tagente WHERE id_grupo = $ag_group"; +
"; + +echo $lang_label["free_text_search"]; +echo ""; + +// Show group selector +if (isset($_POST["ag_group"])){ + $group_mod = "&ag_group_refresh=".$_POST["ag_group"]; } else { - $sql1="SELECT id_agente, nombre, id_grupo, comentarios, id_os - FROM tagente ORDER BY nombre LIMIT $offset, $block_size"; - $sql2="SELECT COUNT(id_agente) FROM tagente"; + $group_mod =""; } + +echo "
"; +echo ""; +echo "
"; +echo ""; +echo ""; +echo "
"; + +if ($search != ""){ + $search_sql = " AND nombre LIKE '%$search%' "; +} else { + $search_sql = ""; +} + +// Show only selected groups +if ($ag_group > 1){ + $sql1="SELECT * FROM tagente WHERE id_grupo=$ag_group + AND disabled = 0 $search_sql ORDER BY nombre LIMIT $offset, $block_size "; + $sql2="SELECT COUNT(id_agente) FROM tagente WHERE id_grupo=$ag_group + AND disabled = 0 $search_sql ORDER BY nombre"; +} else { + // Is admin user ?? + if (get_db_sql ("SELECT * FROM tusuario WHERE id_usuario ='$id_user'", "nivel") == 1){ + $sql1="SELECT * FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo LIMIT $offset, $block_size"; + $sql2="SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo"; + } else { + $sql1="SELECT * FROM tagente WHERE disabled = 0 $search_sql AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='$id_user') + ORDER BY nombre, id_grupo LIMIT $offset, $block_size"; + $sql2="SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='$id_user') ORDER BY nombre, id_grupo"; + } +} + $result=mysql_query($sql1); $result2=mysql_query($sql2); $row2=mysql_fetch_array($result2); @@ -160,7 +173,7 @@ pagination ($total_events, "index.php?sec=gagente&sec2=godmode/agentes/modificar echo "
"; if (mysql_num_rows($result)){ - echo ""; + echo "
"; echo ""; echo ""; echo ""; @@ -182,7 +195,7 @@ if (mysql_num_rows($result)){ echo ""; + id_agente=".$row["id_agente"]."'>".substr(strtoupper($row["nombre"]),0,20).""; // Operating System icon echo ""; @@ -191,7 +204,7 @@ if (mysql_num_rows($result)){   ".dame_grupo($id_grupo).""; // Description - echo ""; + echo ""; // Action echo ""; - $string=$string.""; - $string=$string.""; - $string=$string.""; - $string=$string.""; +if (isset($_POST["ag_group"])) + $ag_group = $_POST["ag_group"]; +elseif (isset($_GET["group_id"])) + $ag_group = $_GET["group_id"]; +else + $ag_group = -1; +if (isset($_GET["ag_group_refresh"])){ + $ag_group = $_GET["ag_group_refresh"]; +} + +if (isset($_POST["ag_group"])){ + $ag_group = $_POST["ag_group"]; + echo ""; +} else { + echo ""; +} +echo "
".$lang_label["agent_name"]."".$lang_label["os"]."".$lang_label["group"]."
".strtoupper($row["nombre"])." ".$row["comentarios"]."".$row["comentarios"].""; - echo "
"; + echo ""; - echo ""; - echo ""; + echo " - -
"; } else { echo "
".$lang_label["no_agent_def"]."
"; echo " 
"; diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index f785fa23da..1be0f0701d 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1,28 +1,14 @@ -// Additions to Pandora FMS 1.2 graph code and new XML reporting template 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. -// --------------------------------------------------------------- +// CSS and some PHP code additions +// Please see http://pandora.sourceforge.net for full contribution list + + // input: var, string. // mesg, mesage to show, var content. // --------------------------------------------------------------- @@ -524,4 +510,15 @@ function render_time ($lapse) { return $output; } +function get_parameter ($name, $default = '') { + // POST has precedence + if (isset($_POST[$name])) + return give_parameter_post ($name); + + if (isset($_GET[$name])) + return give_parameter_get ($name); + + return $default; +} + ?> diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index e916f3903b..4fb41fbbf7 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -1,26 +1,13 @@ -// Additions to Pandora FMS 1.2 graph code -// 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. -// Database functions +// CSS and some PHP code additions +// Please see http://pandora.sourceforge.net for full contribution list + // --------------------------------------------------------------- // give_acl () @@ -611,11 +598,7 @@ function dame_email($id){ // --------------------------------------------------------------- function dame_admin($id){ - require("config.php"); - $query1="SELECT * FROM tusuario WHERE id_usuario ='".$id."'"; - $rowdup=mysql_query($query1); - $rowdup2=mysql_fetch_array($rowdup); - $admin=$rowdup2["nivel"]; + $admin = get_db_sql ("SELECT * FROM tusuario WHERE id_usuario ='$id'", "nivel"); return $admin; } @@ -1080,6 +1063,25 @@ function give_db_value ($field, $table, $field_search, $condition_value){ return $pro; } +// --------------------------------------------------------------- +// Wrapper for old function name. Should be upgraded/renamed in next versions +// --------------------------------------------------------------- + +function get_db_value ($field, $table, $field_search, $condition_value){ + give_db_value ($field, $table, $field_search, $condition_value); +} + +// --------------------------------------------------------------- +// Generic access to single field using a free SQL sentence +// --------------------------------------------------------------- + +function get_db_sql ($sentence, $field = 0){ + global $config; + if ($rowdup = mysql_fetch_array(mysql_query($sentence))) + return $rowdup[$field]; + else + return ""; +} // --------------------------------------------------------------- // Return current status from a given agent module (1 alive, 0 down) @@ -1232,7 +1234,4 @@ function return_moduledata_min_value ($id_agent_module, $period){ return (0); } - - - ?> diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index ec7a83f44e..4b502585cb 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -453,7 +453,7 @@ div.title_line { } #menu_tab li.nomn:hover a, #menu_tab li:hover ul a:hover { - background: #cde0ad; + background: #66AA44; } #menu_tab li:hover a { background: #b2b08a url("../images/arrow.png") no-repeat right 3px; diff --git a/pandora_console/index.php b/pandora_console/index.php index 0fe865833e..d40ca0a62d 100644 --- a/pandora_console/index.php +++ b/pandora_console/index.php @@ -2,7 +2,7 @@ // Pandora FMS - the Free Monitoring System // ======================================== -// Copyright (c) 2004-2007 Sancho Lerena, slerena@gmail.com +// Copyright (c) 2004-2008 Sancho Lerena, slerena@gmail.com // Main PHP/SQL code development, project architecture and management. // Copyright (c) 2004-2007 Raul Mateos Martin, raulofpandora@gmail.com // CSS and some PHP code additions @@ -24,8 +24,8 @@ // Pandora FMS 1.x uses Pear Image::Graph code //Pandora Version, if not defined here it would take from config.php -$build_version="PC071216"; -$pandora_version="v1.4dev"; +$build_version="PC080109"; +$pandora_version="v1.4-dev"; global $build_version; global $pandora_version; diff --git a/pandora_console/install.php b/pandora_console/install.php index e3827bf555..5727932884 100644 --- a/pandora_console/install.php +++ b/pandora_console/install.php @@ -1,12 +1,12 @@ ".$lang_label["ag_title"]." > ".$lang_label["summary"].""; - - // Show group selector + + // Show group selector (POST) if (isset($_POST["ag_group"])){ $ag_group = $_POST["ag_group"]; echo "
".$lang_label["group"].""; + echo "".$lang_label["group"].""; echo ""; - echo " + echo " -
"; +
"; + + echo $lang_label["free_text_search"]; + echo ""; + echo "
"; + echo ""; + echo "
"; + echo ""; + echo ""; + echo "
"; + + if ($search != ""){ + $search_sql = " AND nombre LIKE '%$search%' "; + } else { + $search_sql = ""; + } + // Show only selected groups if ($ag_group > 1){ $sql="SELECT * FROM tagente WHERE id_grupo=$ag_group - AND disabled = 0 ORDER BY nombre LIMIT $offset, $block_size "; + AND disabled = 0 $search_sql ORDER BY nombre LIMIT $offset, $block_size "; $sql2="SELECT COUNT(id_agente) FROM tagente WHERE id_grupo=$ag_group - AND disabled = 0 ORDER BY nombre"; - } - else { - $sql="SELECT * FROM tagente WHERE disabled = 0 - ORDER BY nombre, id_grupo LIMIT $offset, $block_size"; - $sql2="SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 - ORDER BY nombre, id_grupo"; + AND disabled = 0 $search_sql ORDER BY nombre"; + } else { + // Is admin user ?? + if (get_db_sql ("SELECT * FROM tusuario WHERE id_usuario ='$id_user'", "nivel") == 1){ + $sql="SELECT * FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo LIMIT $offset, $block_size"; + $sql2="SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql ORDER BY nombre, id_grupo"; + } else { + $sql="SELECT * FROM tagente WHERE disabled = 0 $search_sql AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='$id_user') + ORDER BY nombre, id_grupo LIMIT $offset, $block_size"; + $sql2="SELECT COUNT(id_agente) FROM tagente WHERE disabled = 0 $search_sql AND id_grupo IN (SELECT id_grupo FROM tusuario_perfil WHERE id_usuario='$id_user') ORDER BY nombre, id_grupo"; + } } $result2=mysql_query($sql2); diff --git a/pandora_console/operation/agentes/estado_ultimopaquete.php b/pandora_console/operation/agentes/estado_ultimopaquete.php index dfbd051bc2..dcc9782039 100644 --- a/pandora_console/operation/agentes/estado_ultimopaquete.php +++ b/pandora_console/operation/agentes/estado_ultimopaquete.php @@ -1,26 +1,11 @@ -// Additions to Pandora FMS 1.2 graph code and new XML reporting template 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. +// CSS and some PHP code additions +// Please see http://pandora.sourceforge.net for full contribution list ?> @@ -103,7 +88,7 @@ if (comprueba_login() == 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["id_tipo_modulo"] > 4 AND ($row3["id_tipo_modulo"] < 100)){ if ($row3["flag"] == 0){ echo "
  "; - echo "  "; - echo ""; + if ($row3["id_tipo_modulo"] != 100) { + echo "  "; + echo "  "; + echo ""; + } + echo "
"; if ($row3["timestamp"] == "0000-00-00 00:00:00"){ echo $lang_label["never"]; diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 1ded7e789a..523c9ab38c 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -18,172 +18,176 @@ // 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)) { - - echo "

".$lang_label["ag_title"]." > "; - echo $lang_label["monitor_listing"]."

"; - - if (isset($_POST["ag_group"])) - $ag_group = $_POST["ag_group"]; - elseif (isset($_GET["group_id"])) - $ag_group = $_GET["group_id"]; - else - $ag_group = -1; - if (isset($_GET["ag_group_refresh"])){ - $ag_group = $_GET["ag_group_refresh"]; - } - - if (isset($_POST["ag_group"])){ - $ag_group = $_POST["ag_group"]; - echo "
"; - } else { - echo ""; - } - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - echo "
".$lang_label["group"].""; - echo ""; +if ((give_acl($id_user, 0, "AR")!=1) AND (give_acl($id_user,0,"AW")!=1)) { + audit_db($id_user,$REMOTE_ADDR, "ACL Violation", + "Trying to access Agent Management"); + require ("general/noaccess.php"); + exit; +} - // Module name selector - // This code thanks for an idea from Nikum, nikun_h@hotmail.com - if (isset($_POST["ag_modulename"])){ - $ag_modulename = $_POST["ag_modulename"]; - echo ""; - } else { - echo ""; - } - - echo ""; - echo "
".$lang_label["green_light"]."
"; - echo "
".$lang_label["red_light"]."
".$lang_label["module_name"]." - "; - echo " - - "; - +echo "

".$lang_label["ag_title"]." > "; +echo $lang_label["monitor_listing"]."

"; - // Show only selected names & groups - if ($ag_group > 1) - $sql='SELECT * FROM tagente WHERE id_grupo='.$ag_group.' ORDER BY nombre'; - else - $sql='SELECT * FROM tagente ORDER BY id_grupo, nombre'; - - echo "
"; - echo "
"; - $color =1; - $result=mysql_query($sql); - if (mysql_num_rows($result)){ - while ($row=mysql_fetch_array($result)){ //while there are agents - if ($row["disabled"] == 0) { - if ((isset($ag_modulename)) && ($ag_modulename != $lang_label["all"])) - $query_gen='SELECT * FROM tagente_modulo - WHERE id_agente = '.$row["id_agente"].' - AND nombre = "'.entrada_limpia($_POST["ag_modulename"]).'" - AND - id_tipo_modulo in (2, 9, 12, 18, 6)'; - // generic_proc, remote_tcp_proc, ??, remote_snmp_proc, remote_icmp_proc - else - $query_gen='SELECT * FROM tagente_modulo - WHERE id_agente = '.$row["id_agente"].' - AND - id_tipo_modulo in (2, 9, 12, 18, 6) '; - $result_gen=mysql_query($query_gen); - if (mysql_num_rows ($result_gen)) { - while ($data=mysql_fetch_array($result_gen)){ - if ($color == 1){ - $tdcolor="datos"; - $color =0; - } else { - $tdcolor="datos2"; - $color =1; - } - if (!isset($string)) {$string='';} - $string=$string. "
"; - $string=$string. ""; - $string=$string.""; - $string=$string. ""; - $string=$string."". - strtoupper(substr(dame_nombre_agente($data["id_agente"]),0,21)).""; - $string=$string.""; - $string=$string." - - ". - substr($data["nombre"],0,21)."". - substr($data["descripcion"],0,30).""; - if ($data["max"] == $data["min"]) - $string .= "--"; - else - $data["max"]."/".$data["min"].""; - if ($data["module_interval"] == 0){ - $my_interval = give_agentinterval($data["id_agente"]); - } else { - $my_interval = $data["module_interval"]; - } - $string .= $my_interval; - - $query_gen2='SELECT * FROM tagente_estado - WHERE id_agente_modulo = '.$data["id_agente_modulo"]; - $result_gen2=mysql_query($query_gen2); - $data2=mysql_fetch_array($result_gen2); - $string=$string.""; - if ($data2["datos"] > 0){ - $string=$string.""; - } else { - $string=$string.""; - } - - $string=$string.""; - $seconds = time() - $data2["utimestamp"]; - if ($seconds >= ($my_interval*2)) - $string .= ""; - else - $string .= ""; - - $string .= human_time_comparation($data2["timestamp"])."
"; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo ""; +echo "
".$lang_label["group"].""; +echo ""; + +// Module name selector +// This code thanks for an idea from Nikum, nikun_h@hotmail.com +if (isset($_POST["ag_modulename"])){ + $ag_modulename = $_POST["ag_modulename"]; + echo ""; +} else { + echo ""; +} + +echo ""; +echo "
".$lang_label["green_light"]."
"; +echo "
".$lang_label["red_light"]."
".$lang_label["module_name"]." +"; +echo " + +"; + +// Show only selected names & groups +if ($ag_group > 1) + $sql='SELECT * FROM tagente WHERE id_grupo='.$ag_group.' ORDER BY nombre'; +else + $sql='SELECT * FROM tagente ORDER BY id_grupo, nombre'; + +echo "
"; +echo "
"; +$color =1; +$result=mysql_query($sql); +if (mysql_num_rows($result)){ + while ($row=mysql_fetch_array($result)){ //while there are agents + if ($row["disabled"] == 0) { + if ((isset($ag_modulename)) && ($ag_modulename != $lang_label["all"])){ + $query_gen='SELECT * FROM tagente_modulo + WHERE id_agente = '.$row["id_agente"].' + AND nombre = "'.entrada_limpia($_POST["ag_modulename"]).'" + AND + id_tipo_modulo in (2, 9, 12, 18, 6, 100)'; + // generic_proc, remote_tcp_proc, ??, remote_snmp_proc, remote_icmp_proc + } else { + $query_gen='SELECT * FROM tagente_modulo + WHERE id_agente = '.$row["id_agente"].' + AND + id_tipo_modulo in (2, 9, 12, 18, 6, 100)'; + } + $result_gen=mysql_query($query_gen); + if (mysql_num_rows ($result_gen)) { + while ($data=mysql_fetch_array($result_gen)){ + if ($color == 1){ + $tdcolor="datos"; + $color =0; + } else { + $tdcolor="datos2"; + $color =1; } + if (!isset($string)) {$string='';} + $string=$string. ""; + $string=$string. ""; + $string=$string.""; + $string=$string. ""; + $string=$string."". + strtoupper(substr(dame_nombre_agente($data["id_agente"]),0,21)).""; + $string=$string.""; + $string=$string." + + "; + $string=$string."". + substr($data["nombre"],0,21).""; + $string=$string."". + substr($data["descripcion"],0,30).""; + + $string=$string.""; + if ($data["module_interval"] == 0){ + $my_interval = give_agentinterval($data["id_agente"]); + } else { + $my_interval = $data["module_interval"]; + } + $string .= $my_interval; + + $query_gen2='SELECT * FROM tagente_estado + WHERE id_agente_modulo = '.$data["id_agente_modulo"]; + $result_gen2=mysql_query($query_gen2); + $data2=mysql_fetch_array($result_gen2); + $string=$string.""; + if ($data2["datos"] > 0){ + $string=$string.""; + } else { + $string=$string.""; + } + + $string=$string.""; + $seconds = time() - $data2["utimestamp"]; + if ($seconds >= ($my_interval*2)) + $string .= ""; + else + $string .= ""; + + $string .= human_time_comparation($data2["timestamp"]).""; } - else if($ag_group>1) {unset($string);} } } - if (isset($string)) { + } + if (isset($string)) { echo " @@ -192,21 +196,16 @@ if (comprueba_login() == 0) { - "; echo $string; //the built table of monitors echo "
".$lang_label["type"]." ".$lang_label["name"]." ".$lang_label["description"]."".$lang_label["max_min"]." ".$lang_label["interval"]." ".$lang_label["status"]." ".$lang_label["timestamp"]."
"; - } - else { - echo "
".$lang_label["no_monitors_g"]."
"; - } } else { - echo "
".$lang_label["no_agent"]."
"; + echo "
".$lang_label["no_monitors_g"]."
"; } - -} //end acl -} //end login +} else { + echo "
".$lang_label["no_agent"]."
"; +} ?> diff --git a/pandora_console/operation/agentes/tactical.php b/pandora_console/operation/agentes/tactical.php index e088d616da..eb7bc76694 100644 --- a/pandora_console/operation/agentes/tactical.php +++ b/pandora_console/operation/agentes/tactical.php @@ -1,25 +1,14 @@ -// Additions to Pandora FMS 1.2 graph code -// 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. +// CSS and some PHP code additions +// Please see http://pandora.sourceforge.net for full contribution list + + // Load global vars require("include/config.php"); @@ -149,28 +138,15 @@ echo "

".$lang_label["tactical_indicator"]."

"; echo ""; - - // Server information // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - $sql='SELECT * FROM tserver'; + // Get total modules defined (network) + $total_modules_network = get_db_sql ("SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo > 4 AND id_tipo_modulo != 100"); + // Get total modules defined (data) + $total_modules_data = get_db_sql ("SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo < 5 OR id_tipo_modulo = 100"); echo "

".$lang_label["tactical_server_information"]."

"; - // Get total modules defined (network) - $sql1='SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo > 4'; - $result1=mysql_query($sql1); - $row1=mysql_fetch_array($result1); - $total_modules = $row1[0]; - - // Get total modules defined (data) - $sql1='SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo < 5 AND id_tipo_modulo != -1'; - if ($result1=mysql_query($sql1)){ - $row1=mysql_fetch_array($result1); - $total_modules_data = $row1[0]; - } else - $total_modules_data = 0; - // Connect DataBase + $sql='SELECT * FROM tserver'; $result=mysql_query($sql); if (mysql_num_rows($result)){ echo ""; diff --git a/pandora_console/operation/servers/view_server.php b/pandora_console/operation/servers/view_server.php index e05f46ce7c..932719935a 100644 --- a/pandora_console/operation/servers/view_server.php +++ b/pandora_console/operation/servers/view_server.php @@ -1,21 +1,12 @@ ".$lang_label["view_servers"]." > "; echo $lang_label["server_detail"].""; // Get total modules defined (network) - $sql1='SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo > 4'; - $result1=mysql_query($sql1); - $row1=mysql_fetch_array($result1); - $total_modules_network = $row1[0]; + $total_modules_network = get_db_sql ("SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo > 4 AND id_tipo_modulo != 100"); // Get total modules defined (data) - $sql1='SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo < 5 AND id_tipo_modulo != -1'; - if ($result1=mysql_query($sql1)){ - $row1=mysql_fetch_array($result1); - $total_modules_data = $row1[0]; - } else - $total_modules_data = 0; + $total_modules_data = get_db_sql ("SELECT COUNT(id_agente_modulo) FROM tagente_modulo WHERE id_tipo_modulo < 5 OR id_tipo_modulo = 100"); // Connect DataBase + $sql='SELECT * FROM tserver'; $result=mysql_query($sql); if (mysql_num_rows($result)){ echo "
"; @@ -86,11 +67,8 @@ if (comprueba_login() == 0) { $modules_server = 0; if (($network_server == 1) OR ($data_server == 1)){ - // Get total modules defined for this server (data modules) - $sql2 = "SELECT COUNT(running_by) FROM tagente_estado WHERE running_by = $id_server"; - $result2=mysql_query($sql2); - $row2=mysql_fetch_array($result2); - $modules_server = $row2[0]; + // Get total modules defined for this server (data modules) + $modules_server = get_db_sql ("SELECT COUNT(running_by) FROM tagente_estado WHERE running_by = $id_server"); } echo "
"; if ($recon_server == 1) @@ -122,16 +100,8 @@ if (comprueba_login() == 0) { $total_modules_temp = $total_modules_data; } } elseif ($recon_server == 1){ - - $sql2 = "SELECT COUNT(id_rt) FROM trecon_task WHERE id_network_server = $id_server"; - $result2=mysql_query($sql2); - $row2=mysql_fetch_array($result2); - $modules_server = $row2[0]; - - $sql2 = "SELECT COUNT(id_rt) FROM trecon_task"; - $result2=mysql_query($sql2); - $row2=mysql_fetch_array($result2); - $total_modules = $row2[0]; + $modules_server = get_db_sql ("SELECT COUNT(id_rt) FROM trecon_task WHERE id_network_server = $id_server"); + $total_modules = get_db_sql ("SELECT COUNT(id_rt) FROM trecon_task"); if ($total_modules == 0) $percentil = 0; else @@ -164,7 +134,7 @@ if (comprueba_login() == 0) { // This only checks for agent with a last_execution_try of at // maximun: ten times it's interval.... if is bigger, it probably // will be because an agent down - $sql1 = "SELECT MAX(last_execution_try), current_interval, id_agente FROM tagente_estado WHERE last_execution_try > 0 AND (tagente_estado.last_execution_try + (tagente_estado.current_interval *10) > UNIX_TIMESTAMP()) AND running_by=$id_server GROUP BY id_agente ORDER BY 1 ASC LIMIT 1"; + $sql1 = "SELECT MAX(last_execution_try), current_interval, id_agente FROM tagente_estado WHERE last_execution_try > 0 AND (tagente_estado.last_execution_try + (tagente_estado.current_interval * 10) > UNIX_TIMESTAMP()) AND running_by=$id_server GROUP BY id_agente ORDER BY 1 ASC LIMIT 1"; $nowtime = time(); $maxlag=0; if ($result1=mysql_query($sql1)) diff --git a/pandora_console/operation/servers/view_server_detail.php b/pandora_console/operation/servers/view_server_detail.php index 4f1b57ab1e..28f86f83e1 100644 --- a/pandora_console/operation/servers/view_server_detail.php +++ b/pandora_console/operation/servers/view_server_detail.php @@ -1,8 +1,12 @@