From 28b879f0585f80573407225fa541b115e57cbaed Mon Sep 17 00:00:00 2001 From: fermin831 Date: Tue, 2 Oct 2018 09:48:29 +0200 Subject: [PATCH] [Tags performance] Added TODOS to revise agents_get_modules --- pandora_console/extensions/agents_modules.php | 3 +++ pandora_console/extensions/insert_data.php | 1 + pandora_console/extras/pandora_diag.php | 2 +- .../godmode/alerts/alert_list.builder.php | 1 + .../godmode/massive/massive_add_tags.php | 1 + .../godmode/massive/massive_copy_modules.php | 1 + .../godmode/massive/massive_delete_alerts.php | 1 + .../massive/massive_delete_modules.php | 4 +++- .../godmode/massive/massive_edit_modules.php | 2 +- .../visual_console_builder.elements.php | 1 + .../reporting/visual_console_builder.php | 2 +- .../ajax/visual_console_builder.ajax.php | 3 +++ pandora_console/include/functions_agents.php | 12 +++++++---- pandora_console/include/functions_graph.php | 2 ++ pandora_console/include/functions_modules.php | 4 ++-- .../include/functions_networkmap.php | 20 ++++++------------- .../include/functions_reporting.php | 8 ++++---- .../include/functions_reporting_html.php | 1 + .../agentes/estado_generalagente.php | 1 - .../operation/agentes/estado_monitores.php | 3 --- .../operation/agentes/exportdata.php | 1 + pandora_console/operation/agentes/graphs.php | 6 +++--- .../agentes/pandora_networkmap.view.php | 2 +- .../operation/agentes/ver_agente.php | 5 ++--- 24 files changed, 48 insertions(+), 39 deletions(-) diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index 790a16ec15..8e33c4180e 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -285,6 +285,7 @@ function mainAgentsModules() { $count = 0; foreach ($agents as $agent) { + // TODO TAGS agents_get_modules $module = agents_get_modules($agent, false, $filter_module_group, true, true); if ($module == false) { @@ -327,6 +328,7 @@ function mainAgentsModules() { } } else { + // TODO TAGS agents_get_modules $all_modules = agents_get_modules($agents, false, $filter_module_group, true, true); } @@ -487,6 +489,7 @@ function mainAgentsModules() { " . $alias['alias'] . ""; + // TODO TAGS agents_get_modules $agent_modules = agents_get_modules($agent['id_agente'], false, $filter_module_group, true, true); $nmodules = 0; diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index 5cfcc331d0..698938aa63 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -174,6 +174,7 @@ function mainInsertData() { $table->data[1][0] = __('Module'); $modules = array (); if ($agent_id){ + // TODO TAGS agents_get_modules $modules = agents_get_modules ($agent_id, false, array("delete_pending" => 0)); } $table->data[1][1] = html_print_select ($modules, 'id_agent_module', $id_agent_module, true, diff --git a/pandora_console/extras/pandora_diag.php b/pandora_console/extras/pandora_diag.php index 4c851238ad..0b4be02ae1 100644 --- a/pandora_console/extras/pandora_diag.php +++ b/pandora_console/extras/pandora_diag.php @@ -612,7 +612,7 @@ echo "data[0][0] = __('Module'); $modules = array (); +// TODO TAGS agents_get_modules if ($id_agente) $modules = agents_get_modules ($id_agente, false, array("delete_pending" => 0)); diff --git a/pandora_console/godmode/massive/massive_add_tags.php b/pandora_console/godmode/massive/massive_add_tags.php index 6d97f0d9e9..729f2dcfcb 100755 --- a/pandora_console/godmode/massive/massive_add_tags.php +++ b/pandora_console/godmode/massive/massive_add_tags.php @@ -55,6 +55,7 @@ function process_manage_add ($id_agents, $modules, $id_tags) { if (count($modules) == 1 && $modules[0] == '0') { foreach ($id_agents as $id_agent) { + // TODO TAGS agents_get_modules $modules_temp = agents_get_modules($id_agent); foreach ($modules_temp as $id_module => $name_module) { $modules_id[] = $id_module; diff --git a/pandora_console/godmode/massive/massive_copy_modules.php b/pandora_console/godmode/massive/massive_copy_modules.php index aae7d4e2df..23739110d1 100755 --- a/pandora_console/godmode/massive/massive_copy_modules.php +++ b/pandora_console/godmode/massive/massive_copy_modules.php @@ -120,6 +120,7 @@ $table->class = 'databox filters'; $table->data = array (); $modules = array (); +// TODO TAGS agents_get_modules if ($source_id_agent) $modules = agents_get_modules ($source_id_agent, 'nombre'); diff --git a/pandora_console/godmode/massive/massive_delete_alerts.php b/pandora_console/godmode/massive/massive_delete_alerts.php index eb0fd60dc3..f96f467672 100755 --- a/pandora_console/godmode/massive/massive_delete_alerts.php +++ b/pandora_console/godmode/massive/massive_delete_alerts.php @@ -120,6 +120,7 @@ function process_manage_delete ($id_alert_template, $id_agents, $module_names) { $modules_id = array(); foreach ($id_agents as $id_agent) { + // TODO TAGS agents_get_modules $current_modules_agent = agents_get_modules($id_agent, 'id_agente_modulo', array ('disabled' => 0)); if ($current_modules_agent != false) { // And their modules diff --git a/pandora_console/godmode/massive/massive_delete_modules.php b/pandora_console/godmode/massive/massive_delete_modules.php index d1dd485db2..26bcb7ec19 100755 --- a/pandora_console/godmode/massive/massive_delete_modules.php +++ b/pandora_console/godmode/massive/massive_delete_modules.php @@ -137,6 +137,7 @@ function process_manage_delete ($module_name, $id_agents, $module_status = 'all' } } else { + // TODO TAGS agents_get_modules $modules = agents_get_modules ($id_agents, 'id_agente_modulo', $filter_for_module_deletion, true); } @@ -212,6 +213,7 @@ function process_manage_delete ($module_name, $id_agents, $module_status = 'all' } } else { + // TODO TAGS agents_get_modules $modules = agents_get_modules ($id_agents, 'id_agente_modulo', sprintf('nombre IN ("%s")', implode('","',$module_name)), true); } @@ -439,7 +441,7 @@ if ($module_type != '') { else { $filter = false; } - +// TODO TAGS agents_get_modules $names = agents_get_modules (array_keys ($agents), 'DISTINCT(nombre)', $filter, false); foreach ($names as $name) { diff --git a/pandora_console/godmode/massive/massive_edit_modules.php b/pandora_console/godmode/massive/massive_edit_modules.php index e7f92d4594..4d326a8e22 100755 --- a/pandora_console/godmode/massive/massive_edit_modules.php +++ b/pandora_console/godmode/massive/massive_edit_modules.php @@ -276,7 +276,7 @@ if ($module_type != '') { else { $filter = false; } - +// TODO TAGS agents_get_modules $names = agents_get_modules (array_keys ($agents), 'DISTINCT(nombre)', $filter, false); foreach ($names as $name) { diff --git a/pandora_console/godmode/reporting/visual_console_builder.elements.php b/pandora_console/godmode/reporting/visual_console_builder.elements.php index c7e63358fa..3bd89eba92 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.elements.php +++ b/pandora_console/godmode/reporting/visual_console_builder.elements.php @@ -416,6 +416,7 @@ foreach ($layoutDatas as $layoutData) { } if ($cell_content_enterprise === false) { if (!defined('METACONSOLE')) { + // TODO TAGS agents_get_modules $modules = agents_get_modules($layoutData['id_agent']); } else { diff --git a/pandora_console/godmode/reporting/visual_console_builder.php b/pandora_console/godmode/reporting/visual_console_builder.php index 6e3654f914..bfe7c3228a 100755 --- a/pandora_console/godmode/reporting/visual_console_builder.php +++ b/pandora_console/godmode/reporting/visual_console_builder.php @@ -560,7 +560,7 @@ switch ($activeTab) { foreach ($name_modules as $mod) { foreach ($id_agents as $ag) { - + // TODO TAGS agents_get_modules $id_module = agents_get_modules($ag, array('id_agente_modulo'), array('nombre' => $mod)); diff --git a/pandora_console/include/ajax/visual_console_builder.ajax.php b/pandora_console/include/ajax/visual_console_builder.ajax.php index 98be4f174b..1226e2a09c 100755 --- a/pandora_console/include/ajax/visual_console_builder.ajax.php +++ b/pandora_console/include/ajax/visual_console_builder.ajax.php @@ -960,6 +960,7 @@ switch ($action) { //Make the html of select box of modules about id_agent. if (($elementFields['id_agent'] != 0) &&($elementFields['id_layout_linked'] == 0)) { + // TODO TAGS agents_get_modules $modules = agents_get_modules( $elementFields['id_agent'], false, array('disabled' => 0, @@ -1022,6 +1023,7 @@ switch ($action) { $elementFields['id_agent_string'] = $elementFields['id_agent']; if (($elementFields['id_agent_string'] != 0) && ($elementFields['id_layout_linked'] == 0)) { + // TODO TAGS agents_get_modules $modules = agents_get_modules( $elementFields['id_agent'], false, array('disabled' => 0, @@ -1050,6 +1052,7 @@ switch ($action) { $elementFields['id_agent_string'] = $elementFields['id_agent']; if (($elementFields['id_agent_string'] != 0) && ($elementFields['id_layout_linked'] == 0)) { + // TODO TAGS agents_get_modules $modules = agents_get_modules( $elementFields['id_agent'], false, array('disabled' => 0, diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 6d16c72e7e..925ff4d6c6 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -205,6 +205,7 @@ function agents_get_alerts_simple ($id_agent = false, $filter = '', $options = f } else { $id_agent = (array) $id_agent; + // TODO TAGS agents_get_modules $id_modules = array_keys (agents_get_modules ($id_agent, false, array('delete_pending' => 0))); if (empty ($id_modules)) @@ -592,7 +593,7 @@ function agents_process_manage_config ($source_id_agent, $destiny_id_agents, $co $module = modules_get_agentmodule ($id_agent_module); if ($module === false) return false; - + // TODO TAGS agents_get_modules $modules = agents_get_modules ($id_destiny_agent, false, array ('nombre' => $module['nombre'], 'disabled' => false)); @@ -1349,6 +1350,7 @@ function agents_get_modules_data_count ($id_agent = 0) { foreach ($id_agent as $agent_id) { //Init value $count[$agent_id] = 0; + // TODO TAGS agents_get_modules $modules = array_keys (agents_get_modules ($agent_id)); foreach ($query as $sql) { //Add up each table's data @@ -1679,6 +1681,7 @@ function agents_get_status($id_agent = 0, $noACLs = false) { global $config; if (!$noACLs) { + // TODO TAGS agents_get_modules $modules = agents_get_modules ($id_agent, 'id_agente_modulo', array('disabled' => 0), true, false); } @@ -2126,7 +2129,7 @@ function agents_monitor_total ($id_agent, $filter = '', $disabled = false) { //Get alert fired for this agent function agents_get_alerts_fired ($id_agent, $filter="") { - + // TODO TAGS agents_get_modules $modules_agent = agents_get_modules($id_agent, "id_agente_modulo", $filter); if (empty($modules_agent)) { @@ -2374,8 +2377,7 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false) else $columns[] = 'descripcion'; - $filter = " id_agente = $agent_id AND disabled = 0 AND id_tipo_modulo IN (".implode(",", $accepted_module_types).") AND (nombre LIKE '%_ifOperStatus' OR nombre LIKE 'ifOperStatus_%')"; - + $filter = " tagente_modulo.id_agente = $agent_id AND tagente_modulo.disabled = 0 AND tagente_modulo.id_tipo_modulo IN (".implode(",", $accepted_module_types).") AND (tagente_modulo.nombre LIKE '%_ifOperStatus' OR tagente_modulo.nombre LIKE 'ifOperStatus_%')"; $modules = agents_get_modules($agent_id, $columns, $filter, true, false); if (!empty($modules)) { @@ -2441,9 +2443,11 @@ function agents_get_network_interfaces ($agents = false, $agents_filter = false) ); if($type_interface){ + // TODO TAGS agents_get_modules $interface_traffic_modules = agents_get_modules($agent_id, $columns, "nombre LIKE '". $interface_name . "_if%Octets'"); } else{ + // TODO TAGS agents_get_modules $interface_traffic_modules = agents_get_modules($agent_id, $columns, "nombre LIKE 'if%Octets_$interface_name'"); } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 53246a05f8..b268751fd4 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -2641,6 +2641,7 @@ function grafico_db_agentes_purge ($id_agent, $width = 380, $height = 300) { $query = ""; } else { + // TODO TAGS agents_get_modules $modules = agents_get_modules($id_agent); $module_ids = array_keys($modules); @@ -4836,6 +4837,7 @@ function graph_monitor_wheel ($width = 550, $height = 600, $filter = false) { $module_groups = modules_get_modulegroups(); $module_groups[0] = __('Not assigned'); + // TODO TAGS agents_get_modules $modules = agents_get_modules(array_keys($agents), '*'); $data_agents = array(); diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index f8e632dad4..c2e037b444 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -142,14 +142,14 @@ function modules_copy_agent_module_to_agent ($id_agent_module, $id_destiny_agent if ($forced_name !== false) $module['nombre'] = $forced_name; - + // TODO TAGS agents_get_modules $modules = agents_get_modules ($id_destiny_agent, false, array ('nombre' => $module['nombre'], 'disabled' => false)); // The module already exist in the target if (! empty ($modules)) return array_pop (array_keys ($modules)); - + // TODO TAGS agents_get_modules $modulesDisabled = agents_get_modules ($id_destiny_agent, false, array ('nombre' => $module['nombre'], 'disabled' => true)); diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index 4e4ad37cee..9ea4e9ef11 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -390,15 +390,11 @@ function networkmap_generate_dot ($pandora_name, $group = 0, $filter = array(); $filter['disabled'] = 0; - + // Get agent modules data - if ($strict_user) { - $modules = tags_get_agent_modules ($agent['id_agente'], false, $acltags, false, $filter, false); - } - else { - $modules = agents_get_modules($agent['id_agente'], '*', $filter, true, true); - } - + // TODO TAGS agents_get_modules + $modules = agents_get_modules($agent['id_agente'], '*', $filter, true, true); + if ($modules === false) $modules = array(); @@ -774,12 +770,8 @@ function networkmap_generate_dot_groups ($pandora_name, $group = 0, } // Get agent modules data - if ($strict_user) { - $filter['disabled'] = 0; - $modules = tags_get_agent_modules ($agent['id_agente'], false, $acltags, false, $filter, false); - } else { - $modules = agents_get_modules ($agent['id_agente'], false, array('disabled' => 0), true, false); - } + // TODO TAGS agents_get_modules + $modules = agents_get_modules ($agent['id_agente'], false, array('disabled' => 0), true, false); // Parse modules foreach ($modules as $key => $module) { diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 3429840c9d..0d4ce3b09f 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -1800,7 +1800,7 @@ function reporting_agent_module($report, $content) { $row = array(); $row['agent_status'][$agent] = agents_get_status($agent); $row['agent_name'] = agents_get_alias($agent); - + // TODO TAGS agents_get_modules $agent_modules = agents_get_modules($agent); $row['modules'] = array(); @@ -3079,7 +3079,7 @@ function reporting_alert_report_agent($report, $content) { $return["description"] = $content["description"]; $return["date"] = reporting_get_date_text($report, $content); $return['label'] = (isset($content['style']['label'])) ? $content['style']['label'] : ''; - + // TODO TAGS agents_get_modules $module_list = agents_get_modules($content['id_agent']); $data = array(); @@ -3669,7 +3669,7 @@ function reporting_agent_configuration($report, $content) { $agent_configuration['description'] = $agent_data['comentarios']; $agent_configuration['enabled'] = (int)!$agent_data['disabled']; $agent_configuration['group'] = $report["group"]; - + // TODO TAGS agents_get_modules $modules = agents_get_modules ($content['id_agent']); $agent_configuration['modules'] = array(); @@ -8313,7 +8313,7 @@ function reporting_get_agent_module_info ($id_agent, $filter = false) { } $filter = 'disabled = 0'; - + // TODO TAGS agents_get_modules $modules = agents_get_modules($id_agent, false, $filter, true, false); if ($modules === false) { diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index fd4d0a2c76..4fb6cfa4e4 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -3346,6 +3346,7 @@ function reporting_get_agent_monitors_table ($id_agent, $period = 0, $date = 0) function reporting_get_agent_modules_table ($id_agent, $period = 0, $date = 0) { $table->data = array (); $n_a_string = __('N/A').'(*)'; + // TODO TAGS agents_get_modules $modules = agents_get_modules ($id_agent, array ("nombre", "descripcion")); if ($modules === false) $modules = array(); diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index 73277400a5..f55889006f 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -273,7 +273,6 @@ $table_data->head_colspan[0] = 3; $data = array(); $data[0] = '' . __('Group') . ''; $data[1] = ''.groups_get_name ($agent["id_grupo"]).''; - // ACCESS RATE GRAPH $access_agent = db_get_value_sql("SELECT COUNT(id_agent) FROM tagent_access diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index 3fceedda4e..d3baf170e5 100755 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -138,17 +138,14 @@ echo ""; ob_start(); - print_form_filter_monitors($id_agente, $status_filter_monitor, $status_text_monitor, $status_hierachy_mode); echo "
" . html_print_image('images/spinner.gif', true) . '
'; echo "
" . - "
"; - $html_toggle = ob_get_clean(); ui_toggle($html_toggle, __('List of modules'), diff --git a/pandora_console/operation/agentes/exportdata.php b/pandora_console/operation/agentes/exportdata.php index e30001fd3c..5319d700d0 100644 --- a/pandora_console/operation/agentes/exportdata.php +++ b/pandora_console/operation/agentes/exportdata.php @@ -283,6 +283,7 @@ if (empty($export_btn) || $show_form) { $table->data[2][0] .= ui_print_help_tip(__("No modules of type string. You can not calculate their average"),true); if ($agent > 0) { + // TODO TAGS agents_get_modules $modules = agents_get_modules ($agent); } else { diff --git a/pandora_console/operation/agentes/graphs.php b/pandora_console/operation/agentes/graphs.php index eaf9b4af3d..f13c92d157 100644 --- a/pandora_console/operation/agentes/graphs.php +++ b/pandora_console/operation/agentes/graphs.php @@ -47,7 +47,7 @@ $option_type = get_parameter('option_type', 0); // - others //---------------------------------------------------------------------- $list_modules = array(); - +// TODO TAGS agents_get_modules $modules_networkmap_no_proc = agents_get_modules( $id_agente, false, array( 'id_modulo' => 2, // networkmap type @@ -62,7 +62,7 @@ $modules_networkmap_no_proc = agents_get_modules( )); if (empty($modules_networkmap_no_proc)) $modules_networkmap_no_proc = array(); - +// TODO TAGS agents_get_modules $modules_others = agents_get_modules( $id_agente, false, array( 'id_tipo_modulo' => array( @@ -77,7 +77,7 @@ $modules_others = agents_get_modules( if (empty($modules_others)) $modules_others = array(); - +// TODO TAGS agents_get_modules $modules_boolean = agents_get_modules( $id_agente, false, array( 'id_tipo_modulo' => array( diff --git a/pandora_console/operation/agentes/pandora_networkmap.view.php b/pandora_console/operation/agentes/pandora_networkmap.view.php index 32225b9ad1..f15c49e28d 100644 --- a/pandora_console/operation/agentes/pandora_networkmap.view.php +++ b/pandora_console/operation/agentes/pandora_networkmap.view.php @@ -595,7 +595,7 @@ if (is_ajax ()) { if ($check_changes_num_modules) { $id = (int)get_parameter('id', 0); - + // TODO TAGS agents_get_modules $modules = agents_get_modules($id); $return = array(); diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index 805db88671..7f67e01c43 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -29,7 +29,6 @@ ui_require_javascript_file('openlayers.pandora'); enterprise_include_once ('operation/agentes/ver_agente.php'); check_login (); - if (is_ajax ()) { $get_agent_json = (bool) get_parameter ('get_agent_json'); $get_agent_modules_json = (bool) get_parameter ('get_agent_modules_json'); @@ -718,7 +717,7 @@ if (is_ajax ()) { $id_agent = array_keys( agents_get_group_agents( array_keys (users_get_groups ()), $search, "none")); - + // TODO TAGS agents_get_modules $agent_modules = agents_get_modules ($id_agent, $fields, $filter, $indexed, true, false, $tags); } // Restore db connection @@ -731,7 +730,7 @@ if (is_ajax ()) { $id_agent = array_keys( agents_get_group_agents( array_keys(users_get_groups ()), $search, "none")); - + // TODO TAGS agents_get_modules $agent_modules = agents_get_modules ($id_agent, $fields, $filter, $indexed, true, false, $tags); }