diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index adaee2269b..6143bec66b 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,8 +1,17 @@ +2009-09-09 Miguel de Dios + + * include/functions_db.php: add new function "get_all_groups", this function + return all groups. + * operation/agentes/ver_agente.php: add another code block for to respond + new ajax request (new select in form massive_edit_modules.php). + * godmode/agentes/massive_edit_modules.php: Fix in part bug #2848951 in + tracker sourceforge, rest things for to do is add more fields. + 2009-09-07 Miguel de Dios * godmode/agentes/massive_edit_modules.php: now the select of Module name have got all modules but you can filter in the select of - Module type. Fix in part but #2848951 in tracker sourceforge, exactly + Module type. Fix in part bug #2848951 in tracker sourceforge, exactly the first paragraph of bug. 2009-09-07 Miguel de Dios diff --git a/pandora_console/godmode/agentes/massive_edit_modules.php b/pandora_console/godmode/agentes/massive_edit_modules.php index e74f0bed43..4e48e0e56a 100644 --- a/pandora_console/godmode/agentes/massive_edit_modules.php +++ b/pandora_console/godmode/agentes/massive_edit_modules.php @@ -28,16 +28,26 @@ require_once ('include/functions_modules.php'); echo '

'.__('Massive modules edition').'

'; -function process_manage_edit ($module_name) { +function process_manage_edit ($module_name, $group_select = null, $agents_select = null) { 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")); + if (($group_select === null) || ($group_select == 0)) + $agents = array_keys (get_group_agents (array_keys (get_user_groups ()), false, "none")); + else { + if (($agents_select === null) || ($agents_select == 0)) { + $agents = array_keys (get_group_agents ($group_select, false, "none")); + } + else { + $agents = $agents_select; + } + } /* List of fields which can be updated */ - $fields = array ('min_warning', 'max_warning', 'min_critical', 'max_critical', 'min_ff_event'); + $fields = array ('min_warning', 'max_warning', 'min_critical', 'max_critical', 'min_ff_event','module_interval', + 'disabled','post_process','snmp_community','min','max','id_module_group'); $values = array (); foreach ($fields as $field) { $value = get_parameter ($field); @@ -71,11 +81,15 @@ function process_manage_edit ($module_name) { $module_type = (int) get_parameter ('module_type'); $module_name = (string) get_parameter ('module_name'); +$idGroupMassive = (int) get_parameter('id_group_massive'); +$idAgentMassive = (int) get_parameter('id_agent_massive'); +$group_select = get_parameter('groups_select'); +$agents_select = get_parameter('agents_select'); $update = (bool) get_parameter_post ('update'); if ($update) { - $result = process_manage_edit ($module_name); + $result = process_manage_edit ($module_name, $group_select, $agents_select); print_result_message ($result, __('Successfully updated'), @@ -98,6 +112,9 @@ $table->size[3] = '35%'; if (! $module_type) { $table->rowstyle['edit1'] = 'display: none'; $table->rowstyle['edit2'] = 'display: none'; + $table->rowstyle['edit3'] = 'display: none'; + $table->rowstyle['edit4'] = 'display: none'; + $table->rowstyle['edit5'] = 'display: none'; } $agents = get_group_agents (array_keys (get_user_groups ()), false, "none"); $module_types = get_db_all_rows_filter ('tagente_modulo,ttipo_modulo', @@ -137,11 +154,21 @@ $names = get_agent_modules (array_keys ($agents), foreach ($names as $name) { $modules[$name['nombre']] = $name['nombre']; } +$agents = null; $table->data[0][2] = __('Module name'); $table->data[0][3] = print_select ($modules, 'module_name', $module_name, false, __('Select'), 0, true, false, false); +$table->rowstyle[1] = 'vertical-align: top;'; +$table->data[1][0] = __('Agent group'); +$table->data[1][1] = print_select (get_all_groups(true), 'groups_select', + $idGroupMassive, false, __('All'), 0, true, false, false); +$table->data[1][2] = __('Agents'); +$table->data[1][3] = print_select ($agents, 'agents_select[]', + $idAgentMassive, false, __('All'), 0, true, true, false); + + $table->data['edit1'][0] = __('Warning status'); $table->data['edit1'][1] = ''.__('Min.').''; $table->data['edit1'][1] .= print_input_text ('min_warning', '', '', 5, 15, true); @@ -153,11 +180,30 @@ $table->data['edit1'][3] .= print_input_text ('min_critical', '', '', 5, 15, tru $table->data['edit1'][3] .= '
'.__('Max.').''; $table->data['edit1'][3] .= print_input_text ('max_critical', '', '', 5, 15, true); +$table->data['edit2'][0] = __('Interval'); +$table->data['edit2'][1] = print_input_text ('module_interval', '', '', 5, 15, true); +$table->data['edit2'][2] = __('Disabled'); +$table->data['edit2'][3] = print_checkbox ("disabled", 1, '', true); + +$table->data['edit3'][0] = __('Post process'); +$table->data['edit3'][1] = print_input_text ('post_process', '', '', 10, 15, true); +$table->data['edit3'][2] = __('SMNP community'); +$table->data['edit3'][3] = print_input_text ('snmp_community', '', '', 10, 15, true); + +$table->data['edit4'][0] = __('Value'); +$table->data['edit4'][1] = ''.__('Min.').''; +$table->data['edit4'][1] .= print_input_text ('min', '', '', 5, 15, true); +$table->data['edit4'][1] .= '
'.__('Max.').''; +$table->data['edit4'][1] .= print_input_text ('max', '', '', 5, 15, true); +$table->data['edit4'][2] = __('Group'); +$table->data['edit4'][3] = print_select (get_modulegroups(), + 'id_module_group', '', '', __('Select'), 0, true, false, false); + /* FF stands for Flip-flop */ -$table->data['edit2'][0] = __('FF threshold').' '.print_help_icon ('ff_threshold', true); -$table->data['edit2'][1] = print_input_text ('min_ff_event', '', '', 5, 15, true); -$table->data['edit2'][2] = __('Historical data'); -$table->data['edit2'][3] = print_checkbox ("history_data", 1, '', true); +$table->data['edit5'][0] = __('FF threshold').' '.print_help_icon ('ff_threshold', true); +$table->data['edit5'][1] = print_input_text ('min_ff_event', '', '', 5, 15, true); +$table->data['edit5'][2] = __('Historical data'); +$table->data['edit5'][3] = print_checkbox ("history_data", 1, '', true); echo '
'; print_table ($table); @@ -209,15 +255,39 @@ $(document).ready (function () { $("#module_name").change (function () { if (this.value <= 0) { - $("td#delete_table-0-1").css ("width", "85%"); - $("tr#delete_table-edit1, tr#delete_table-edit2").hide (); +// $("td#delete_table-0-1").css ("width", "85%"); + $("tr#delete_table-edit1, tr#delete_table-edit2, tr#delete_table-edit3, tr#delete_table-edit4, tr#delete_table-edit5").hide (); return; } $("td#delete_table-0-1, td#delete_table-edit1-1, td#delete_table-edit2-1").css ("width", "35%"); $("#form_edit input[type=text]").attr ("value", ""); $("#form_edit input[type=checkbox]").removeAttr ("checked"); - $("tr#delete_table-edit1, tr#delete_table-edit2").show (); + $("tr#delete_table-edit1, tr#delete_table-edit2, tr#delete_table-edit3, tr#delete_table-edit4, tr#delete_table-edit5").show (); }); + + $("#groups_select").change ( + function () { + jQuery.post ("ajax.php", + {"page" : "operation/agentes/ver_agente", + "get_agents_group_json" : 1, + "id_group" : this.value, + }, + function (data, status) { + $("#agents_select").html(''); + option = $("").attr ("value", 0).html ("").attr ("selected", "selected"); + $("#agents_select").append (option); + + jQuery.each (data, function (id, value) { + option = $("").attr ("value", value["id_agente"]).html (value["nombre"]); + $("#agents_select").append (option); + }); + }, + "json" + ); + } + ); + + }); /* ]]> */ diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 82c634b6c5..82b788395d 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -1173,6 +1173,24 @@ function give_agentmodule_flag ($id_agent_module) { return get_db_value ('flag', 'tagente_modulo', 'id_agente_modulo', $id_agent_module); } +/** + * Get all groups in array with index as id_group + */ +function get_all_groups($groupWithAgents = false) { + $sql = 'SELECT id_grupo, nombre FROM tgrupo'; + + if ($groupWithAgents) + $sql .= ' WHERE id_grupo IN (SELECT id_grupo FROM tagente GROUP BY id_grupo)'; + + $rows = get_db_all_rows_sql ($sql); + + $return = array(); + foreach ($rows as $row) + $return[$row['id_grupo']] = $row['nombre']; + + return $return; +} + /** * Prints a list of HTML tags with the groups the user has * reading privileges. diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 37c7600cfd..0e874c9f18 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -26,6 +26,16 @@ if (is_ajax ()) { $get_agent_json = (bool) get_parameter ('get_agent_json'); $get_agent_modules_json = (bool) get_parameter ('get_agent_modules_json'); $get_agent_status_tooltip = (bool) get_parameter ("get_agent_status_tooltip"); + $get_agents_group_json = (bool) get_parameter ("get_agents_group_json"); + + if ($get_agents_group_json) { + $id_group = get_parameter('id_group'); + + $agents = get_db_all_rows_sql("SELECT id_agente, nombre FROM tagente WHERE id_grupo = ". $id_group); + + echo json_encode($agents); + return; + } if ($get_agent_json) { $id_agent = (int) get_parameter ('id_agent');