From e38b33958d394f72965390d8c3f30d7d8817471e Mon Sep 17 00:00:00 2001 From: Esteban Sanchez Date: Wed, 18 Mar 2009 15:42:15 +0000 Subject: [PATCH] 2009-03-18 Esteban Sanchez * godmode/agentes/massive_edit_modules.php: Added to repository. New interface to update modules massively. Should be improved lately. * reporting/pchart_graph.php: Fixed mess with color pallete. * godmode/agentes/massive_operations.php: Fixed sec parameter on links. Changed label. Added link to the new modules editor. * godmode/agentes/module_manager.php: Fixed an error when showing module group titles. * godmode/agentes/module_manager_editor.php: Decode values from components. * godmode/agentes/module_manager_editor_wmi.php: Bigger WMI query input text. * include/functions_db.php: Fixed a bug when using group on format_array_to_where_clause_sql(). * include/functions_modules.php: Fixed an error on get_network_components() which was not filtering fine. Many fixes in get_network_component_groups() so it works better now. Added update_agent_module(). git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1550 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 27 +++ .../godmode/agentes/massive_edit_modules.php | 172 ++++++++++++++++++ .../godmode/agentes/massive_operations.php | 13 +- .../godmode/agentes/module_manager.php | 4 +- .../godmode/agentes/module_manager_editor.php | 16 +- .../agentes/module_manager_editor_wmi.php | 2 +- pandora_console/include/functions_db.php | 2 +- pandora_console/include/functions_modules.php | 43 +++-- pandora_console/pandoradb.sql | 2 +- pandora_console/reporting/pchart_graph.php | 19 +- 10 files changed, 262 insertions(+), 38 deletions(-) create mode 100644 pandora_console/godmode/agentes/massive_edit_modules.php diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index f916f2df5b..6c3b7fc51d 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,30 @@ +2009-03-18 Esteban Sanchez + + * godmode/agentes/massive_edit_modules.php: Added to repository. New + interface to update modules massively. Should be improved lately. + + * reporting/pchart_graph.php: Fixed mess with color pallete. + + * godmode/agentes/massive_operations.php: Fixed sec parameter on + links. Changed label. Added link to the new modules editor. + + * godmode/agentes/module_manager.php: Fixed an error when showing + module group titles. + + * godmode/agentes/module_manager_editor.php: Decode values from + components. + + * godmode/agentes/module_manager_editor_wmi.php: Bigger WMI query + input text. + + * include/functions_db.php: Fixed a bug when using group on + format_array_to_where_clause_sql(). + + * include/functions_modules.php: Fixed an error on + get_network_components() which was not filtering fine. Many fixes in + get_network_component_groups() so it works better now. Added + update_agent_module(). + 2009-03-18 Esteban Sanchez * godmode/alerts/alert_list.php: Put tooltip before the template name diff --git a/pandora_console/godmode/agentes/massive_edit_modules.php b/pandora_console/godmode/agentes/massive_edit_modules.php new file mode 100644 index 0000000000..4f9b339c05 --- /dev/null +++ b/pandora_console/godmode/agentes/massive_edit_modules.php @@ -0,0 +1,172 @@ +'.__('Massive alerts deletion').''; + +function process_manage_edit ($module_name) { + if (is_int ($module_name) && $module_name <= 0) { + echo '

'.__('No modules selected').'

'; + return false; + } + + $agents = array_keys (get_group_agents (array_keys (get_user_groups ()), false, "none")); + + /* List of fields which can be updated */ + $fields = array ('min_warning', 'max_warning', 'min_critical', 'max_critical', 'ff_event'); + $values = array (); + foreach ($fields as $field) { + $value = get_parameter ($field); + if ($value != '') + $values[$field] = $value; + } + + + $modules = get_db_all_rows_filter ('tagente_modulo', + array ('id_agente' => $agents, + 'nombre' => $module_name), + array ('id_agente_modulo')); + + process_sql ('SET AUTOCOMMIT = 0'); + process_sql ('START TRANSACTION'); + if ($modules === false) + return false; + foreach ($modules as $module) { + update_agent_module ($module['id_agente_modulo'], $values); + } + + echo '

'.__('Successfully updated').'

'; + process_sql ('COMMIT'); + process_sql ('SET AUTOCOMMIT = 1'); +} + +$module_name = (string) get_parameter ('module_name'); + +$update = (bool) get_parameter_post ('update'); + +if ($update) { + process_manage_edit ($module_name); +} + + +$table->id = 'delete_table'; +$table->width = '95%'; +$table->data = array (); +$table->style = array (); +$table->style[0] = 'font-weight: bold; vertical-align:top'; +$table->style[2] = 'font-weight: bold'; +$table->rowstyle = array (); +$table->rowstyle['edit1'] = 'display: none'; +$table->rowstyle['edit2'] = 'display: none'; +$table->size = array (); +$table->size[0] = '15%'; +$table->size[1] = '85%'; /* Fixed using javascript */ +$table->size[2] = '15%'; +$table->size[3] = '35%'; +$table->colspan = array (); +$table->colspan[0][1] = '3'; + +$agents = get_group_agents (array_keys (get_user_groups ()), false, "none"); +$all_modules = get_db_all_rows_filter ('tagente_modulo', + array ('id_agente' => array_keys ($agents), + 'group' => 'nombre', + 'order' => 'id_tipo_modulo,nombre'), + array ('DISTINCT(nombre)', 'id_tipo_modulo')); + +if ($all_modules === false) + $all_modules = array (); + +$modules = array (); +$latest_type = -1; +$i = -1; +$prefix = str_repeat (' ', 3); +foreach ($all_modules as $module) { + if ($latest_type != $module['id_tipo_modulo']) { + $modules[$i--] = get_moduletype_description ($module['id_tipo_modulo']); + $latest_type = $module['id_tipo_modulo']; + } + $modules[$module['nombre']] = $prefix.$module['nombre']; +} + +$table->data = array (); +$table->data[0][0] = __('Module'); +$table->data[0][0] .= ''; +$table->data[0][1] = print_select ($modules, + 'module_name', 0, false, __('Select'), 0, true, false, false); + +$table->data['edit1'][0] = __('Warning status'); +$table->data['edit1'][1] = ''.__('Min.').''; +$table->data['edit1'][1] .= print_input_text ('min_warning', '', '', 5, 15, true); +$table->data['edit1'][1] .= '
'.__('Max.').''; +$table->data['edit1'][1] .= print_input_text ('max_warning', '', '', 5, 15, true); +$table->data['edit1'][2] = __('Critical status'); +$table->data['edit1'][3] = ''.__('Min.').''; +$table->data['edit1'][3] .= print_input_text ('min_critical', '', '', 5, 15, true); +$table->data['edit1'][3] .= '
'.__('Max.').''; +$table->data['edit1'][3] .= print_input_text ('max_critical', '', '', 5, 15, true); + +/* FF stands for Flip-flop */ +$table->data['edit2'][0] = __('FF threshold').' '.pandora_help ('ff_threshold', true); +$table->data['edit2'][1] = print_input_text ('ff_event', '', '', 5, 15, true); +$table->data['edit2'][2] = __('Historical data'); +$table->data['edit2'][3] = print_checkbox ("history_data", 1, '', true); + +echo '
'; +print_table ($table); + +echo '
'; +print_input_hidden ('update', 1); +print_submit_button (__('Update'), 'go', false, 'class="sub upd"'); +echo '
'; +echo '
'; + +echo ''; + +require_jquery_file ('pandora.controls'); +?> + + diff --git a/pandora_console/godmode/agentes/massive_operations.php b/pandora_console/godmode/agentes/massive_operations.php index da27e9e5b4..a6529310d5 100644 --- a/pandora_console/godmode/agentes/massive_operations.php +++ b/pandora_console/godmode/agentes/massive_operations.php @@ -39,9 +39,15 @@ echo '