From e94f4f491e838679c55844b249aee999d4778604 Mon Sep 17 00:00:00 2001 From: Ramon Novoa Date: Wed, 22 Oct 2008 09:08:03 +0000 Subject: [PATCH] 2008-10-22 Ramon Novoa * include/styles/op.css, include/styles/pandora.css, pandoradb.sql, operation/menu.php, godmode/agentes/configurar_agente.php, godmode/agentes/agent_manager.php, godmode/menu.php: Added inventory support. * operation/agentes/export_csv.php: Fixed, didn't work. * operation/agentes/ver_agente.php: Fixed tabs. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1183 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 14 ++++++++ .../godmode/agentes/agent_manager.php | 13 +++++++ .../godmode/agentes/configurar_agente.php | 21 ++++++++--- pandora_console/godmode/menu.php | 4 +++ pandora_console/include/styles/op.css | 3 ++ pandora_console/include/styles/pandora.css | 4 +-- .../operation/agentes/export_csv.php | 13 +++---- .../operation/agentes/ver_agente.php | 36 +++++++++++++------ pandora_console/operation/menu.php | 5 ++- pandora_console/pandoradb.sql | 32 +++++++++++++++++ 10 files changed, 120 insertions(+), 25 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index dd1fe83431..6a25078e5e 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2008-10-22 Ramon Novoa + + * include/styles/op.css, + include/styles/pandora.css, + pandoradb.sql, + operation/menu.php, + godmode/agentes/configurar_agente.php, + godmode/agentes/agent_manager.php, + godmode/menu.php: Added inventory support. + + * operation/agentes/export_csv.php: Fixed, didn't work. + + * operation/agentes/ver_agente.php: Fixed tabs. + 2008-10-21 Jorge Gonzalez * operation/servers/view_server.php, diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 41eea1c8a5..7992f875ab 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -175,6 +175,19 @@ if ($id_prediction_server == 0) { print_select_from_sql ('SELECT id_server, name FROM tserver WHERE prediction_server = 1 ORDER BY name', 'prediction_server', $id_prediction_server, '', $none, $none_value); +// Inventory Server +echo ''.__('Inventory Server').''; +echo ' '.__('You must select an Inventory Server for the Agent, so it can work properly with this kind of modules').''; +echo ''; +$none = ''; +$none_value = ''; +if ($id_inventory_server == 0) { + $none = $none_str; + $none_value = 0; +} +print_select_from_sql ('SELECT id_server, name FROM tserver WHERE inventory_server = 1 ORDER BY name', + 'inventory_server', $id_inventory_server, '', $none, $none_value); + // Description echo ''; echo __('Description'); diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 028b8dedf4..ec1824f6ab 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -19,6 +19,7 @@ // Load global vars require("include/config.php"); +enterprise_include('godmode/agentes/configurar_agente.php'); check_login (); @@ -103,6 +104,7 @@ $id_network_server = 0; $id_plugin_server = 0; $id_prediction_server = 0; $id_wmi_server = 0; +$id_inventory_server = 0; $grupo = 0; $id_os = 0; @@ -123,6 +125,7 @@ if (isset ($_POST["create_agent"])) { // Create a new and shiny agent $id_plugin_server = get_parameter_post ("plugin_server", 0); $id_prediction_server = get_parameter_post ("prediction_server", 0); $id_wmi_server = get_parameter_post ("wmi_server", 0); + $id_inventory_server = get_parameter_post ("inventory_server", 0); $id_os = get_parameter_post ("id_os", 0); $disabled = get_parameter_post ("disabled", 0); @@ -135,10 +138,10 @@ if (isset ($_POST["create_agent"])) { // Create a new and shiny agent $agent_created_ok = 0; } else { $sql = sprintf ("INSERT INTO tagente - (nombre, direccion, id_grupo, intervalo, comentarios, modo, id_os, disabled, id_network_server, id_plugin_server, id_wmi_server, id_prediction_server, id_parent) + (nombre, direccion, id_grupo, intervalo, comentarios, modo, id_os, disabled, id_network_server, id_plugin_server, id_wmi_server, id_prediction_server, id_inventory_server, id_parent) VALUES - ('%s', '%s', %d, %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d)", - $nombre_agente, $direccion_agente, $grupo, $intervalo, $comentarios, $modo, $id_os, $disabled, $id_network_server, $id_plugin_server, $id_wmi_server, $id_prediction_server, $id_parent); + ('%s', '%s', %d, %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)", + $nombre_agente, $direccion_agente, $grupo, $intervalo, $comentarios, $modo, $id_os, $disabled, $id_network_server, $id_plugin_server, $id_wmi_server, $id_prediction_server, $id_inventory_server, $id_parent); $id_agente = process_sql ($sql, "insert_id"); if ($id_agente !== false) { $agent_created_ok = 1; @@ -226,6 +229,8 @@ if ($tab == "template") { echo " ".__('Net. Templates').""; echo ""; +enterprise_hook ('inventory_tab'); + echo ""; echo ""; echo ""; // menu_tab_frame @@ -496,6 +501,7 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter $id_plugin_server = (int) get_parameter_post ("plugin_server", 0); $id_wmi_server = (int) get_parameter_post ("wmi_server", 0); $id_prediction_server = (int) get_parameter_post ("prediction_server", 0); + $id_inventory_server = (int) get_parameter_post ("inventory_server", 0); $id_parent = (int) get_parameter_post ("id_parent", 0); //Verify if there is another agent with the same name but different ID @@ -529,8 +535,9 @@ if (isset($_POST["update_agent"])) { // if modified some agent paramenter id_network_server = %d, id_plugin_server = %d, id_wmi_server = %d, - id_prediction_server = %d - WHERE id_agente = %d",$disabled,$id_parent,$id_os,$modo,$nombre_agente,$direccion_agente,$grupo,$intervalo,$comentarios,$id_network_server,$id_plugin_server,$id_wmi_server,$id_prediction_server,$id_agente); + id_prediction_server = %d, + id_inventory_server = %d + WHERE id_agente = %d",$disabled,$id_parent,$id_os,$modo,$nombre_agente,$direccion_agente,$grupo,$intervalo,$comentarios,$id_network_server,$id_plugin_server,$id_wmi_server,$id_prediction_server,$id_inventory_server,$id_agente); $result = process_sql ($sql); if ($result === false) { echo '

'.__('There was a problem updating agent').'

'; @@ -575,6 +582,7 @@ if (isset($_GET["id_agente"])) { $id_network_server = $row["id_network_server"]; $id_prediction_server = $row["id_prediction_server"]; $id_wmi_server = $row["id_wmi_server"]; + $id_inventory_server = $row["id_inventory_server"]; $modo = $row["modo"]; $id_os = $row["id_os"]; $disabled = $row["disabled"]; @@ -895,6 +903,9 @@ switch ($tab) { case "template": require "agent_template.php"; break; + case "inventory": + enterprise_include ('godmode/agentes/inventory_manager.php'); + break; default: //This will make sure that blank pages will have at least some //debug info in them diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 0fe004b9e0..44a520dd2e 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -16,6 +16,8 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +enterprise_include ('godmode/menu.php'); + if (comprueba_login ()) { return; } @@ -104,6 +106,8 @@ if ((give_acl($config['id_user'], 0, "PM")==1)){ echo ""; } + // Inventory modules + enterprise_hook ('inventory_submenu'); } if (give_acl ($config['id_user'], 0, "LM")) { diff --git a/pandora_console/include/styles/op.css b/pandora_console/include/styles/op.css index 004bc94b34..188d3a5b27 100644 --- a/pandora_console/include/styles/op.css +++ b/pandora_console/include/styles/op.css @@ -59,6 +59,9 @@ #op9 li { background: url(../../images/monitor.png) no-repeat 4px 3px; } +#op10 li { + background: url(../../images/page_white_text.png) no-repeat 4px 3px; +} #op-extensions li { background: url(../../images/extensions.png) no-repeat 4px 3px; } diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 64cdc816b5..e8e5b76f90 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -466,7 +466,7 @@ div.title_line { } #menu_tab li a, #menu_tab li.nomn a { background: #d4ddc6; - padding: 2px 10px 2px 10px; + padding: 2px 5px 2px 5px; color: #333; border-left: 2px solid #778866; font-weight: bold; @@ -509,7 +509,7 @@ div.title_line { } #menu_tab_left li a { background: #d84437; - padding: 2px 10px 2px 10px; + padding: 2px 5px 2px 5px; color: #fff; font-weight: bold; line-height: 18px; diff --git a/pandora_console/operation/agentes/export_csv.php b/pandora_console/operation/agentes/export_csv.php index fec7201fcc..95f53caa3c 100644 --- a/pandora_console/operation/agentes/export_csv.php +++ b/pandora_console/operation/agentes/export_csv.php @@ -16,13 +16,14 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +session_start(); +require_once ("../../include/config.php"); +require_once ("../../include/functions.php"); +require_once ("../../include/functions_db.php"); -require ("include/config.php"); - -check_login (); - -if (! give_acl($config['id_user'], 0, "AR") && ! give_acl ($config['id_user'], 0, "AW")){ +$config["id_user"] = $_SESSION["id_usuario"]; +if (! give_acl ($config['id_user'], 0, "AR") && ! give_acl ($config['id_user'], 0, "AW")) { require ("../../general/noaccess.php"); return; } @@ -31,7 +32,7 @@ if (isset ($_GET["agentmodule"]) && isset ($_GET["agent"]) ){ $id_agentmodule = $_GET["agentmodule"]; $id_agent = $_GET["agent"]; $agentmodule_name = dame_nombre_modulo_agentemodulo ($id_agentmodule); - if (! give_acl ($config['id_user'], dame_id_grupo ($id_agent), "AR") != 1) { + if (! give_acl ($config['id_user'], dame_id_grupo ($id_agent), "AR")) { audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access Agent Export Data"); require ("../../general/noaccess.php"); diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index dbe26a7cb4..0a6ab6f37e 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -18,6 +18,7 @@ // Load global vars require("include/config.php"); +enterprise_include('operation/agentes/ver_agente.php'); check_login(); @@ -189,10 +190,10 @@ if (give_acl ($config['id_user'],$id_grupo, "AW")) { echo "
  • "; } else { echo "
  • "; - // Manage agent - echo " ".__('Manage')." "; - echo "
  • "; } + // Manage agent + echo " ".__('Manage')." "; + echo ""; } // Main view @@ -200,30 +201,40 @@ if ($tab == "main") { echo "
  • "; } else { echo "
  • "; - echo " ".__('Main')." "; - echo "
  • "; } +echo " ".__('Main')." "; +echo ""; + // Data if ($tab == "data") { echo "
  • "; } else { echo "
  • "; - echo " ".__('Data')." "; - echo "
  • "; } +echo " ".__('Data')." "; +echo ""; + // Alerts if ($tab == "alert") { echo "
  • "; } else { echo "
  • "; - echo " ".__('Alerts')." "; - echo "
  • "; } +echo " ".__('Alerts')." "; +echo ""; + // Go to SLA view -echo "
  • "; +if ($tab == "sla") { + echo "
  • "; +} else { + echo "
  • "; +} echo " ".__('S.L.A')." "; echo "
  • "; - + +// Inventory +enterprise_hook ('inventory_tab'); + echo ""; echo ""; echo ""; @@ -248,6 +259,9 @@ case "data": case "alert": require "estado_alertas.php"; break; +case "inventory": + enterprise_include ('operation/agentes/agent_inventory.php'); + break; } ?> diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index f4841945f3..51977d70bc 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -19,6 +19,8 @@ if (! isset ($config['id_user'])) { return; } + +enterprise_include ('operation/menu.php'); ?>
    :: ::
    @@ -116,7 +118,8 @@ if (give_acl ($config['id_user'], 0, "AR")) { echo ""; } } - + + enterprise_hook ('inventory_menu'); // Server view if ( $sec == "estado_server") { diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index a5d8cf2b0e..14376d36e3 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -57,6 +57,7 @@ CREATE TABLE IF NOT EXISTS `tagente` ( `id_prediction_server` smallint(4) unsigned default '0', `id_wmi_server` smallint(4) unsigned default '0', `id_parent` int(10) unsigned default '0', + `id_inventory_server` smallint(4) unsigned default '0', PRIMARY KEY (`id_agente`), KEY `nombre` (`nombre`), KEY `direccion` (`direccion`), @@ -493,6 +494,7 @@ CREATE TABLE IF NOT EXISTS `tserver` ( `prediction_server` tinyint(3) unsigned NOT NULL default '0', `wmi_server` tinyint(3) unsigned NOT NULL default '0', `export_server` tinyint(3) unsigned NOT NULL default '0', + `inventory_server` tinyint(3) unsigned NOT NULL default '0', PRIMARY KEY (`id_server`), KEY `name` (`name`), KEY `keepalive` (`keepalive`), @@ -724,3 +726,33 @@ CREATE TABLE IF NOT EXISTS `tplanned_downtime_agents` ( `id_downtime` mediumint(8) unsigned NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tmodule_inventory` ( + `id_module_inventory` int(10) NOT NULL auto_increment, + `id_os` int(10) unsigned NOT NULL, + `name` varchar(100) default '', + `description` varchar(100) default '', + `interpreter` varchar(100) default '', + `code` BLOB NOT NULL, + PRIMARY KEY (`id_module_inventory`), + FOREIGN KEY (`id_os`) REFERENCES tconfig_os(`id_os`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tagent_module_inventory` ( + `id_agent_module_inventory` int(10) NOT NULL auto_increment, + `id_agente` int(10) unsigned NOT NULL, + `id_module_inventory` int(10) NOT NULL, + `target` varchar(100) default '', + `interval` int(10) unsigned NOT NULL default '3600', + `username` varchar(100) default '', + `password` varchar(100) default '', + `data` BLOB NOT NULL, + `timestamp` datetime default '0000-00-00 00:00:00', + `flag` tinyint(1) unsigned default '1', + PRIMARY KEY (`id_agent_module_inventory`), + FOREIGN KEY (`id_agente`) REFERENCES tagente(`id_agente`) + ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_module_inventory`) REFERENCES tmodule_inventory(`id_module_inventory`) + ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8;