From f7e49b71d33fd1318269f1a7a76658539f43ae63 Mon Sep 17 00:00:00 2001 From: esanchezm Date: Mon, 2 Feb 2009 15:40:31 +0000 Subject: [PATCH] 2009-02-02 Esteban Sanchez * godmode/agentes/configurar_agente.php, godmode/agentes/module_manager.php, godmode/agentes/module_manager_editor.php, godmode/agentes/module_manager_editor_data.php, godmode/agentes/module_manager_editor_network.php, godmode/agentes/module_manager_editor_plugin.php, godmode/agentes/module_manager_editor_prediction.php, godmode/agentes/module_manager_editor_wmi.php: Agent module editions rewritten. The interface should be clearer now and SNMP walking much more faster, since it's done with AJAX. Some cleanup might be needed yet. * godmode/agentes/module_manager_editor_common.php: Added to repository. Common part for agent module editors. * images/edit.png, images/spinner.gif: Added to repository. * include/javascript/jquery.form.js: Added to repository. jQuery form plugin. * include/javascript/jquery.pandora.js: Added to repository. Special Pandora addons for jQuery library. * include/javascript/pandora.js: Added an extension to Array javascript objects to check if an array has an element. * include/styles/pandora.css: Added styling for new module editors. * include/functions_db.php: Added get_moduletype_description(). * index.php: Added Pandora jQuery extensions. * pandoradb.sql, pandoradb_migrate_20_to_21.sql: Removed alert_text useless field from talert_templates. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1417 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 37 ++ .../godmode/agentes/configurar_agente.php | 425 ++++++------- .../godmode/agentes/module_manager.php | 30 +- .../godmode/agentes/module_manager_editor.php | 464 ++++++++++---- .../agentes/module_manager_editor_common.php | 182 ++++++ .../agentes/module_manager_editor_data.php | 216 +------ .../agentes/module_manager_editor_network.php | 382 +++-------- .../agentes/module_manager_editor_plugin.php | 261 +------- .../module_manager_editor_prediction.php | 163 +---- .../agentes/module_manager_editor_wmi.php | 302 ++------- .../images/console/icons/server_warning.png | Bin 1741 -> 0 bytes pandora_console/images/edit.png | Bin 0 -> 574 bytes pandora_console/images/spinner.gif | Bin 0 -> 673 bytes pandora_console/include/functions_db.php | 11 + .../include/javascript/jquery.form.js | 602 ++++++++++++++++++ .../include/javascript/jquery.pandora.js | 28 + pandora_console/include/javascript/pandora.js | 17 +- pandora_console/include/styles/pandora.css | 15 + pandora_console/index.php | 5 +- pandora_console/pandoradb.sql | 1 - .../pandoradb_migrate_20_to_21.sql | 1 - 21 files changed, 1608 insertions(+), 1534 deletions(-) create mode 100644 pandora_console/godmode/agentes/module_manager_editor_common.php delete mode 100644 pandora_console/images/console/icons/server_warning.png create mode 100644 pandora_console/images/edit.png create mode 100644 pandora_console/images/spinner.gif create mode 100644 pandora_console/include/javascript/jquery.form.js create mode 100644 pandora_console/include/javascript/jquery.pandora.js diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 5d6fa07d61..737726e1fd 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,40 @@ +2009-02-02 Esteban Sanchez + + * godmode/agentes/configurar_agente.php, + godmode/agentes/module_manager.php, + godmode/agentes/module_manager_editor.php, + godmode/agentes/module_manager_editor_data.php, + godmode/agentes/module_manager_editor_network.php, + godmode/agentes/module_manager_editor_plugin.php, + godmode/agentes/module_manager_editor_prediction.php, + godmode/agentes/module_manager_editor_wmi.php: Agent module editions + rewritten. The interface should be clearer now and SNMP walking much + more faster, since it's done with AJAX. Some cleanup might be needed + yet. + + * godmode/agentes/module_manager_editor_common.php: Added to + repository. Common part for agent module editors. + + * images/edit.png, images/spinner.gif: Added to repository. + + * include/javascript/jquery.form.js: Added to repository. jQuery form + plugin. + + * include/javascript/jquery.pandora.js: Added to repository. Special + Pandora addons for jQuery library. + + * include/javascript/pandora.js: Added an extension to Array + javascript objects to check if an array has an element. + + * include/styles/pandora.css: Added styling for new module editors. + + * include/functions_db.php: Added get_moduletype_description(). + + * index.php: Added Pandora jQuery extensions. + + * pandoradb.sql, pandoradb_migrate_20_to_21.sql: Removed alert_text + useless field from talert_templates. + 2009-01-30 Evi Vanoost * include/config.inc.php: Updated documentation on LDAP implementation. diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 8532459fa7..7f78e50298 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -35,12 +35,10 @@ if (! give_acl($config["id_user"], $group, "AW")) { exit; } - // Get passed variables -$tab = get_parameter_get ("tab", "main"); -$form_moduletype = get_parameter_post ("form_moduletype"); -$form_alerttype = get_parameter ("form_alerttype"); -$moduletype = get_parameter_get ("moduletype"); +$tab = get_parameter ('tab', 'main'); +$alerttype = get_parameter ('alerttype'); +$id_agent_module = (int) get_parameter ('id_agent_module'); // Init vars $descripcion = ""; @@ -51,7 +49,7 @@ $campo_3 = ""; $maximo = 0; $minimo = 0; $nombre_agente = ""; -$direccion_agente = get_parameter ("direccion", ""); +$direccion_agente = get_parameter ('direccion'); $intervalo = 300; $id_server = ""; $max_alerts = 0; @@ -108,26 +106,24 @@ $grupo = 0; $id_os = 0; $custom_id = ""; -// ================================ -// Create AGENT -// ================================ -// We need to create agent BEFORE showing tabs, because we need to get agent_id -// This is not very clean, but... -if (isset ($_POST["create_agent"])) { // Create a new and shiny agent - $nombre_agente = get_parameter_post ("agente", ""); - $direccion_agente = get_parameter_post ("direccion", ""); - $grupo = get_parameter_post ("grupo", 0); - $intervalo = get_parameter_post ("intervalo", 300); - $comentarios = get_parameter_post ("comentarios", ""); - $modo = get_parameter_post ("modo", 0); - $id_parent = get_parameter_post ("id_parent", 0); - $id_network_server = get_parameter_post ("network_server", 0); - $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_os = get_parameter_post ("id_os", 0); - $disabled = get_parameter_post ("disabled", 0); - $custom_id = get_parameter_post ("custom_id", ""); +$create_agent = (bool) get_parameter ('create_agent'); + +// Create agent +if ($create_agent) { + $nombre_agente = (string) get_parameter_post ("agente"); + $direccion_agente = (string) get_parameter_post ("direccion"); + $grupo = (int) get_parameter_post ("grupo"); + $intervalo = (string) get_parameter_post ("intervalo", 300); + $comentarios = (string)get_parameter_post ("comentarios"); + $modo = (int) get_parameter_post ("modo"); + $id_parent = (int) get_parameter_post ("id_parent"); + $id_network_server = (int) get_parameter_post ("network_server"); + $id_plugin_server = (int) get_parameter_post ("plugin_server"); + $id_prediction_server = (int) get_parameter_post ("prediction_server"); + $id_wmi_server = (int) get_parameter_post ("wmi_server"); + $id_os = (int) get_parameter_post ("id_os"); + $disabled = (int) get_parameter_post ("disabled"); + $custom_id = (string) get_parameter_post ("custom_id"); // Check if agent exists (BUG WC-50518-2) if ($nombre_agente == "") { @@ -137,65 +133,72 @@ if (isset ($_POST["create_agent"])) { // Create a new and shiny agent $agent_creation_error = __('There is already an agent in the database with this name'); $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, custom_id) - VALUES - ('%s', '%s', %d, %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d, '%s')", - $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, $custom_id); - $id_agente = process_sql ($sql, "insert_id"); + $id_agente = process_sql_insert ('tagente', + array ('nombre' => $nombre_agente, + 'direccion' => $direccion_agente, + 'id_grupo' => $grupo, 'intervalo' => $intervalo, + 'comentarios' => $comentarios, 'modo' => $modo, + 'id_os' => $id_os, 'disabled' => $disabled, + 'id_network_server' => $id_network_server, + 'id_plugin_server' => $id_plugin_server, + 'id_wmi_server' => $id_wmi_server, + 'id_prediction_server' => $id_prediction_server, + 'id_parent' => $id_parent, 'custom_id' => $custom_id)); enterprise_hook ('update_agent', array ($id_agente)); if ($id_agente !== false) { - $agent_created_ok = 1; - $agent_creation_error = ""; + // Create address for this agent in taddress + agent_add_address ($id_agente, $direccion_agente); + + $agent_created_ok = true; // Create special module agent_keepalive - $sql = "INSERT INTO tagente_modulo - (nombre, id_agente, id_tipo_modulo, descripcion, id_modulo,min_warning, max_warning ) - VALUES - ('agent_keepalive',".$id_agente.",100,'Agent Keepalive monitor',1 ,0,1)"; - $id_agent_module = process_sql ($sql, "insert_id"); + $id_agent_module = process_sql_insert ('tagente_modulo', + array ('nombre' => 'agent_keepalive', + 'id_agente' => $id_agente, + 'id_tipo_modulo' => 100, + 'descripcion' => __('Ageng keepalive monitor'), + 'id_modulo' => 1, + 'min_warning' => 0, + 'max_warning' => 1)); if ($id_agent_module !== false) { // Create agent_keepalive in tagente_estado table - $sql = "INSERT INTO tagente_estado - (id_agente_modulo, datos, timestamp, estado, id_agente, last_try, utimestamp, current_interval, running_by, last_execution_try) - VALUES - (".$id_agent_module.",'',0,0,".$id_agente.",0,0,0,0,0)"; - $result = process_sql ($sql); - if ($result === false) { - $agent_created_ok = 0; - // Do not translate tagente_estado, is the table name - $agent_creation_error = __("There was a problem creating record in tagente_estado table"); - } + $result = process_sql_insert ('tagente_modulo', + array ('id_agente_modulo' => $id_agent_module, + 'datos' => '', + 'timestamp' => 0, + 'estado' => 0, + 'id_agente' => $id_agente, + 'last_try' => 0, + 'utimestamp' => 0, + 'current_interval' => 0, + 'running_by' => 0, + 'last_execution_try' => 0)); + if ($result === false) + $agent_created_ok = false; } else { - $agent_created_ok = 0; - $agent_creation_error = __("There was a problem creating agent_keepalive module"); + $agent_created_ok = false; } - - // Create address for this agent in taddress - agent_add_address ($id_agente, $direccion_agente); } else { $id_agente = -1; - $agent_created_ok = 0; $agent_creation_error = __("There was a problem creating the agent"); } } } // Show tabs -// ----------------- echo ""; // menu_tab_frame // Make some space between tabs and title -echo "
 
"; //Some browsers (IE) might not always show an empty div, added space +// IE might not always show an empty div, added space +echo "
 
"; // Show agent creation results -if (isset ($_POST["create_agent"])) { - if ($agent_created_ok == 0){ +if ($create_agent) { + if (! $agent_created_ok) { echo "

".__('There was a problem creating agent')."

"; - echo $agent_creation_error; + echo __('There was a problem creating agent_keepalive module'); } else { echo "

".__('Agent successfully created')."

"; } @@ -290,11 +294,12 @@ if (isset($_GET["delete_alert_comp"])) { // if modified some parameter // Combined ALERT - Add component // ================================ -if (isset($_POST["add_alert_combined"])){ // Update an existing alert - $alerta_id_aam = get_parameter ("update_alert",-1); - $component_item = get_parameter ("component_item",-1); - $component_operation = get_parameter ("component_operation","AND"); - $sql = sprintf ("INSERT INTO tcompound_alert (id, id_aam, operation) VALUES (%d, %d, '%s')", $alerta_id_aam, $component_item, $component_operation); +if (isset($_POST["add_alert_combined"])) { // Update an existing alert + $alerta_id_aam = get_parameter ('update_alert', -1); + $component_item = get_parameter ('component_item', -1); + $component_operation = get_parameter ('component_operation', 'AND'); + $sql = sprintf ("INSERT INTO tcompound_alert (id, id_aam, operation) VALUES (%d, %d, '%s')", + $alerta_id_aam, $component_item, $component_operation); $result = process_sql ($sql); if ($result === false) { echo '

'.__('There was a problem creating the combined alert').'

'; @@ -376,9 +381,9 @@ if ((isset($agent_created_ok)) && ($agent_created_ok == 1)){ // Read agent data // This should be at the end of all operation checks, to read the changess -if (isset($_GET["id_agente"])) { +if (isset($_REQUEST["id_agente"])) { //This has been done in the beginning of the page, but if an agent was created, this id might change - $id_agente = get_parameter_get ("id_agente"); + $id_agente = (int) get_parameter ('id_agente'); $id_grupo = dame_id_grupo ($id_agente); if (give_acl ($config["id_user"], $id_grupo, "AW") != 1) { audit_db($config["id_user"],$REMOTE_ADDR, "ACL Violation","Trying to admin an agent without access"); @@ -390,10 +395,7 @@ if (isset($_GET["id_agente"])) { if (empty ($agent)) { //Close out the page echo '

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

'; - echo '"; - exit; + return; } $intervalo = $agent["intervalo"]; // Define interval in seconds @@ -413,194 +415,140 @@ if (isset($_GET["id_agente"])) { $custom_id = $agent["custom_id"]; } -// Read data module if editing module -// ================================== -if ((isset ($_GET["update_module"])) && (!isset ($_POST["oid"])) && (!isset ($_POST["update_module"]))) { - $update_module = 1; - $id_agente_modulo = (int) get_parameter_get ("update_module",0); - - $module = get_db_row ('tagente_modulo', 'id_agente_modulo', $id_agente_modulo); - - if ($module === false) { - echo '

'.__('There was a problem loading the module').'

'; - } else { - $modulo_id_agente = $module["id_agente"]; - $modulo_id_tipo_modulo = $module["id_tipo_modulo"]; - $modulo_nombre = $module["nombre"]; - $modulo_descripcion = $module["descripcion"]; - $tcp_send = $module["tcp_send"]; - $tcp_rcv = $module["tcp_rcv"]; - $ip_target = $module["ip_target"]; - $snmp_community = $module["snmp_community"]; - $snmp_oid = $module["snmp_oid"]; - $id_module_group = $module["id_module_group"]; - $module_interval = $module["module_interval"]; - $modulo_max = $module["max"]; - if (empty ($modulo_max)) - $modulo_max = "N/A"; - if (empty ($modulo_min)) - $modulo_min = "N/A"; - $custom_id = $module["custom_id"]; - } -} +$update_module = (bool) get_parameter ('update_module'); +$create_module = (bool) get_parameter ('create_module'); +$edit_module = (bool) get_parameter ('edit_module'); // GET DATA for MODULE UPDATE OR MODULE INSERT -// =========================================== -if ((isset ($_POST["update_module"])) || (isset ($_POST["insert_module"]))) { - if (isset ($_POST["update_module"])) { - $update_module = 1; - $id_agente_modulo = get_parameter_post ("id_agente_modulo",0); - } - +if ($update_module || $create_module) { $id_grupo = dame_id_grupo ($id_agente); - if (give_acl ($config["id_user"], $id_grupo, "AW") == 0) { - audit_db ($config["id_user"],$REMOTE_ADDR, "ACL Violation","Trying to create a module without admin rights"); + if (! give_acl ($config["id_user"], $id_grupo, "AW")) { + audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation", + "Trying to create a module without admin rights"); require ("general/noaccess.php"); exit; } - $form_id_tipo_modulo = (int) get_parameter ("form_id_tipo_modulo",0); - $form_name = (string) get_parameter ("form_name",0); - $form_description = (string) get_parameter ("form_description",""); - $form_id_module_group = (int) get_parameter ("form_id_module_group",0); - $form_flag = (bool) get_parameter ("form_flag",0); - $form_post_process = (float) get_parameter ("form_post_process",0); - $form_prediction_module = (int) get_parameter ("form_prediction_module",0); - $form_max_timeout = (int) get_parameter ("form_max_timeout",0); - $form_minvalue = (int) get_parameter_post ("form_minvalue",0); - $form_maxvalue = (int) get_parameter ("form_maxvalue",0); - $form_interval = (int) get_parameter ("form_interval",300); - $form_id_prediction_module = (int) get_parameter ("form_id_prediction_module",0); - $form_id_plugin = (int) get_parameter ("form_id_plugin",0); - $form_id_export = (int) get_parameter ("form_id_export",0); - $form_disabled = (bool) get_parameter ("form_disabled",0); - $form_tcp_send = (string) get_parameter ("form_tcp_send",""); - $form_tcp_rcv = (string) get_parameter ("form_tcp_rcv",""); - $form_tcp_port = (int) get_parameter ("form_tcp_port",0); - $form_snmp_community = (string) get_parameter ("form_snmp_community",""); - $form_snmp_oid = (string) get_parameter ("form_snmp_oid",""); - $form_ip_target = (string) get_parameter ("form_ip_target",""); - $form_plugin_user = (string) get_parameter ("form_plugin_user",""); - $form_plugin_pass = (string) get_parameter ("form_plugin_pass",""); - $form_plugin_parameter = (string) get_parameter ("form_plugin_parameter",""); - $form_id_modulo = (int) get_parameter ("form_id_modulo",0); - $form_custom_id = (string) get_parameter ("form_custom_id",""); - $form_history_data = (int) get_parameter('form_history_data',0); - $form_min_warning = (float) get_parameter ('form_min_warning', 0); - $form_max_warning = (float) get_parameter ('form_max_warning', 0); - $form_min_critical = (float) get_parameter ('form_min_critical', 0); - $form_max_critical = (float) get_parameter ('form_max_critical', 0); - $form_ff_event = (int) get_parameter ('form_ff_event', 0); + $id_module_type = (int) get_parameter ('id_module_type'); + $name = (string) get_parameter ('name'); + $description = (string) get_parameter ('description'); + $id_module_group = (int) get_parameter ('id_module_group'); + $flag = (bool) get_parameter ('flag'); + $post_process = (float) get_parameter ('post_process'); + $prediction_module = (int) get_parameter ('prediction_module'); + $max_timeout = (int) get_parameter ('max_timeout'); + $minvalue = (int) get_parameter_post ("minvalue"); + $maxvalue = (int) get_parameter ('maxvalue'); + $interval = (int) get_parameter ("interval", 300); + $id_prediction_module = (int) get_parameter ('id_prediction_module'); + $id_plugin = (int) get_parameter ('id_plugin'); + $id_export = (int) get_parameter ('id_export'); + $disabled = (bool) get_parameter ('disabled'); + $tcp_send = (string) get_parameter ('tcp_send'); + $tcp_rcv = (string) get_parameter ('tcp_rcv'); + $tcp_port = (int) get_parameter ('tcp_port'); + $snmp_community = (string) get_parameter ('snmp_community'); + $snmp_oid = (string) get_parameter ('snmp_oid'); + if (empty ($snmp_oid)) { + /* The user did not set any OID manually but did a SNMP walk */ + $snmp_oid = (string) get_parameter ('select_snmp_oid'); + } + $ip_target = (string) get_parameter ('ip_target'); + $plugin_user = (string) get_parameter ('plugin_user'); + $plugin_pass = (string) get_parameter ('plugin_pass'); + $plugin_parameter = (string) get_parameter ('plugin_parameter'); + $custom_id = (string) get_parameter ('custom_id'); + $history_data = (int) get_parameter('history_data'); + $min_warning = (float) get_parameter ('min_warning'); + $max_warning = (float) get_parameter ('max_warning'); + $min_critical = (float) get_parameter ('min_critical'); + $max_critical = (float) get_parameter ('max_critical'); + $ff_event = (int) get_parameter ('ff_event'); } // MODULE UPDATE -// ================= -if ((isset ($_POST["update_module"])) && (!isset ($_POST["oid"]))) { // if modified something - if (isset ($_POST["form_combo_snmp_oid"])) { - $form_combo_snmp_oid = get_parameter_post ("form_combo_snmp_oid"); - if ($snmp_oid == "") { - $snmp_oid = $form_combo_snmp_oid; - } - } +if ($update_module) { + $id_agent_module = (int) get_parameter ('id_agent_module'); - $sql = sprintf ("UPDATE tagente_modulo SET - descripcion = '%s', - id_module_group = %d, - nombre = '%s', - max = %d, - min = %d, - module_interval = %d, - tcp_port = %d, - tcp_send = '%s', - tcp_rcv = '%s', - snmp_community = '%s', - snmp_oid = '%s', - ip_target = '%s', - flag = %d, - id_modulo = %d, - disabled = %d, - id_export = %d, - plugin_user = '%s', - plugin_pass = '%s', - plugin_parameter = '%s', - id_plugin = %d, - post_process = %f, - prediction_module = %d, - max_timeout = %d, - custom_id = '%s', - history_data = %d, - min_warning = %f, - max_warning = %f, - min_critical = %f, - max_critical = %f, - min_ff_event = %d - WHERE id_agente_modulo = %d", $form_description, $form_id_module_group, $form_name, $form_maxvalue, $form_minvalue, $form_interval, $form_tcp_port, $form_tcp_send, $form_tcp_rcv, - $form_snmp_community, $form_snmp_oid, $form_ip_target, $form_flag, $form_id_modulo, $form_disabled, $form_id_export, $form_plugin_user, $form_plugin_pass, - $form_plugin_parameter, $form_id_plugin, $form_post_process, $form_prediction_module, $form_max_timeout, $form_custom_id, $form_history_data, $form_min_warning, $form_max_warning, $form_min_critical, $form_max_critical, $form_ff_event, $id_agente_modulo); + process_sql_update ('tagente_modulo', + array ('descripcion' => $description, + 'id_module_group' => $id_module_group, 'nombre' => $name, + 'max' => $maxvalue, 'min' => $minvalue, 'module_interval' => $interval, + 'tcp_port' => $tcp_port, 'tcp_send' => $tcp_send, + 'tcp_rcv' => $tcp_rcv, 'snmp_community' => $snmp_community, + 'snmp_oid' => $snmp_oid, 'ip_target' => $ip_target, + 'flag' => $flag, 'disabled' => $disabled, + 'id_export' => $id_export, 'plugin_user' => $plugin_user, + 'plugin_pass' => $plugin_pass, 'plugin_parameter' => $plugin_parameter, + 'id_plugin' => $id_plugin, 'post_process' => $post_process, + 'prediction_module' => $prediction_module, + 'max_timeout' => $max_timeout, 'custom_id' => $custom_id, + 'history_data' => $history_data, + 'min_warning' => $min_warning, 'max_warning' => $max_warning, + 'min_critical' => $min_critical, 'max_critical' => $max_critical, + 'min_ff_event' => $ff_event + ), + 'id_agente_modulo = '.$id_agent_module); $result = process_sql ($sql); if ($result === false) { echo '

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

'; } else { echo '

'.__('Module successfully updated').'

'; - } - -} -// ========================================================= -// OID Refresh button to get SNMPWALK from data in form -// This code is also applied when submitting a new module (insert_module = 1) -// ========================================================= -if (isset ($_POST["oid"])){ - snmp_set_quick_print (1); - $snmpwalk = snmprealwalk ($form_ip_target, $form_snmp_community, ''); - - if (empty ($snmpwalk)) { - echo '

'.__('Cannot read from SNMP source').'

'; - } else { - echo '

'.__('SNMP source has been scanned').'

'; + $id_agent_module = false; + $edit_module = false; } } - -// ========================================================= // MODULE INSERT -// ========================================================= - -if (((!isset ($_POST["nc"]) OR ($_POST["nc"] == -1))) && (!isset ($_POST["oid"])) && (isset ($_POST["insert_module"])) && (isset ($_POST['crtbutton']))) { - - if (isset ($_POST["form_combo_snmp_oid"])) { - $combo_snmp_oid = get_parameter_post ("form_combo_snmp_oid"); +if ($create_module) { + if (isset ($_POST["combo_snmp_oid"])) { + $combo_snmp_oid = get_parameter_post ("combo_snmp_oid"); } - if ($form_snmp_oid == ""){ - $form_snmp_oid = $combo_snmp_oid; + if ($snmp_oid == ""){ + $snmp_oid = $combo_snmp_oid; } - if ($form_tcp_port == "") { - $form_tcp_port= "0"; - } - $sql = sprintf ("INSERT INTO tagente_modulo - (id_agente, id_tipo_modulo, nombre, descripcion, max, min, snmp_oid, snmp_community, - id_module_group, module_interval, ip_target, tcp_port, tcp_rcv, tcp_send, id_export, - plugin_user, plugin_pass, plugin_parameter, id_plugin, post_process, prediction_module, - max_timeout, disabled, id_modulo, custom_id, history_data, min_warning, max_warning, min_critical, max_critical, min_ff_event) - VALUES (%d,%d,'%s','%s',%d,%d,'%s','%s',%d,%d,'%s',%d,'%s','%s',%d,'%s','%s','%s',%d,%d,%d,%d,%d,%d,'%s', %d, %f, %f, %f, %f, %d)", - $id_agente, $form_id_tipo_modulo, $form_name, $form_description, $form_maxvalue, $form_minvalue, $form_snmp_oid, $form_snmp_community, - $form_id_module_group, $form_interval, $form_ip_target, $form_tcp_port, $form_tcp_rcv, $form_tcp_send, $form_id_export, $form_plugin_user, $form_plugin_pass, - $form_plugin_parameter, $form_id_plugin, $form_post_process, $form_id_prediction_module, $form_max_timeout, $form_disabled, $form_id_modulo, $form_custom_id, $form_history_data, $form_min_warning, $form_max_warning, $form_min_critical, $form_max_critical, $form_ff_event); - $id_agente_modulo = process_sql ($sql, 'insert_id'); - - if ($id_agente_modulo === false){ + + $id_module = (int) get_parameter ('id_module'); + + $id_agent_module = process_sql_insert ('tagente_modulo', + array ('id_agente' => $id_agente, + 'id_tipo_modulo' => $id_module_type, + 'nombre' => $name, 'descripcion' => $description, 'max' => $maxvalue, + 'min' => $minvalue, 'snmp_oid' => $snmp_oid, + 'snmp_community' => $snmp_community, + 'id_module_group' => $id_module_group, 'module_interval' => $interval, + 'ip_target' => $ip_target, 'tcp_port' => $tcp_port, + 'tcp_rcv' => $tcp_rcv, 'tcp_send' => $tcp_send, + 'id_export' => $id_export, 'plugin_user' => $plugin_user, + 'plugin_pass' => $plugin_pass, 'plugin_parameter' => $plugin_parameter, + 'id_plugin' => $id_plugin, 'post_process' => $post_process, + 'prediction_module' => $id_prediction_module, + 'max_timeout' => $max_timeout, 'disabled' => $disabled, + 'id_modulo' => $id_module, 'custom_id' => $custom_id, + 'history_data' => $history_data, 'min_warning' => $min_warning, + 'max_warning' => $max_warning, 'min_critical' => $min_critical, + 'max_critical' => $max_critical, 'min_ff_event' => $ff_event + )); + + if ($id_agent_module === false) { echo '

'.__('There was a problem adding module').'

'; + $edit_module = true; } else { - $sql = sprintf ("INSERT INTO tagente_estado - (id_agente_modulo,datos,timestamp,estado,id_agente, utimestamp, status_changes, last_status) - VALUES (%d, 0,'0000-00-00 00:00:00',0,%d,0,0,0)",$id_agente_modulo,$id_agente); - - $result = process_sql ($sql); + $result = process_sql_insert ('tagente_estado', + array ('id_agente_modulo' => $id_agent_module, + 'datos' => 0, 'timestamp' => '0000-00-00 00:00:00', + 'estado' => 0, 'id_agente' => $id_agente, + 'utimestamp' => 0, 'status_changes' => 0, + 'last_status' => 0 + )); if ($result !== false) { echo '

'.__('Module added successfully').'

'; } else { echo '

'.__('Module added successfully').' - '.__('Status init unsuccessful').'

'; } + $id_agent_module = false; + $edit_module = false; } } @@ -610,7 +558,7 @@ if (isset ($_GET["delete_module"])){ // DELETE agent module ! $id_borrar_modulo = (int) get_parameter_get ("delete_module",0); $id_grupo = (int) dame_id_grupo ($id_agente); - if (give_acl ($config["id_user"], $id_grupo, "AW") == 0){ + if (! give_acl ($config["id_user"], $id_grupo, "AW")) { audit_db($config["id_user"],$REMOTE_ADDR, "ACL Violation", "Trying to delete a module without admin rights"); require ("general/noaccess.php"); @@ -657,16 +605,15 @@ if (isset ($_GET["delete_module"])){ // DELETE agent module ! // ----------------------------------- // Load page depending on tab selected // ----------------------------------- - switch ($tab) { case "main": require ("agent_manager.php"); break; case "module": - if (($form_moduletype == "") && ($moduletype == "")) { - require ("module_manager.php"); - } else { + if ($id_agent_module || $edit_module) { require ("module_manager_editor.php"); + } else { + require ("module_manager.php"); } break; case "alert": diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 79adc7f562..b31a4b8963 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -31,7 +31,6 @@ echo "

".__('Agent configuration')." > ".__('Modules')."

"; echo ''; echo ''; echo ""; +$servers = array (); +$servers['dataserver'] = __('Create a new data server module'); +if ($network_available) + $servers['networkserver'] = __('Create a new network server module'); +if ($plugin_available) + $servers['pluginserver'] = __('Create a new plugin Server module'); +if ($wmi_available) + $servers['wmiserver'] = __('Create a new WMI Server module'); +if ($prediction_available) + $servers['predictionserver'] = __('Create a new prediction Server module'); +print_select ($servers, 'moduletype', '', '', '', '', false, false, false); +print_input_hidden ('edit_module', 1); +echo ''; echo '
"; -echo ''; echo ''; echo ""; @@ -69,7 +71,7 @@ echo "
"; echo "

".__('Assigned modules')."

"; $sql1='SELECT * FROM tagente_modulo WHERE delete_pending = 0 AND id_agente = "'.$id_agente.'" -ORDER BY id_module_group, nombre '; + ORDER BY id_module_group, nombre '; $result=mysql_query($sql1); if ($row=mysql_num_rows($result)){ echo ''; @@ -147,8 +149,8 @@ if ($row=mysql_num_rows($result)){ echo ""; echo " "; // Update module - echo ""; - echo ""; + echo ""; + echo ""; // Make a data normalization if (($id_tipo == 22) OR ($id_tipo == 1) OR ($id_tipo == 4) OR ($id_tipo == 7) OR diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 864091efce..ebad84feb4 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -16,140 +16,356 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +if (defined ('AJAX')) { + $get_network_component = (bool) get_parameter ('get_network_component'); + $snmp_walk = (bool) get_parameter ('snmp_walk'); + $get_module_component = (bool) get_parameter ('get_module_component'); + + if ($get_module_component) { + $id_component = (int) get_parameter ('id_module_component'); + + $component = get_db_row ('tnetwork_component', 'id_nc', $id_component); + + echo json_encode ($component); + return; + } + + if ($snmp_walk) { + $ip_target = (string) get_parameter ('ip_target'); + $snmp_community = (string) get_parameter ('snmp_community'); + + snmp_set_quick_print (1); + $snmpwalk = snmprealwalk ($ip_target, $snmp_community, NULL); + if ($snmpwalk === false) { + echo json_encode ($snmpwalk); + return; + } + + $result = array (); + foreach ($snmpwalk as $id => $value) { + $value = substr ($id, 0, 35)." - ".substr ($value, 0, 20); + $result[$id] = substr ($value, 0, 55); + } + asort ($result); + echo json_encode ($result); + return; + } + + return; +} + if (!isset ($id_agente)) { die ("Not Authorized"); } require_once ("include/functions_exportserver.php"); -// Following variables come from module_manager.php -> configurar_agente.php : -// -// $form_moduletype: could be [1] Agent module/Data server, [2] network server, [4] plugin server, [6] wmiserver, or [5] predictionserver -// $moduletype: helper to fix get/post method; copy of $form_moduletype just to edit modules, not to create them - -if (($form_moduletype == "") && ($moduletype != "")) { - switch ($moduletype) { - case "1": - $form_moduletype = "dataserver"; - break; - case "2": - $form_moduletype = "networkserver"; - break; - case "4": - $form_moduletype = "pluginserver"; - break; - case "5": - $form_moduletype = "predictionserver"; - break; - case "6": - $form_moduletype = "wmiserver"; - break; - //This will make sure that blank pages will - //have at least some debug info in them - default: - echo '

DEBUG: Invalid module type specified in '.__FILE__.':'.__LINE__.'

'; - echo 'Most likely you have recently upgraded from an earlier version of Pandora and either
- 1) forgot to use the database converter
- 2) used a bad version of the database converter (see Bugreport #2124706 for the solution)
- 3) found a new bug - please report a way to duplicate this error'; - return; //We return control to the invoking script so the page finishes rendering - } -} - -// Get form -$form_network_component = get_parameter ("form_network_component", ""); - // Using network component to fill some fields -if (($form_moduletype == "networkserver" || $form_moduletype == "wmiserver") && ($form_network_component != "") && (!isset($_POST['crtbutton'])) && (!isset($_POST['oid']))) { - // Preload data from template - $row = get_db_row ("tnetwork_component", 'id_nc', $form_network_component); - if (empty ($row)) - unmanaged_error ("Cannot load tnetwork_component reference from previous page"); - - $form_id_tipo_modulo = $row["type"]; - $form_id_module_group = $row["id_module_group"]; - $form_name = $row["name"]; - $form_descripcion = $row["description"]; - $form_tcp_send = $row["tcp_send"]; - $form_tcp_rcv = $row["tcp_rcv"]; - $form_tcp_port = $row["tcp_port"]; - $form_snmp_community = $row["snmp_community"]; - $form_snmp_oid = $row["snmp_oid"]; - $form_id_module_group = $row["id_module_group"]; - $form_interval = $row["module_interval"]; - $form_maxvalue = $row["max"]; - $form_minvalue = $row["min"]; - $form_max_timeout = $row["max_timeout"]; - $form_id_export = 0; - $form_disabled = 0; - $form_plugin_user = $row["plugin_user"]; - $form_plugin_pass = $row["plugin_pass"]; - $form_plugin_parameter = $row["plugin_parameter"]; - $form_prediction_module = ""; - $form_id_plugin = ""; - $form_post_process = ""; - $form_custom_id = ""; - -} elseif (!isset($_POST['oid'])) { - // Clean up specific network modules fields - $form_name = ""; - $form_description = ""; - $form_id_module_group = 1; - $form_id_tipo_modulo = 1; - $form_post_process = ""; - $form_max_timeout = ""; - $form_minvalue = ""; - $form_maxvalue = ""; - $form_interval = ""; - $form_prediction_module = ""; - $form_id_plugin = ""; - $form_id_export = ""; - $form_disabled= "0"; - $form_tcp_send = ""; - $form_tcp_rcv = ""; - $form_tcp_port = ""; +if ($id_agent_module) { + $module = get_agent_module ($id_agent_module); + $moduletype = $module['id_modulo']; + $name = $module['nombre']; + $description = $module['descripcion']; + $id_module_group = $module['id_module_group']; + $id_module_type = $module['id_tipo_modulo']; + $max = $module['max']; + $min = $module['min']; + $interval = $module['module_interval']; + if ($interval == 0) { + $interval = get_agent_interval ($id_agente); + } + $tcp_port = $module['tcp_port']; + $tcp_send = $module['tcp_send']; + $tcp_rcv = $module['tcp_rcv']; + $snmp_community = $module['snmp_community']; + $snmp_oid = $module['snmp_oid']; + $ip_target = $module['ip_target']; + if (empty ($ip_target)) { + $ip_target = get_agent_address ($id_agente); + } + $disabled = $module['disabled']; + $id_export = $module['id_export']; + $plugin_user = $module['plugin_user']; + $plugin_pass = $module['plugin_pass']; + $plugin_parameter = $module['plugin_parameter']; + $id_plugin = $module['id_plugin']; + $post_process = $module['post_process']; + $prediction_module = $module['prediction_module']; + $max_timeout = $module['max_timeout']; + $custom_id = $module['custom_id']; + $history_data = $module['history_data']; + $min_warning = $module['min_warning']; + $max_warning = $module['max_warning']; + $min_critical = $module['min_critical']; + $max_critical = $module['max_critical']; + $ff_event = $module['min_ff_event']; +} else { + $moduletype = (string) get_parameter ('moduletype'); - if ($form_moduletype == "wmiserver") - $form_snmp_community = ""; + // Clean up specific network modules fields + $name = ''; + $description = ''; + $id_module_group = 1; + $id_module_type = 1; + $post_process = ''; + $max_timeout = ''; + $min = ''; + $max = ''; + $interval = ''; + $prediction_module = ''; + $id_plugin = ''; + $id_export = ''; + $disabled = "0"; + $tcp_send = ''; + $tcp_rcv = ''; + $tcp_port = ''; + + if ($moduletype == "wmiserver") + $snmp_community = ''; else - $form_snmp_community = "public"; - $form_snmp_oid = ""; - $form_ip_target = $direccion_agente; // taken from configurar_agente.php - $form_plugin_user = ""; - $form_plugin_pass = ""; - $form_plugin_parameter = ""; - $form_custom_id = ""; - $form_history_data = 1; - $form_min_warning = 0; - $form_max_warning = 0; - $form_min_critical = 0; - $form_max_critical = 0; - $form_ff_event = 0; + $snmp_community = "public"; + $snmp_oid = ''; + $ip_target = get_agent_address ($id_agente); + $plugin_user = ''; + $plugin_pass = ''; + $plugin_parameter = ''; + $custom_id = ''; + $history_data = 1; + $min_warning = 0; + $max_warning = 0; + $min_critical = 0; + $max_critical = 0; + $ff_event = 0; } -switch ($form_moduletype) { - case "dataserver": - include $config["homedir"]."/godmode/agentes/module_manager_editor_data.php"; - break; - case "networkserver": - include $config["homedir"]."/godmode/agentes/module_manager_editor_network.php"; - break; - case "pluginserver": - include $config["homedir"]."/godmode/agentes/module_manager_editor_plugin.php"; - break; - case "predictionserver": - include $config["homedir"]."/godmode/agentes/module_manager_editor_prediction.php"; - break; - case "wmiserver": - include $config["homedir"]."/godmode/agentes/module_manager_editor_wmi.php"; - break; - default: - echo '

DEBUG: Invalid module type specified in '.__FILE__.':'.__LINE__.'

'; - echo 'Most likely you have recently upgraded from an earlier version of Pandora and either
- 1) forgot to use the database converter
- 2) used a bad version of the database converter (see Bugreport #2124706 for the solution)
- 3) found a new bug - please report a way to duplicate this error'; - return; - +switch ($moduletype) { +case "dataserver": + $moduletype = 1; +case 1: + require ('module_manager_editor_common.php'); + require ('module_manager_editor_data.php'); + break; +case "networkserver": + $moduletype = 2; +case 2: + require ('module_manager_editor_common.php'); + require ('module_manager_editor_network.php'); + break; +case "pluginserver": + $moduletype = 3; +case 3: + require ('module_manager_editor_common.php'); + require ('module_manager_editor_plugin.php'); + break; +case "predictionserver": + $moduletype = 4; +case 4: + require ('module_manager_editor_common.php'); + require ('module_manager_editor_prediction.php'); + break; +case "wmiserver": + $moduletype = 5; +case 5: + require ('module_manager_editor_common.php'); + require ('module_manager_editor_wmi.php'); + break; +default: + echo '

DEBUG: Invalid module type specified in '.__FILE__.':'.__LINE__.'

'; + echo 'Most likely you have recently upgraded from an earlier version of Pandora and either
+ 1) forgot to use the database converter
+ 2) used a bad version of the database converter (see Bugreport #2124706 for the solution)
+ 3) found a new bug - please report a way to duplicate this error'; + return; //We return control to the invoking script so the page finishes rendering } + +echo '

'.__('Module assignment'); +if (isset ($extra_title)) + echo ' - '.$extra_title; +echo '

'; + +echo ''; + +echo ''; +print_table ($table_simple); + +echo ''.__('Advanced options').' » '; + +echo ''; + +// Submit +echo '
'; +if ($id_agent_module) { + print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"'); + print_input_hidden ('update_module', 1); + print_input_hidden ('id_agent_module', $id_agent_module); +} else { + print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"'); + print_input_hidden ('id_module', $moduletype); + print_input_hidden ('create_module', 1); +} +echo '
'; +echo ''; ?> + + + + + diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php new file mode 100644 index 0000000000..f7f228ac8d --- /dev/null +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -0,0 +1,182 @@ + $row); + else + $data = array ($row); + + $table_simple->data = array_merge ($data, $table_simple->data); +} + +function push_table_simple ($row, $id = false) { + global $table_simple; + + if ($id) + $data = array ($id => $row); + else + $data = array ($row); + + $table_simple->data = array_merge ($table_simple->data, $data); +} + +function prepend_table_advanced ($row, $id = false) { + global $table_advanced; + + if ($id) + $data = array ($id => $row); + else + $data = array ($row); + + $table_advanced->data = array_merge ($data, $table_advanced->data); +} + +function push_table_advanced ($row, $id = false) { + global $table_advanced; + + if ($id) + $data = array ($id => $row); + else + $data = array ($row); + + $table_advanced->data = array_merge ($table_advanced->data, $data); +} + +$update_module_id = (int) get_parameter_get ('update_module'); + +$table_simple->id = 'simple'; +$table_simple->width = '90%'; +$table_simple->class = 'databox_color'; +$table_simple->data = array (); +$table_simple->colspan = array (); +$table_simple->style = array (); +$table_simple->style[0] = 'font-weight: bold'; +$table_simple->style[2] = 'font-weight: bold'; + +$table_simple->data[0][0] = __('Name'); +$table_simple->data[0][1] = print_input_text ('name', $name, '', 20, 100, true); +$table_simple->data[0][2] = __('Disabled'); +$table_simple->data[0][3] = print_checkbox ("disabled", 1, $disabled, true); + +$table_simple->data[1][0] = __('Type').' '.pandora_help ('module_type', true); +if ($id_agent_module) { + $table_simple->data[1][1] = ''.get_moduletype_description ($id_module_type).''; +} else { + switch ($moduletype) { + case 1: + case "dataserver": + $categories = array (0, 1, 2, 6, 7, 8, 9, -1); + break; + case 2: + case "networkserver": + $categories = array (3, 4, 5); + break; + case 3: + case "pluginserver": + $categories = array (0, 1, 2, 9); + break; + case 4: + case "predictionserver": + $categories = array (1, 2); + break; + case 5: + case "wmiserver": + $categories = array (0, 1, 2); + break; + } + + $sql = sprintf ('SELECT id_tipo, descripcion + FROM ttipo_modulo + WHERE categoria IN (%s) + ORDER BY descripcion', + implode (',', $categories)); + $table_simple->data[1][1] = print_select_from_sql ($sql, 'id_module_type', + '', '', '', '', true, false, false); +} + +$table_simple->data[1][2] = __('Module group'); +$table_simple->data[1][3] = print_select_from_sql ('SELECT id_mg, name FROM tmodule_group ORDER BY name', + 'id_module_group', $id_module_group, '', __('Not assigned'), '0', + true); + +$table_simple->data[2][0] = __('Warning status'); +$table_simple->data[2][1] = ''.__('Min.').''; +$table_simple->data[2][1] .= print_input_text ('min_warning', $min_warning, + '', 5, 15, true); +$table_simple->data[2][1] .= '
'.__('Max.').''; +$table_simple->data[2][1] .= print_input_text ('max_warning', $max_warning, + '', 5, 15, true); +$table_simple->data[2][2] = __('Critical status'); +$table_simple->data[2][3] = ''.__('Min.').''; +$table_simple->data[2][3] .= print_input_text ('min_critical', $min_critical, + '', 5, 15, true); +$table_simple->data[2][3] .= '
'.__('Max.').''; +$table_simple->data[2][3] .= print_input_text ('max_critical', $max_critical, + '', 5, 15, true); + +/* FF stands for Flip-flop */ +$table_simple->data[3][0] = __('FF threshold').' '.pandora_help ('ff_threshold', true); +$table_simple->data[3][1] = print_input_text ('ff_event', $ff_event, + '', 5, 15, true); +$table_simple->data[3][2] = __('Historical data'); +$table_simple->data[3][3] = print_checkbox ("history_data", 1, $history_data, true); + +/* Advanced form part */ +$table_advanced->id = 'advanced'; +$table_advanced->width = '90%'; +$table_advanced->class = 'databox_color'; +$table_advanced->data = array (); +$table_advanced->style = array (); +$table_advanced->style[0] = 'font-weight: bold'; +$table_advanced->style[2] = 'font-weight: bold'; +$table_advanced->colspan = array (); + +$table_advanced->data[0][0] = __('Description'); +$table_advanced->colspan[0][1] = 3; +$table_advanced->data[0][1] = print_textarea ('description', 2, 65, + $description, '', true); + +$table_advanced->data[1][0] = __('Custom ID'); +$table_advanced->data[1][1] = print_input_text ('custom_id', $custom_id, + '', 20, 65, true); + +$table_advanced->data[2][0] = __('Interval'); +$table_advanced->data[2][1] = print_input_text ('module_interval', $interval, + '', 5, 10, true); + +$table_advanced->data[2][2] = __('Post process').' '.pandora_help ('postprocess', true); +$table_advanced->data[2][3] = print_input_text ('post_process', + $post_process, '', 5, 5, true); + +$table_advanced->data[3][0] = __('Min. value'); +$table_advanced->data[3][1] = print_input_text ('min', $min, '', 5, 15, true); +$table_advanced->data[3][2] = __('Max. value'); +$table_advanced->data[3][3] = print_input_text ('max', $max, '', 5, 15, true); + +$table_advanced->data[4][0] = __('Export target'); +$table_advanced->data[4][1] = print_select_from_sql ('SELECT id, name FROM tserver_export ORDER BY name', + 'id_export', $id_export, '',__('None'),'0', true, false, false); +$table_advanced->colspan[4][1] = 3; +?> diff --git a/pandora_console/godmode/agentes/module_manager_editor_data.php b/pandora_console/godmode/agentes/module_manager_editor_data.php index 87e74ce1ef..f53259e7bf 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_data.php +++ b/pandora_console/godmode/agentes/module_manager_editor_data.php @@ -21,219 +21,7 @@ if (!isset ($id_agente)) { die ("Not Authorized"); } -// get the variable form_moduletype -$form_moduletype = get_parameter_post ("form_moduletype"); -// get the module to update -$update_module_id = get_parameter_get ("update_module",NULL); -// the variable that checks whether the module is disabled or not must be setcommitedversion -$disabled_status = false; +$extra_title = __('Data server module'); -// Specific ACL check -if (give_acl ($config["id_user"], 0, "AW")!=1) { - audit_db ($config["id_user"], $REMOTE_ADDR, "ACL Violation","Trying to access agent manager"); - require ($config["homedir"]."/general/noaccess.php"); - exit; -} - -// Check whether we are updataing and get data if so -if ($update_module_id != NULL){ - $row = get_db_row ("tagente_modulo", 'id_agente_modulo', $update_module_id); - if (empty ($row)) - unmanaged_error("Cannot load tnetwork_component reference from previous page"); - - $id_agente = $row['id_agente']; - $form_id_tipo_modulo = $row['id_tipo_modulo']; // It doesn't matter - $form_description = $row['descripcion']; - $form_name = $row['nombre']; - $form_minvalue = $row['min']; - $form_maxvalue = $row['max']; - $form_interval = $row['module_interval']; - $form_tcp_port = $row['tcp_port']; - $form_tcp_send = $row['tcp_send']; - $form_tcp_rcv = $row['tcp_rcv']; - $form_snmp_community = $row['snmp_community']; - $form_snmp_oid = $row['snmp_oid']; - $form_ip_target = $row['ip_target']; - $form_id_module_group = $row['id_module_group']; - $form_flag = $row['flag']; - $tbl_id_modulo = $row['id_modulo']; // It doesn't matter - $tbl_disabled = $row['disabled']; - $form_id_export = $row['id_export']; - $form_plugin_user = $row['plugin_user']; - $form_plugin_pass = $row['plugin_pass']; - $form_plugin_parameter = $row['plugin_parameter']; - $form_id_plugin = $row['id_plugin']; - $form_post_process = $row['post_process']; - $form_prediction_module = $row['prediction_module']; - $form_max_timeout = $row['max_timeout']; - $form_custom_id = $row['custom_id']; - $form_history_data = $row['history_data']; - $form_min_warning = $row['min_warning']; - $form_max_warning = $row['max_warning']; - $form_min_critical = $row['min_critical']; - $form_max_critical = $row['max_critical']; - $form_ff_event = $row['min_ff_event']; - - if ($tbl_disabled == 1) - $disabled_status = true; -} - -echo "

".__('Module assignment')." - ".__('Data server module')."

"; -echo ''; - -// Whether in update or insert mode -if ($update_module_id == NULL) { - print_input_hidden ("insert_module", 1); -} else { - print_input_hidden ("update_module", 1); -} - -//id_agente_module -print_input_hidden ("id_agente_modulo", $update_module_id); - -// id_modulo 1 - Dataserver -print_input_hidden ("form_id_modulo", 1); -echo '
'; -echo ''; - -// module type / max timeout -echo ''; - -// Post process / Export server -echo ''; -echo ''; -echo ''; - -// Max / min value -echo ''; -echo ''; -echo ''; -echo ''; - -// Interval & id_module_group -echo ''; -echo ''; -echo ''; -echo ''; -echo ''; - -// Max / min value -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo ''; - -// Warning value threshold -echo ''; -echo '"; -echo ''; - -// Critical value threshold -echo '"; -echo ''; -echo ''; - -// History data ? -echo ""; -echo '"; -echo ''; -echo ''; - - -// Description -echo ''; -echo '"; -echo ''; - -// Custom ID -echo ''; -echo '"; -echo ''; -echo ''; - -echo '
'. __('Module name').''; -print_input_text ("form_name", $form_name, '', 35); -echo ''. __('Disabled').''; -print_checkbox ("form_disabled", 1, $disabled_status); -echo '
'.__('Module type'); -pandora_help("module_type"); -echo ''; - -if ($update_module_id != NULL){ - //We don't pass it along as hidden anymore because the update query - //doesn't need that specific value to change. - echo 'Not available in edition mode'; -} else { - $sql = "SELECT id_tipo, nombre FROM ttipo_modulo WHERE categoria IN (0,1,2,6,7,8,9,-1) ORDER BY categoria, nombre"; - $result = get_db_all_rows_sql ($sql); //This database is always filled - - foreach ($result as $row) { - $fields[$row["id_tipo"]] = $row["nombre"]; - } - print_select ($fields, "form_id_tipo_modulo", '', '', '', '', false, false, false); -} -echo '
'.__('Post process'); -pandora_help("postprocess"); -echo ''; -print_input_text ("form_post_process",$form_post_process, '', 5); -// Export target is a server where the data will be sent -echo ''.__('Export target').''; - -$fields = array (); -$sql = "SELECT id, name FROM tserver_export ORDER BY name"; -$result = get_db_all_rows_sql ($sql); - -if ($result === false) - $result = array (); - -foreach ($result as $row) { - $fields[$row["id"]] = $row["name"]; -} - -print_select ($fields, "form_id_export", $form_id_export,'',__('None'),'0', false, false, false); - -echo '
'.__('Min. Value').''; -print_input_text ("form_minvalue",$form_minvalue,'',5); -echo ''.__('Max. Value').''; -print_input_text ("form_maxvalue",$form_maxvalue,'',5); -echo '
'.__('Interval').''.__('Module group').''; - -$fields = array (); -$sql = "SELECT id_mg, name FROM tmodule_group"; -$result = get_db_all_rows_sql ($sql); - -if ($result === false) - $result = array (); - -$fields[0] = __("Not assigned"); - -foreach ($result as $row) { - $fields[$row["id_mg"]] = $row["name"]; -} - - -print_select ($fields, "form_id_module_group", $form_id_module_group,'','','',false,false,false); -echo '
'.__('Min. Value')."'.__('Max. Value')."
'.__('Warning status')."'.__("Min.").' '; -echo ' '.__("Max.").' '.__('Critical status')."'.__("Min.").' '; -echo ' '.__("Max.").'
'.__('Historical data')."'; -print_checkbox ("form_history_data", 1, $form_history_data, false); - -//FF stands for Flip-Flop -echo ''.__('FF threshold'); -pandora_help ("ff_threshold"); -echo '
'.__('Description')."'; -print_textarea ("form_description", 2, 65, $form_description); -echo '
'.__('Custom ID')."
'; - -//Submit -echo ''; -echo '
'; -if ($update_module_id == NULL){ - print_submit_button (__('Create'), "crtbutton", false,'class="sub wand"'); -} else { - print_submit_button (__('Update'), "updbutton", false,'class="sub wand"'); -} -echo '
'; +/* No extra fields at this moment */ ?> diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index 2cc77bdeb8..7064ef783a 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -1,8 +1,9 @@ - +// Copyright (c) 2008 Esteban Sanchez // Please see http://pandora.sourceforge.net for full contribution list // This program is free software; you can redistribute it and/or @@ -22,313 +23,102 @@ if (!isset ($id_agente)) { die ("Not Authorized"); } -// get the variable form_moduletype -$form_moduletype = get_parameter_post ("form_moduletype"); -// get the module to update -$update_module_id = get_parameter_get ("update_module"); -// the variable that checks whether the module is disabled or not must be setcommitedversion -$disabled_status = NULL; +$extra_title = __('Network server module'); -// Specific ACL check -if (give_acl($config["id_user"], 0, "AW")!=1) { - audit_db($config["id_user"], $REMOTE_ADDR, "ACL Violation","Trying to access agent manager"); - require ($config["homedir"]."/general/noaccess.php"); - exit; -} +$data = array (); +$data[0] = __('Using module component').' '; +$data[0] .= pandora_help ('network_component', true); - -// Check whether we are updataing and get data if so -if ($update_module_id != NULL){ - $row = get_db_row ("tagente_modulo", 'id_agente_modulo', $update_module_id); - if ($row == 0){ - unmanaged_error("Cannot load tnetwork_component reference from previous page"); - } - else{ - $id_agente = $row['id_agente']; - $form_id_tipo_modulo = $row['id_tipo_modulo']; // It doesn't matter - $form_description = $row['descripcion']; - $form_name = $row['nombre']; - $form_minvalue = $row['min']; - $form_maxvalue = $row['max']; - $form_interval = $row['module_interval']; - $form_tcp_port = $row['tcp_port']; - $form_tcp_send = $row['tcp_send']; - $form_tcp_rcv = $row['tcp_rcv']; - $form_snmp_community = $row['snmp_community']; - $form_snmp_oid = $row['snmp_oid']; - $form_ip_target = $row['ip_target']; - $form_id_module_group = $row['id_module_group']; - $form_flag = $row['flag']; - $tbl_id_modulo = $row['id_modulo']; // It doesn't matter - $tbl_disabled = $row['disabled']; - $form_id_export = $row['id_export']; - $form_plugin_user = $row['plugin_user']; - $form_plugin_pass = $row['plugin_pass']; - $form_plugin_parameter = $row['plugin_parameter']; - $form_id_plugin = $row['id_plugin']; - $form_post_process = $row['post_process']; - $form_prediction_module = $row['prediction_module']; - $form_max_timeout = $row['max_timeout']; - $form_custom_id = $row['custom_id']; - $form_history_data = $row['history_data']; - $form_min_warning = $row['min_warning']; - $form_max_warning = $row['max_warning']; - $form_min_critical = $row['min_critical']; - $form_max_critical = $row['max_critical']; - $form_ff_event = $row['min_ff_event']; - if ($tbl_disabled == 1){ - $disabled_status = 'checked="ckecked"'; - } else { - $disabled_status = NULL; - } - } -} - -echo "

".__('Module assignment')." - ".__('Network server module')."

"; -echo ''; -// Create from Network Component -echo ''; -// Whether in update or insert mode -if ($update_module_id == NULL){ - echo ""; +if (empty ($update_module_id)) { + $data[1] = print_select_from_sql ('SELECT id_nc, name FROM tnetwork_component WHERE id_modulo = 2', + 'network_component', '', '', '---'.__('Manual setup').'---', 0, true); + $data[1] .= ' '; } else { - echo ""; + /* TODO: Print network component if available */ + $data[1] = 'TODO'; } +$table_simple->colspan['module_component'][1] = 3; +$table_simple->rowstyle['module_component'] = 'background-color: #D4DDC6'; -//id_agente_module -echo ""; +prepend_table_simple ($data, 'module_component'); -// id_modulo 2 - Network -echo ""; +$data = array (); +$data[0] = __('Target IP'); +$data[1] = print_input_text ('ip_target', $ip_target, '', 15, 60, true); +$data[2] = _('Port'); +$data[3] = print_input_text ('tcp_port', $tcp_port, '', 5, 20, true); -// Network component usage -echo "'; -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo ''; +push_table_simple ($data, 'snmp_1'); -// Ip target, tcp port -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo ''; +$data = array (); +$data[0] = __('SNMP OID'); +$data[1] = ''; +$data[1] .= print_input_text ('snmp_oid', $snmp_oid, '', 30, 120, true); +$data[1] .= ''; +$data[1] .= ''; +$data[1] .= ''; +$data[1] .= print_button (__('SNMP walk'), 'snmp_walk', $ip_target == '', '', + 'class="sub next"', true); +$data[1] .= pandora_help ('snmpwalk', true); +$data[1] .= ''; +$table_simple->colspan['snmp_2'][1] = 3; -// module type / max timeout -echo ''; -echo ''; +push_table_simple ($data, 'snmp_2'); -echo '"; -echo ''; - -// Interval & id_module_group -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo ''; -echo ''; -echo ''; -echo ''; -echo '"; -echo ''; -echo ''; - -// SNMP version -echo ''; -echo ''; -echo ''; -echo ''; - -// Max / min value -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo ''; - -// Warning value threshold -echo ''; -echo '"; -echo ''; - -// Critical value threshold -echo '"; -echo ''; -echo ''; - -// History data ? -echo ""; -echo '"; -echo ''; -echo ''; - -// Post process / Export server -echo ''; -echo ''; -echo ''; -// Export target is a server where the data will be sent -echo '"; -echo ''; - -// tcp send / rcv value -echo ''; -echo '"; - -if ($form_id_tipo_modulo >= 15 && $form_id_tipo_modulo <= 18) { - echo ''; -echo '"; -echo ''; - -// Description -echo ''; -echo '"; -echo ''; - -// Custom ID -echo ''; -echo '"; -echo ''; -echo ''; - -echo '
"; -echo __('Using Module Component'); -pandora_help ("network_component"); -echo ""; +push_table_simple ($data, 'target_ip'); -if ($update_module_id != NULL){ - echo "Not available in edition mode"; - echo ""; +$snmp_versions['1'] = 'v. 1'; +$snmp_versions['2'] = 'v. 2'; +$snmp_versions['2c'] = 'v. 2c'; +$data = array (); +$data[0] = __('SNMP community'); +$data[1] = print_input_text ('snmp_community', $snmp_community, '', 15, 60, true); + +$data[2] = _('SNMP version'); +$snmp_version = 1; +if ($id_module_type >= 15 && $id_module_type <= 18) { + $data[3] = print_select ($snmp_versions, 'snmp_version', $snmp_version, + '', '', '', true); } else { - echo '"; -} -echo ''; -echo ''; -if ($update_module_id == NULL){ -echo ''; + $data[3] = print_select ($snmp_versions, 'snmp_version', 0, '', '', + '', true); } -// Name / IP_target -echo '
'.__('Module name')."'.__('Disabled')."
'.__('Target IP')."'.__('TCP port')."
'.__('Module type'); -pandora_help ("module_type"); -echo ''; -if ($update_module_id != NULL){ - echo "Not available in edition mode"; - echo ""; -} else { - echo ''; +/* Advanced stuff */ +$data = array (); +$data[0] = __('TCP send').' '.pandora_help ("tcp_send", true); +$data[1] = print_textarea ('tcp_send', 2, 65, + $tcp_send, '', true); +$table_advanced->colspan['tcp_send'][1] = 3; + +push_table_advanced ($data, 'tcp_send'); + +$data[0] = __('TCP receive'); +$data[1] = print_textarea ('tcp_rcv', 2, 65, + $tcp_rcv, '', true); +$table_advanced->colspan['tcp_receive'][1] = 3; + +push_table_advanced ($data, 'tcp_receive'); + +if ($id_module_type >= 15 && $id_module_type <= 18) { + /* SNMP */ + $table_advanced->rowstyle['tcp_send'] = 'display: none'; + $table_advanced->rowstyle['tcp_receive'] = 'display: none'; +} elseif ($id_module_type >= 8 && $id_module_type <= 11) { + /* TCP or ICMP */ + $table_simple->rowstyle['snmp_1'] = 'display: none'; + $table_simple->rowstyle['snmp_2'] = 'display: none'; +} elseif (empty ($update_module_id)) { + $table_advanced->rowstyle['tcp_send'] = 'display: none'; + $table_advanced->rowstyle['tcp_receive'] = 'display: none'; + $table_simple->rowstyle['snmp_1'] = 'display: none'; + $table_simple->rowstyle['snmp_2'] = 'display: none'; } - -echo ''.__('Max. timeout')."
'.__('Interval')."'.__('Module group')."'; -echo ''; - -// Snmp walk -echo '
'.__('SNMP walk'); -pandora_help ("snmpwalk"); -echo ''; -echo '"; -echo ''; -echo ''; - -// Snmp Oid / community -echo '
'.__('SNMP OID'); -pandora_help ("snmpoid"); -echo ''.__('SNMP Community')."
'.__('SNMP version'); -$snmp_versions["1"] = "1"; -$snmp_versions["2"] = "2"; -$snmp_versions["2c"] = "2c"; -echo ''; -// SNMP module, tcp_send contains the snmp version -if ($form_id_tipo_modulo >= 15 && $form_id_tipo_modulo <= 18) { - print_select ($snmp_versions, 'form_tcp_send', $form_tcp_send, '', '', '', false, false); -} else { - print_select ($snmp_versions, 'form_tcp_send_void', 0, '', '', '', false, false); -} -echo '
'.__('Min. Value')."'.__('Max. Value')."
'.__('Warning status')."'.__("Min.").' '; -echo ' '.__("Max.").' '.__('Critical status')."'.__("Min.").' '; -echo ' '.__("Max.").'
'.__('Historical data')."'; -print_checkbox ("form_history_data", 1, $form_history_data, false); - -//FF stands for Flip-Flop -echo ''.__('FF threshold'); -pandora_help ("ff_threshold"); -echo '
'.__('Post process'); -pandora_help ("postprocess"); -echo ''.__('Export target')."'; -echo '
'.__('TCP send'); -pandora_help ("tcp_send"); -echo "'; -} else { - echo ''; -} -echo '
'.__('TCP receive')."'; -echo '
'.__('Description')."'; -echo '
'.__('Custom ID')."
'; - -// Submit -echo ''; -echo '
'; -if ($update_module_id == NULL){ - echo ''; -} else { - echo ''; -} -echo '
'; - ?> diff --git a/pandora_console/godmode/agentes/module_manager_editor_plugin.php b/pandora_console/godmode/agentes/module_manager_editor_plugin.php index 7ce9b84184..7dd2f4676e 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_plugin.php +++ b/pandora_console/godmode/agentes/module_manager_editor_plugin.php @@ -1,4 +1,5 @@ -colspan['plugin_1'][1] = 3; -// Check whether we are updataing and get data if so -if ($update_module_id != NULL){ - $row = get_db_row ("tagente_modulo", 'id_agente_modulo', $update_module_id); - if ($row == 0){ - unmanaged_error("Cannot load tnetwork_component reference from previous page"); - } - else{ - $id_agente = $row['id_agente']; - $form_id_tipo_modulo = $row['id_tipo_modulo']; // It doesn't matter - $form_description = $row['descripcion']; - $form_name = $row['nombre']; - $form_minvalue = $row['min']; - $form_maxvalue = $row['max']; - $form_interval = $row['module_interval']; - $form_tcp_port = $row['tcp_port']; - $form_tcp_send = $row['tcp_send']; - $form_tcp_rcv = $row['tcp_rcv']; - $form_snmp_community = $row['snmp_community']; - $form_snmp_oid = $row['snmp_oid']; - $form_ip_target = $row['ip_target']; - $form_id_module_group = $row['id_module_group']; - $form_flag = $row['flag']; - $tbl_id_modulo = $row['id_modulo']; // It doesn't matter - $tbl_disabled = $row['disabled']; - $form_id_export = $row['id_export']; - $form_plugin_user = $row['plugin_user']; - $form_plugin_pass = $row['plugin_pass']; - $form_plugin_parameter = $row['plugin_parameter']; - $form_id_plugin = $row['id_plugin']; - $form_post_process = $row['post_process']; - $form_prediction_module = $row['prediction_module']; - $form_max_timeout = $row['max_timeout']; - $form_custom_id = $row['custom_id']; - $form_history_data = $row['history_data']; - $form_min_warning = $row['min_warning']; - $form_max_warning = $row['max_warning']; - $form_min_critical = $row['min_critical']; - $form_max_critical = $row['max_critical']; - $form_ff_event = $row['min_ff_event']; +push_table_simple ($data, 'plugin_1'); - if ($tbl_disabled == 1){ - $disabled_status = 'checked="ckecked"'; - } else { - $disabled_status = NULL; - } - } -} +$data = array (); +$data[0] = __('Target IP'); +$data[1] = print_input_text ('ip_target', $ip_target, '', 15, 60, true); +$data[2] = _('Port'); +$data[3] = print_input_text ('tcp_port', $tcp_port, '', 5, 20, true); -echo "

".__('Module assignment')." - ".__('Plugin server module')."

"; -echo ''; -echo ''; -// Whether in update or insert mode -if ($update_module_id == NULL){ - echo ""; -} else { - echo ""; -} +push_table_simple ($data, 'target_ip'); -//id_agente_module -echo ""; +$data = array (); +$data[0] = __('Username'); +$data[1] = print_input_text ('plugin_user', $plugin_user, '', 15, 60, true); +$data[2] = _('Password'); +$data[3] = print_input_password ('plugin_pass', $plugin_pass, '', 15, 60, true); -// id_modulo 4 - PLugin -echo ""; +push_table_simple ($data, 'plugin_2'); -// Name / IP_target -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo ''; - -// Ip target, Plugin Parameter -echo ""; -echo '"; -echo ''; -echo '"; -echo ''; - -echo ''; -echo ''; -echo ''; - -echo '"; -echo ''; - -// username / password -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo ''; - -// module type / max timeout -echo ''; -echo ''; -echo '"; -echo ''; - -// Warning value threshold -echo ''; -echo '"; -echo ''; - -// Critical value threshold -echo '"; -echo ''; -echo ''; - -// History data ? -echo ""; -echo '"; -echo ''; -echo ''; - - -// Interval & id_module_group -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo ''; - -// Post process / Export server -echo ''; -echo ''; -echo ''; -// Export target is a server where the data will be sent -echo '"; -echo ''; - -// Description -echo ''; -echo '"; -echo ''; - -// Custom ID -echo ''; -echo '"; -echo ''; -echo ''; - -echo '
'.__('Module name')."'.__('Disabled')."
'.__('Target IP')."'.__('plugin')."'; -// Get actual plugin ID and nicename -echo ''; -echo '
'.__('Plugin parameters'); -pandora_help ("plugin_parameters"); -echo ''.__('Port')."
'.__('Username')."'.__('Password')."
'.__('Module type'); -pandora_help ("module_type"); -echo ''; - -if ($update_module_id != NULL){ - echo "Not available in edition mode"; - echo ""; -} else { - echo ''; -} - -echo ''.__('Max. timeout')."
'.__('Warning status')."'.__("Min.").' '; -echo ' '.__("Max.").' '.__('Critical status')."'.__("Min.").' '; -echo ' '.__("Max.").'
'.__('Historical data')."'; -print_checkbox ("form_history_data", 1, $form_history_data, false); - -//FF stands for Flip-Flop -echo ''.__('FF threshold'); -pandora_help ("ff_threshold"); -echo '
'.__('Interval')."'.__('Module group')."'; -echo ''; - -// Max / min value -echo '
'.__('Min. Value')."'.__('Max. Value')."
'.__('Post process'); -pandora_help ("postprocess"); -echo ''.__('Export target')."'; -echo '
'.__('Description')."'; -echo '
'.__('Custom ID')."
'; - -// Submit -echo ''; -echo '
'; -if ($update_module_id == NULL){ - echo ''; -} else { - echo ''; -} -echo '
'; +$data = array (); +$data[0] = __('Plugin parameters'); +$data[0] .= pandora_help ('plugin_parameters', true); +$data[1] = print_input_text ('plugin_parameter', $plugin_parameter, '', 30, 60, true); +$table_simple->colspan['plugin_3'][1] = 3; +push_table_simple ($data, 'plugin_3'); ?> diff --git a/pandora_console/godmode/agentes/module_manager_editor_prediction.php b/pandora_console/godmode/agentes/module_manager_editor_prediction.php index 9dc4f47871..d87dd03906 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_prediction.php +++ b/pandora_console/godmode/agentes/module_manager_editor_prediction.php @@ -21,162 +21,29 @@ if (!isset ($id_agente)) { die ("Not Authorized"); } -// get the variable form_moduletype -$form_moduletype = get_parameter_post ("form_moduletype"); -// get the module to update -$update_module_id = get_parameter_get ("update_module"); -// the variable that checks whether the module is disabled or not must be setcommitedversion -$disabled_status = NULL; - -// Specific ACL check -if (give_acl($config["id_user"], 0, "AW") != 1) { - audit_db($config["id_user"], $REMOTE_ADDR, "ACL Violation","Trying to access agent manager"); - require ($config["homedir"]."/general/noaccess.php"); - exit; -} - -// Check whether we are updataing and get data if so -if ($update_module_id != NULL){ - $row = get_db_row ("tagente_modulo", 'id_agente_modulo', $update_module_id); - if ($row == 0){ - unmanaged_error("Cannot load tnetwork_component reference from previous page"); - } - else{ - $id_agente = $row['id_agente']; - $form_id_tipo_modulo = $row['id_tipo_modulo']; // It doesn't matter - $form_description = $row['descripcion']; - $form_name = $row['nombre']; - $form_minvalue = $row['min']; - $form_maxvalue = $row['max']; - $form_interval = $row['module_interval']; - $form_tcp_port = $row['tcp_port']; - $form_tcp_send = $row['tcp_send']; - $form_tcp_rcv = $row['tcp_rcv']; - $form_snmp_community = $row['snmp_community']; - $form_snmp_oid = $row['snmp_oid']; - $form_ip_target = $row['ip_target']; - $form_id_module_group = $row['id_module_group']; - $form_flag = $row['flag']; - $tbl_id_modulo = $row['id_modulo']; // It doesn't matter - $tbl_disabled = $row['disabled']; - $form_id_export = $row['id_export']; - $form_plugin_user = $row['plugin_user']; - $form_plugin_pass = $row['plugin_pass']; - $form_plugin_parameter = $row['plugin_parameter']; - $form_id_plugin = $row['id_plugin']; - $form_post_process = $row['post_process']; - $form_prediction_module = $row['prediction_module']; - $form_max_timeout = $row['max_timeout']; - $form_custom_id = $row['custom_id']; - - if ($tbl_disabled == 1){ - $disabled_status = 'checked="ckecked"'; - } else { - $disabled_status = NULL; - } - } -} - -echo "

".__('Module assignment')." - ".__('Prediction server module')."

"; -echo ''; -// Whether in update or insert mode -if ($update_module_id == NULL){ - print_input_hidden ("insert_module", 1); -} else { - print_input_hidden ("update_module", 1); -} - -//id_agente_module -print_input_hidden ("id_agente_modulo", $update_module_id); - -// id_modulo 5 - Prediction -print_input_hidden ("form_id_modulo", 5); - -// name / disabled -echo ''; -echo ''; -echo ''; -echo ''; -echo ''; - -//Source module -echo ''; -echo ''; -echo ''; - -// module type / interval -echo ''; - -// Post process / Export server -echo ''; -echo ''; - -// Description -echo ''; -echo ''; -echo ''; - -// Custom ID -echo ''; -echo ''; -echo ''; - -echo '
'.__('Module name').''; -print_input_text ("form_name", $form_name, '', 35); -echo ''.__('Disabled').''; -print_checkbox ("form_disabled", 1, $disabled_status); -echo '
'.__('Source module'); -pandora_help ("prediction_source_module"); -echo ''; +$extra_title = __('Prediction server module'); +$data = array (); +$data[0] = __('Source module'); +$data[0] .= pandora_help ('prediction_source_module', true); $agents = get_group_agents (array_keys (get_user_groups ($config["id_user"], "AW"))); $fields = array (); - foreach ($agents as $agent_id => $agent_name) { - $modules = get_agent_modules ($agent_id); + $modules = get_agent_modules ($agent_id, false, 'disabled = 0 AND history_data = 1'); foreach ($modules as $module_id => $module_name) { $fields[$module_id] = $agent_name.' / '.$module_name; } } +$data[1] = print_select ($fields, 'prediction_module', $prediction_module, '', + '', '', true); +$table_simple->colspan['prediction_module'][1] = 3; -print_select ($fields, "form_prediction_module", $form_prediction_module); -echo '
'. __('Module type') .''; -if (!empty ($update_module_id)) { - echo 'Not available in edition mode'; - print_input_hidden ("form_id_tipo_modulo", $form_id_tipo_modulo); -} else { - $fields = array (); - $fields[1] = get_moduletype_name (1); - $fields[2] = get_moduletype_name (2); - print_select ($fields, "form_id_tipo_modulo"); -} - -echo ''.__('Interval').''; -print_input_text ("form_interval", $form_interval, '', 5); -echo '
'.__('Module group').''; -$fields = get_modulegroups (); -print_select ($fields, "form_id_module_group", $form_id_module_group); - -// Export target is a server where the data will be sent -echo ''.__('Export target').''; - -$fields = get_exportservers_info (); -$fields[0] = __('None'); - -print_select ($fields, "form_id_export", $form_id_export); -echo '
'.__('Description').''; -print_textarea ("form_description", 2, 65, $form_description); -echo '
'.__('Custom ID').''; -print_input_text ("form_custom_id", $form_custom_id, '', 20); -echo '
'; - -// Submit -echo '
'; -if ($update_module_id == NULL){ - print_submit_button (__('Create'), 'crtbutton', false, 'class="sub wand"'); -} else { - print_submit_button (__('Update'), 'updbutton', false, 'class="sub upd"'); -} -echo '
'; +push_table_simple ($data, 'prediction_module'); +/* Removed common useless parameter */ +unset ($table_simple->data[2]); +unset ($table_simple->data[3]); +unset ($table_advanced->data[3]); +unset ($table_advanced->data[2][2]); +unset ($table_advanced->data[2][3]); ?> diff --git a/pandora_console/godmode/agentes/module_manager_editor_wmi.php b/pandora_console/godmode/agentes/module_manager_editor_wmi.php index 4b38a6673c..48ae945170 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_wmi.php +++ b/pandora_console/godmode/agentes/module_manager_editor_wmi.php @@ -21,277 +21,59 @@ if (!isset ($id_agente)) { die ("Not Authorized"); } -// get the variable form_moduletype -$form_moduletype = get_parameter_post ("form_moduletype"); -// get the module to update -$update_module_id = get_parameter_get ("update_module"); -// the variable that checks whether the module is disabled or not must be setcommitedversion -$disabled_status = NULL; +$extra_title = __('WMI server module'); -// Specific ACL check -if (give_acl($config["id_user"], 0, "AW")!=1) { - audit_db($config["id_user"], $REMOTE_ADDR, "ACL Violation","Trying to access agent manager"); - require ($config["homedir"]."/general/noaccess.php"); - exit; -} +$data = array (); +$data[0] = __('Using module component').' '; +$data[0] .= pandora_help ('network_component', true); -// Check whether we are updataing and get data if so -if ($update_module_id != NULL){ - $row = get_db_row ("tagente_modulo", 'id_agente_modulo', $update_module_id); - if ($row == 0){ - unmanaged_error("Cannot load tnetwork_component reference from previous page"); - } - else{ - $id_agente = $row['id_agente']; - $form_id_tipo_modulo = $row['id_tipo_modulo']; - $form_description = $row['descripcion']; - $form_name = $row['nombre']; - $form_minvalue = $row['min']; - $form_maxvalue = $row['max']; - $form_interval = $row['module_interval']; - $form_tcp_port = $row['tcp_port']; - $form_tcp_send = $row['tcp_send']; - $form_tcp_rcv = $row['tcp_rcv']; - $form_snmp_community = $row['snmp_community']; - $form_snmp_oid = $row['snmp_oid']; - $form_ip_target = $row['ip_target']; - $form_id_module_group = $row['id_module_group']; - $form_flag = $row['flag']; - $tbl_id_modulo = $row['id_modulo']; // It doesn't matter - $tbl_disabled = $row['disabled']; - $form_id_export = $row['id_export']; - $form_plugin_user = $row['plugin_user']; - $form_plugin_pass = $row['plugin_pass']; - $form_plugin_parameter = $row['plugin_parameter']; - $form_id_plugin = $row['id_plugin']; - $form_post_process = $row['post_process']; - $form_prediction_module = $row['prediction_module']; - $form_max_timeout = $row['max_timeout']; - $form_custom_id = $row['custom_id']; - $form_history_data = $row['history_data']; - $form_min_warning = $row['min_warning']; - $form_max_warning = $row['max_warning']; - $form_min_critical = $row['min_critical']; - $form_max_critical = $row['max_critical']; - $form_ff_event = $row['min_ff_event']; - - if ($tbl_disabled == 1){ - $disabled_status = 'checked="ckecked"'; - } else { - $disabled_status = NULL; - } - } -} - -echo "

".__('Module assignment')." - ".__('WMI server module')."

"; -echo ''; -echo ''; -// Whether in update or insert mode -if ($update_module_id == NULL){ - echo ""; +if (empty ($update_module_id)) { + $data[1] = print_select_from_sql ('SELECT id_nc, name FROM tnetwork_component WHERE id_modulo = 6', + 'network_component', '', '', '---'.__('Manual setup').'---', 0, true); + $data[1] .= ' '; } else { - echo ""; + /* TODO: Print network component if available */ + $data[1] = 'TODO'; } +$table_simple->colspan['module_component'][1] = 3; +$table_simple->rowstyle['module_component'] = 'background-color: #D4DDC6'; -//id_agente_module -echo ""; +prepend_table_simple ($data, 'module_component'); -// id_modulo 6 - WMI -echo ""; +$data = array (); +$data[0] = __('Target IP'); +$data[1] = print_input_text ('ip_target', $ip_target, '', 15, 60, true); +$data[2] = _('Namespace'); +$data[2] .= pandora_help ('wminamespace', true); +$data[3] = print_input_text ('tcp_send', $tcp_send, '', 5, 20, true); -// WMI component usage -echo "'; -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo ''; +$data = array (); +$data[0] = __('WMI Query'); +$data[0] .= pandora_help ('wmiquery', true); +$data[1] = print_input_text ('snmp_oid', $snmp_oid, '', 35, 60, true); +$table_simple->colspan['wmi_query'][1] = 3; -// Ip target / Namespace -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo ''; +push_table_simple ($data, 'wmi_query'); -echo ''; -echo ''; -echo ''; - -// Specific string and field number -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo ''; - -// username / password -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo ''; - - -// module type / max timeout -echo ''; -echo ''; -echo '"; -echo ''; - -// Interval & id_module_group -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo '"; -echo ''; -echo ''; - - -// Warning value threshold -echo ''; -echo '"; -echo ''; - -// Critical value threshold -echo '"; -echo ''; -echo ''; - -// History data ? -echo ""; -echo '"; -echo ''; -echo ''; - -// Post process / Export server -echo ''; -echo ''; -echo ''; -// Export target is a server where the data will be sent -echo '"; -echo ''; - -// Description -echo ''; -echo '"; -echo ''; - -// Custom ID -echo ''; -echo '"; -echo ''; -echo ''; - -echo '
"; -echo __('Using Module Component'); -pandora_help ("network_component"); -echo ""; +push_table_simple ($data, 'target_ip'); -if ($update_module_id != NULL){ - echo "Not available in edition mode"; - echo ""; -} else { - echo '"; -} +$data = array (); +$data[0] = __('Username'); +$data[1] = print_input_text ('plugin_user', $plugin_user, '', 15, 60, true); +$data[2] = _('Password'); +$data[3] = print_input_password ('plugin_pass', $plugin_pass, '', 15, 60, true); -echo ''; -echo ''; -if ($update_module_id == NULL){ - echo ''; -} +push_table_simple ($data, 'user_pass'); -// Name / IP_target -echo '
'.__('Module name')."'.__('Disabled')."
'.__('Target IP')."'.__('Namespace'); -pandora_help("wminamespace"); -echo "
'.__('WMI Query'); -pandora_help("wmiquery"); -echo '
'.__('Key string'); -pandora_help("wmikey"); -echo "'.__('Field number'); -pandora_help("wmifield"); -echo "
'.__('Username')."'.__('Password')."
'.__('Module type'); -pandora_help("module_type"); -echo ''; -if ($update_module_id != NULL){ - echo "Not available in edition mode"; - echo ""; -} else { - echo ''; -} - -echo ''.__('Max. timeout')."
'.__('Interval')."'.__('Module group')."'; -echo ''; - -// Max / min value -echo '
'.__('Min. Value')."'.__('Max. Value')."
'.__('Warning status')."'.__("Min.").' '; -echo ' '.__("Max.").' '.__('Critical status')."'.__("Min.").' '; -echo ' '.__("Max.").'
'.__('Historical data')."'; -print_checkbox ("form_history_data", 1, $form_history_data, false); - -//FF stands for Flip-Flop -echo ''.__('FF threshold'); -pandora_help ("ff_threshold"); -echo '
'.__('Post process'); -pandora_help("postprocess"); -echo ''.__('Export target')."'; -echo '
'.__('Description')."'; -echo '
'.__('Custom ID')."
'; - -// Submit -echo ''; -echo '
'; -if ($update_module_id == NULL){ - echo ''; -} else { - echo ''; -} -echo '
'; +$data = array (); +$data[0] = __('Key string'); +$data[0] .= pandora_help ('wmikey', true); +$data[1] = print_input_text ('snmp_community', $snmp_community, '', 20, 60, true); +$data[2] = __('Field number'); +$data[2] .= pandora_help ('wmifield', true); +$data[3] = print_input_text ('tcp_port', $tcp_port, '', 5, 15, true); +push_table_simple ($data, 'key_field'); ?> diff --git a/pandora_console/images/console/icons/server_warning.png b/pandora_console/images/console/icons/server_warning.png deleted file mode 100644 index 4f029072c0d755bd55be99599230202ce12c128b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1741 zcmV;;1~U1HP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iXA@ z5dbuer~5_#0013yMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HRA^-&M@dak?_?!z000Ig zNklqR}F-e*_VJBtU%wadaTJN@H<3%I~8ET%8{C2!u$y!p=e zcfOxwFc|p14W-+6yrYi%_D2T$s9@HfjmrWGCb+zXPT?eE9g#MR6nFxGI*?Vw&?P){7afOXkV z=m7A=2#AjX-&T&F&ntk1ad7Yi053XsV8@Xy{M=@cA*b=6?x-h>k74KOEK~sDVUV~Q z0^2$Fy6!Q|i-n9U0OW*+vFFz~HWFfZ;WDTSBi8RdMh8IIF#z_hhtO^fv%{-*Vd^Tl z_YnO3;Ob3-FX7KX0m|MylmS*k%wD%R8RQ*$z zf@&G4JOwNHMPRehsEA$$pj3)K{PP?XnOp;7lSMGiF9LIE0~oHkaJ%>qR_<}#2J3Ot*EvBb`DgVbJgq5JiC2_U}^Iz_;(`_L&6d{l7qBHYkHVKG>& z6|`EwL+OQw2bfE3bsBJE)YlB4g*SZIABKMg<6{JC9}N@$^9msSf>4dh6U^ok%F98P z-BbNI0_6iDk4^d%&Zofdn}l60-2z6F02ZMUKuu=%fvF3W2}BCH{x8g4D;R0l2Ksb? zpb-!fCE|@u77^NFtu9Rgstlmm1nU<;SP$qj8j=pe$ibpkDlCQ#yDQ?F&9ULT8x#PS z??8c3of>iUJ^xpEuG4x~wJs?xIxi(ybNxVj(G6XE`2=r`_7`B5t? zjREEelyB7wOF85hi$FT4H>4-Qj4^QO=DR)3a__TBXo9D&jSSgo*Z3s~y08Ce$I=Zw@g z^#1?U3o5U&$ZO#ZL%)Q(4{HC2t(J%`*AeN{FTkj|V(!-(Ye+_p2+bMkT-QaVS1W>sbJ7~BU2^n&cC zA~|PVfrJC%U;!|+AH{Lsu&--J7N%&lC63~DUj`7Iqj9YjROt5?KTU}KEMY$@fiN!> zM2`}sOF%nudcJf+)b6J%nskBwJl(yPxPBodr)ab$M__{K#>XhhtHF>P1&NzwfkV-P8%$ jsqw%kiF=+~ngrB;WjE%Aj7v(l00000NkvXXu0mjf(pf8; diff --git a/pandora_console/images/edit.png b/pandora_console/images/edit.png new file mode 100644 index 0000000000000000000000000000000000000000..188e1c12bd2de0029c75eefc6c7c4753b86b7d9b GIT binary patch literal 574 zcmV-E0>S->P)2^qNERY3;<4ZcwkNNp7Zp5;AjKf{B7T6H z7K$;wTN)8fToCQSV$+QqO#Q&sZ0iseT9M6oFhjF#YAe3W{|(Ih&u?blgZ~U+lHy(Z zfEnP}R(g1dys47_mq#z10cH*!ci4`$5?D>W0r2hlIkux$PfFdaJ1vdV-c&$Y6qM6=z7>zUrb8|$BG>39|jmV1jOTU#EGRpi+xRHO?}@de@`-W?HM1Qj5D_ogg}SY zdLN|}^?H57O9w%Kn@Oz|d&_(+O?3c05d+({v28n2?E5}$CdJ@bk;TUuUX_^(h)oH!))dmc3|x7NH+_f7=kKWb2fXhZ zrnAjAMhLXlWV2a*$wSOL4(~qIS$aJMy=iu>tN_|Hp>9hMh9SE@rg`+GoBO#O-SQ{L5?nn?G7$uQNU|ANHWktGp13@enLu*Z~ zRzquzloG8qLI{Kqt=k(B1Emy><7_&0#$+Z`3#dv5h=E26FfcG1 zbL_hF&)}42ws10s6^G;;cE1^EoUR)U5A70}d2pLv!jVIT7j&Z~EblI3x0K*v_sV|m z0kj3v921Z^em#l`(k(o@H$3ZdDRc@9NidXDNbqrumReCGv$gd8+e8WW28HVqkJ_9i zH>s*<31KtHjANIPvi2#*6BEu%3Dak5O_t&NBI)H?V$TxT}#l{vOTn5naXTfF^&~Hhq+NX@#Ccc>y7T?;vjI&jdhsDsPJyAw*m0Qz>i}K7# zL9w50Ng{fT}A5JUe8lRK1h7_Y2;BWJDd=c6f&i?Wv5(5q?6|P zQw{>maxZP<537OA37Uk}7@%_$4o$EWe_Zl>&#id|lE-BpDC#+Fn|msJ%_2h{Hg1vP z#N8WAzfWasG}yq|xqE)DrWaOofX=z|?*pgc%{ig5vl!pqDlC|q&~Z0$&Rvsft&VO- z4MZj+%-+Vx%W}v;V76hyp=;+R;x+~t^Q%*xuFTQAF2})fSfTHDAs>sO!OBw`)&)o$ c0!CNZt))x~rAZP^^P&YOFfdqy5)K#u0POD40{{R3 literal 0 HcmV?d00001 diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 9b7c42da00..9bca4d4ae7 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -870,6 +870,17 @@ function get_moduletype_name ($id_type) { return (string) get_db_value ('nombre', 'ttipo_modulo', 'id_tipo', (int) $id_type); } +/** + * Get the module type description + * + * @param int $id_type Type id + * + * @return string Description of the given type. + */ +function get_moduletype_description ($id_type) { + return (string) get_db_value ('descripcion', 'ttipo_modulo', 'id_tipo', (int) $id_type); +} + /** * Returns an array with all module types (default) or if "remote" or "agent" * is passed it will return only remote (ICMP, SNMP, TCP...) module types diff --git a/pandora_console/include/javascript/jquery.form.js b/pandora_console/include/javascript/jquery.form.js new file mode 100644 index 0000000000..d98fd9e077 --- /dev/null +++ b/pandora_console/include/javascript/jquery.form.js @@ -0,0 +1,602 @@ +/* + * jQuery Form Plugin + * version: 2.12 (06/07/2008) + * @requires jQuery v1.2.2 or later + * + * Examples and documentation at: http://malsup.com/jquery/form/ + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * Revision: $Id$ + */ +(function($) { + +/* + Usage Note: + ----------- + Do not use both ajaxSubmit and ajaxForm on the same form. These + functions are intended to be exclusive. Use ajaxSubmit if you want + to bind your own submit handler to the form. For example, + + $(document).ready(function() { + $('#myForm').bind('submit', function() { + $(this).ajaxSubmit({ + target: '#output' + }); + return false; // <-- important! + }); + }); + + Use ajaxForm when you want the plugin to manage all the event binding + for you. For example, + + $(document).ready(function() { + $('#myForm').ajaxForm({ + target: '#output' + }); + }); + + When using ajaxForm, the ajaxSubmit function will be invoked for you + at the appropriate time. +*/ + +/** + * ajaxSubmit() provides a mechanism for immediately submitting + * an HTML form using AJAX. + */ +$.fn.ajaxSubmit = function(options) { + // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) + if (!this.length) { + log('ajaxSubmit: skipping submit process - no element selected'); + return this; + } + + if (typeof options == 'function') + options = { success: options }; + + options = $.extend({ + url: this.attr('action') || window.location.toString(), + type: this.attr('method') || 'GET' + }, options || {}); + + // hook for manipulating the form data before it is extracted; + // convenient for use with rich editors like tinyMCE or FCKEditor + var veto = {}; + this.trigger('form-pre-serialize', [this, options, veto]); + if (veto.veto) { + log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); + return this; + } + + var a = this.formToArray(options.semantic); + if (options.data) { + options.extraData = options.data; + for (var n in options.data) + a.push( { name: n, value: options.data[n] } ); + } + + // give pre-submit callback an opportunity to abort the submit + if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { + log('ajaxSubmit: submit aborted via beforeSubmit callback'); + return this; + } + + // fire vetoable 'validate' event + this.trigger('form-submit-validate', [a, this, options, veto]); + if (veto.veto) { + log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); + return this; + } + + var q = $.param(a); + + if (options.type.toUpperCase() == 'GET') { + options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; + options.data = null; // data is null for 'get' + } + else + options.data = q; // data is the query string for 'post' + + var $form = this, callbacks = []; + if (options.resetForm) callbacks.push(function() { $form.resetForm(); }); + if (options.clearForm) callbacks.push(function() { $form.clearForm(); }); + + // perform a load on the target only if dataType is not provided + if (!options.dataType && options.target) { + var oldSuccess = options.success || function(){}; + callbacks.push(function(data) { + $(options.target).html(data).each(oldSuccess, arguments); + }); + } + else if (options.success) + callbacks.push(options.success); + + options.success = function(data, status) { + for (var i=0, max=callbacks.length; i < max; i++) + callbacks[i](data, status, $form); + }; + + // are there files to upload? + var files = $('input:file', this).fieldValue(); + var found = false; + for (var j=0; j < files.length; j++) + if (files[j]) + found = true; + + // options.iframe allows user to force iframe mode + if (options.iframe || found) { + // hack to fix Safari hang (thanks to Tim Molendijk for this) + // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d + if ($.browser.safari && options.closeKeepAlive) + $.get(options.closeKeepAlive, fileUpload); + else + fileUpload(); + } + else + $.ajax(options); + + // fire 'notify' event + this.trigger('form-submit-notify', [this, options]); + return this; + + + // private function for handling file uploads (hat tip to YAHOO!) + function fileUpload() { + var form = $form[0]; + + if ($(':input[@name=submit]', form).length) { + alert('Error: Form elements must not be named "submit".'); + return; + } + + var opts = $.extend({}, $.ajaxSettings, options); + + var id = 'jqFormIO' + (new Date().getTime()); + var $io = $('