diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e7afa47216..21c3735ca4 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,15 @@ +2009-05-27 Esteban Sanchez + + * godmode/agentes/configurar_agente.php: Use pandora functions to + create and update modules. Some fixes when these operations could + not be done so the editor appears again. Fixes #2762316 + + * godmode/agentes/module_manager_editor.php: Some patches to work + better with configurar_agente.php + + * include/functions_modules.php: Avoid setting an empty name on + update_agent_module() + 2009-05-27 Esteban Sanchez * reporting/fgraph.php: Do not short agent name on diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index 1f8768ba31..3ee8e6a492 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -33,9 +33,11 @@ if (! give_acl ($config["id_user"], $group, "AW")) { audit_db ($config['id_user'], $REMOTE_ADDR, "ACL Violation", "Trying to access agent manager"); require ("general/noaccess.php"); - exit; + return; } +require_once ('include/functions_modules.php'); + // Get passed variables $tab = get_parameter ('tab', 'main'); $alerttype = get_parameter ('alerttype'); @@ -372,8 +374,8 @@ if ($update_module || $create_module) { $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 ("min"); - $maxvalue = (int) get_parameter ('max'); + $min = (int) get_parameter_post ("min"); + $max = (int) get_parameter ('max'); $interval = (int) get_parameter ('module_interval', $intervalo); $id_prediction_module = (int) get_parameter ('id_prediction_module'); $id_plugin = (int) get_parameter ('id_plugin'); @@ -405,12 +407,12 @@ if ($update_module || $create_module) { if ($update_module) { $id_agent_module = (int) get_parameter ('id_agent_module'); - $result = process_sql_update ('tagente_modulo', + $result = update_agent_module ($id_agent_module, array ('descripcion' => $description, 'id_module_group' => $id_module_group, 'nombre' => $name, - 'max' => $maxvalue, - 'min' => $minvalue, + 'max' => $max, + 'min' => $min, 'module_interval' => $interval, 'tcp_port' => $tcp_port, 'tcp_send' => $tcp_send, @@ -434,12 +436,11 @@ if ($update_module) { 'max_warning' => $max_warning, 'min_critical' => $min_critical, 'max_critical' => $max_critical, - 'min_ff_event' => $ff_event - ), - 'id_agente_modulo = '.$id_agent_module); + 'min_ff_event' => $ff_event)); if ($result === false) { echo '

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

'; + $edit_module = true; } else { echo '

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

'; $id_agent_module = false; @@ -458,13 +459,11 @@ if ($create_module) { $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, + $id_agent_module = create_agent_module ($id_agente, $name, + array ('id_tipo_modulo' => $id_module_type, 'descripcion' => $description, - 'max' => $maxvalue, - 'min' => $minvalue, + 'max' => $max, + 'min' => $min, 'snmp_oid' => $snmp_oid, 'snmp_community' => $snmp_community, 'id_module_group' => $id_module_group, @@ -495,19 +494,9 @@ if ($create_module) { if ($id_agent_module === false) { echo '

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

'; $edit_module = true; + $moduletype = $id_module; } else { - $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').'

'; - } + echo '

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

'; $id_agent_module = false; $edit_module = false; } diff --git a/pandora_console/godmode/agentes/module_manager_editor.php b/pandora_console/godmode/agentes/module_manager_editor.php index 0b1c88423f..14952f02bb 100644 --- a/pandora_console/godmode/agentes/module_manager_editor.php +++ b/pandora_console/godmode/agentes/module_manager_editor.php @@ -113,42 +113,44 @@ if ($id_agent_module) { $max_critical = $module['max_critical']; $ff_event = $module['min_ff_event']; } else { - $moduletype = (string) get_parameter ('moduletype'); + if (!isset ($moduletype)) { + $moduletype = (string) get_parameter ('moduletype'); + + // 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 = ''; - // 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 - $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; + if ($moduletype == "wmiserver") + $snmp_community = ''; + else + $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 ($moduletype) { diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 2a4c2c0aad..a8916b1b70 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -108,6 +108,8 @@ function delete_agent_module ($id_agent_module) { function update_agent_module ($id, $values) { if (! is_array ($values)) return false; + if (! isset ($values['nombre']) && empty ($values['nombre'])) + return false; return (@process_sql_update ('tagente_modulo', $values, array ('id_agente_modulo' => (int) $id)) !== false);