From 79914082e9aa999a20249fea680457faf14fa24f Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Wed, 24 Mar 2021 15:16:13 +0000 Subject: [PATCH] Ent 6850 quitar nta --- .../extras/delete_files/delete_files.txt | 3 +- .../reporting_builder.item_editor.php | 13 -- .../godmode/reporting/reporting_builder.php | 18 --- .../godmode/setup/setup_general.php | 8 - pandora_console/include/functions_config.php | 8 - pandora_console/include/functions_network.php | 142 ------------------ .../include/functions_reporting.php | 45 ------ .../include/functions_reporting_html.php | 63 -------- pandora_console/include/functions_reports.php | 7 - pandora_console/operation/menu.php | 62 +++----- .../operation/netflow/netflow_explorer.php | 1 - .../operation/network/network_explorer.php | 40 ----- .../operation/network/network_report.php | 68 +++------ .../operation/network/network_usage_map.php | 26 +--- 14 files changed, 50 insertions(+), 454 deletions(-) delete mode 100644 pandora_console/operation/network/network_explorer.php diff --git a/pandora_console/extras/delete_files/delete_files.txt b/pandora_console/extras/delete_files/delete_files.txt index f21a69a040..2419ea0cb3 100644 --- a/pandora_console/extras/delete_files/delete_files.txt +++ b/pandora_console/extras/delete_files/delete_files.txt @@ -73,4 +73,5 @@ enterprise/extensions/ipam.php enterprise/extensions/ipam enterprise/extensions/disabled/visual_console_manager.php enterprise/extensions/visual_console_manager.php -pandora_console/extensions/net_tools.php \ No newline at end of file +pandora_console/extensions/net_tools.php +operation/network/network_explorer.php diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index 0a6c53d766..135c915b76 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -770,12 +770,6 @@ switch ($action) { // Max values. break; - case 'nt_top_n': - $period = $item['period']; - $description = $item['description']; - $top_n_value = $item['top_n_value']; - break; - case 'permissions_report': $description = $item['description']; $es = json_decode($item['external_source'], true); @@ -818,7 +812,6 @@ switch ($action) { case 'simple_baseline_graph': case 'event_report_log': case 'increment': - case 'nt_top_n': $label = (isset($style['label'])) ? $style['label'] : ''; break; @@ -5908,12 +5901,6 @@ function chooseType() { $("#row_historical_db_check").hide(); break; - case 'nt_top_n': - $("#row_description").show(); - $("#row_period").show(); - $("#row_quantity").show(); - break; - case 'permissions_report': $("#row_description").show(); $("#row_users").show(); diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 7b38abef62..d4967be810 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1718,14 +1718,6 @@ switch ($action) { $good_format = true; break; - case 'nt_top_n': - $values['period'] = get_parameter('period'); - $values['top_n_value'] = get_parameter( - 'quantity' - ); - $good_format = true; - break; - default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( @@ -2093,7 +2085,6 @@ switch ($action) { case 'projection_graph': case 'prediction_date': case 'simple_baseline_graph': - case 'nt_top_n': if ($label != '') { $style['label'] = $label; } else { @@ -2379,14 +2370,6 @@ switch ($action) { $good_format = true; break; - case 'nt_top_n': - $values['top_n_value'] = get_parameter( - 'quantity' - ); - $values['period'] = get_parameter('period'); - $good_format = true; - break; - default: $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( @@ -2727,7 +2710,6 @@ switch ($action) { case 'projection_graph': case 'prediction_date': case 'simple_baseline_graph': - case 'nt_top_n': if ($label != '') { $style['label'] = $label; } else { diff --git a/pandora_console/godmode/setup/setup_general.php b/pandora_console/godmode/setup/setup_general.php index 6401cd2949..fbd33b8a90 100644 --- a/pandora_console/godmode/setup/setup_general.php +++ b/pandora_console/godmode/setup/setup_general.php @@ -242,14 +242,6 @@ $table->data[$i++][1] = html_print_checkbox_switch_extended( true ); -$table->data[$i][0] = __('Enable Network Traffic Analyzer'); -$table->data[$i++][1] = html_print_switch( - [ - 'name' => 'activate_nta', - 'value' => $config['activate_nta'], - ] -); - $zone_name = [ 'Africa' => __('Africa'), diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index a5fe9e2f93..49ae33b20d 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -225,10 +225,6 @@ function config_update_config() $error_update[] = __('Enable Netflow'); } - if (!config_update_value('activate_nta', (bool) get_parameter_switch('activate_nta'))) { - $error_update[] = __('Enable Network Traffic Analyzer'); - } - $timezone = (string) get_parameter('timezone'); if ($timezone != '') { if (!config_update_value('timezone', $timezone)) { @@ -2369,10 +2365,6 @@ function config_process_config() config_update_value('activate_netflow', 0); } - if (!isset($config['activate_nta'])) { - config_update_value('activate_nta', 0); - } - if (!isset($config['netflow_path'])) { if ($is_windows) { $default = 'C:\PandoraFMS\Pandora_Server\data_in\netflow'; diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php index 9d81bf8bdc..9df4f8dbc4 100644 --- a/pandora_console/include/functions_network.php +++ b/pandora_console/include/functions_network.php @@ -21,70 +21,6 @@ // Write here requires and definitions. -/** - * Get the tnetwok_matrix summatory data. - * - * @param integer $top Number of hosts to show. - * @param boolean $talker Talker (true) or listetener (false). - * @param integer $start Utimestamp of start time. - * @param integer $end Utimestamp of end time. - * @param string $ip_filter Ip to filter. - * @param boolean $order_by_bytes True by top by bytes. False by packets. - * @param array $host_filter Host filter array. - * - * @return array With requested data. - */ -function network_matrix_get_top( - $top, - $talker, - $start, - $end, - $ip_filter='', - $order_by_bytes=true, - $host_filter=[] -) { - $field_to_group = ($talker === true) ? 'source' : 'destination'; - $field_to_order = ($order_by_bytes === true) ? 'sum_bytes' : 'sum_pkts'; - $filter_sql = ''; - if (!empty($ip_filter)) { - $filter_field = ($talker === true) ? 'destination' : 'source'; - $filter_sql = sprintf('AND %s="%s"', $filter_field, $ip_filter); - } - - $host_filter_sql = ''; - if (!empty($host_filter)) { - $host_filter_sql = sprintf( - ' AND %s IN ("%s")', - $field_to_group, - implode('","', $host_filter) - ); - } - - $sql = sprintf( - 'SELECT SUM(bytes) sum_bytes, SUM(pkts) sum_pkts, %s host - FROM tnetwork_matrix - WHERE utimestamp > %d AND utimestamp < %d - %s - %s - GROUP BY %s - ORDER BY %s DESC - LIMIT %d', - $field_to_group, - $start, - $end, - $filter_sql, - $host_filter_sql, - $field_to_group, - $field_to_order, - $top - ); - - $data = db_get_all_rows_sql($sql); - - return ($data !== false) ? $data : []; -} - - /** * Get the possible actions on networking. * @@ -169,84 +105,6 @@ function network_format_bytes($value) } -/** - * Build netflow data structure to network map. - * - * @param integer $start Time in timestamp format. - * @param integer $end Time in timestamp format. - * @param integer $top Max data to show. - * @param boolean $talker True to get top tolkers. False for listeners. - * - * @return array With map structure. - */ -function network_build_map_data($start, $end, $top, $talker) -{ - $data = network_matrix_get_top($top, $talker, $start, $end); - - $hosts = array_map( - function ($elem) { - return $elem['host']; - }, - $data - ); - $inverse_hosts = array_flip($hosts); - - $nodes = array_map( - function ($elem) { - return network_init_node_map($elem); - }, - $hosts - ); - - $relations = []; - $orphan_relations = []; - foreach ($hosts as $host) { - $host_top = network_matrix_get_top( - $top, - !$talker, - $start, - $end, - $host, - true, - $hosts - ); - foreach ($host_top as $sd) { - $src_index = $inverse_hosts[$host]; - $dst_index = $inverse_hosts[$sd['host']]; - if (isset($src_index) === false || isset($dst_index) === false) { - continue; - } - - network_init_relation_map( - $relations, - $src_index, - $dst_index, - network_format_bytes($sd['sum_bytes']) - ); - } - - // Put the orphans on Other node. - if (empty($host_top)) { - $other_id = (end($inverse_hosts) + 1); - // TODOS: Add the data. - network_init_relation_map( - $orphan_relations, - $other_id, - $inverse_hosts[$host] - ); - } - } - - // Put the Others node and their relations. - if (empty($orphan_relations) === false) { - $nodes[] = network_init_node_map(__('Others')); - $relations = array_merge($relations, $orphan_relations); - } - - return network_general_map_configuration($nodes, $relations); -} - - /** * Return the array to pass to constructor to NetworkMap. * diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 8e0aafe5fb..aab903a361 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -851,14 +851,6 @@ function reporting_make_reporting_data( ); break; - case 'nt_top_n': - $report['contents'][] = reporting_nt_top_n_report( - $report, - $content, - $pdf - ); - break; - default: // Default. break; @@ -13580,43 +13572,6 @@ function reporting_header_table_for_pdf($title='', $description='') } -/** - * Build the required data to build network traffic top N report - * - * @param int Period (time window). - * @param array Information about the item of report. - * @param bool Pdf or not - * - * @return array With report presentation info and report data. - */ -function reporting_nt_top_n_report($period, $content, $pdf) -{ - $return = []; - $return['type'] = 'nt_top_n'; - $return['title'] = $content['name']; - $return['landscape'] = $content['landscape']; - $return['pagebreak'] = $content['pagebreak']; - $return['description'] = $content['description']; - - // Get the data sent and received - $return['data'] = []; - $start_time = ($period['datetime'] - (int) $content['period']); - $return['data']['send'] = network_matrix_get_top( - $content['top_n_value'], - true, - $start_time, - $period['datetime'] - ); - $return['data']['recv'] = network_matrix_get_top( - $content['top_n_value'], - false, - $start_time, - $period['datetime'] - ); - return $return; -} - - /** * Will display an hourly analysis of the selected period. * diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 0733a8a06d..9877842e0a 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -403,10 +403,6 @@ function reporting_html_print_report($report, $mini=false, $report_info=1) reporting_enterprise_html_SLA_monthly($table, $item, $mini); break; - case 'nt_top_n': - reporting_html_nt_top_n($table, $item, $mini); - break; - case 'SLA_weekly': reporting_enterprise_html_SLA_weekly($table, $item, $mini); break; @@ -5591,65 +5587,6 @@ function reporting_get_event_histogram_meta($width) } -/** - * Print network traffic data into top n tables - * (one for received data and another for sent) - * - * @param stdClass Table class to paint the report - * @param array Associative array with info about - * @param bool Unused - */ -function reporting_html_nt_top_n($table, $item, $mini) -{ - // Prepare the table - $table_top = new stdClass(); - $table_top->cellpadding = 0; - $table_top->cellspacing = 0; - $table_top->width = '100%'; - $table_top->class = 'databox data'; - $table_top->cellpadding = 0; - $table_top->cellspacing = 0; - $table_top->width = '100%'; - $table_top->class = 'databox data'; - $table_top->head['host'] = __('Agent'); - $table_top->head['bytes'] = __('Kilobytes'); - $table_top->head['pkts'] = __('Packages'); - - // Build the table for sent packages - if (empty($item['data']['send'])) { - $table->data['send_title'] = '

'.__('No network traffic sent data').'

'; - } else { - foreach ($item['data']['send'] as $s_item) { - $table_top->data[] = [ - 'host' => $s_item['host'], - 'bytes' => remove_right_zeros(number_format(($s_item['sum_bytes'] / 1024), $config['graph_precision'])), - 'pkts' => remove_right_zeros(number_format($s_item['sum_pkts'], $config['graph_precision'])), - ]; - } - - $table->data['send_title'] = '

'.__('Network traffic sent').'

'; - $table->data['send'] = html_print_table($table_top, true); - } - - // Reset the table and build the table for received packages - $table_top->data = []; - if (empty($item['data']['send'])) { - $table->data['recv_title'] = '

'.__('No network traffic received data').'

'; - } else { - foreach ($item['data']['recv'] as $s_item) { - $table_top->data[] = [ - 'host' => $s_item['host'], - 'bytes' => remove_right_zeros(number_format(($s_item['sum_bytes'] / 1024), $config['graph_precision'])), - 'pkts' => remove_right_zeros(number_format($s_item['sum_pkts'], $config['graph_precision'])), - ]; - } - - $table->data['recv_title'] = '

'.__('Network traffic received').'

'; - $table->data['recv'] = html_print_table($table_top, true); - } -} - - function reporting_html_planned_downtimes_table($planned_downtimes) { global $config; diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index 192940c8ed..fbf647d392 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -891,13 +891,6 @@ function reports_get_report_types($template=false, $not_editor=false) ]; } - if (!is_metaconsole()) { - $types['nt_top_n'] = [ - 'optgroup' => __('Network traffic'), - 'name' => __('Network Traffic Top N'), - ]; - } - if ($template === false) { $types['permissions_report'] = [ 'optgroup' => __('Permissions report'), diff --git a/pandora_console/operation/menu.php b/pandora_console/operation/menu.php index 5c30612969..d43829b753 100644 --- a/pandora_console/operation/menu.php +++ b/pandora_console/operation/menu.php @@ -67,7 +67,7 @@ if (check_acl($config['id_user'], 0, 'AR')) { enterprise_hook('inventory_menu'); - if ($config['activate_netflow'] || $config['activate_nta']) { + if ($config['activate_netflow']) { $sub['network_traffic'] = [ 'text' => __('Network'), 'id' => 'Network', @@ -79,45 +79,29 @@ if (check_acl($config['id_user'], 0, 'AR')) { // Initialize the submenu. $netflow_sub = []; - if ($config['activate_netflow']) { - $netflow_sub = array_merge( - $netflow_sub, - [ - 'operation/netflow/netflow_explorer' => [ - 'text' => __('Netflow explorer'), - 'id' => 'Netflow explorer', - ], - 'operation/netflow/nf_live_view' => [ - 'text' => __('Netflow Live View'), - 'id' => 'Netflow Live View', - ], - ] - ); - } + $netflow_sub = array_merge( + $netflow_sub, + [ + 'operation/netflow/netflow_explorer' => [ + 'text' => __('Netflow explorer'), + 'id' => 'Netflow explorer', + ], + 'operation/netflow/nf_live_view' => [ + 'text' => __('Netflow Live View'), + 'id' => 'Netflow Live View', + ], + ] + ); - if ($config['activate_nta']) { - $netflow_sub = array_merge( - $netflow_sub, - [ - 'operation/network/network_explorer' => [ - 'text' => __('Network explorer'), - 'id' => 'Network explorer', - ], - ] - ); - } - - if ($config['activate_nta'] || $config['activate_netflow']) { - $netflow_sub = array_merge( - $netflow_sub, - [ - 'operation/network/network_usage_map' => [ - 'text' => __('Network usage map'), - 'id' => 'Network usage map', - ], - ] - ); - } + $netflow_sub = array_merge( + $netflow_sub, + [ + 'operation/network/network_usage_map' => [ + 'text' => __('Network usage map'), + 'id' => 'Network usage map', + ], + ] + ); $sub['network_traffic']['sub2'] = $netflow_sub; } diff --git a/pandora_console/operation/netflow/netflow_explorer.php b/pandora_console/operation/netflow/netflow_explorer.php index dea519adbd..baff5da32f 100644 --- a/pandora_console/operation/netflow/netflow_explorer.php +++ b/pandora_console/operation/netflow/netflow_explorer.php @@ -33,7 +33,6 @@ if (! check_acl($config['id_user'], 0, 'AR')) { } $action = get_parameter('action', 'listeners'); -$is_network = false; ui_print_page_header(__('Netflow explorer')); diff --git a/pandora_console/operation/network/network_explorer.php b/pandora_console/operation/network/network_explorer.php deleted file mode 100644 index 3e929fd183..0000000000 --- a/pandora_console/operation/network/network_explorer.php +++ /dev/null @@ -1,40 +0,0 @@ -class = 'databox filters'; $table->styleTable = 'width: 100%'; $table->data['0']['0'] = __('Data to show').'  '; $table->data['0']['0'] .= html_print_select( - network_get_report_actions($is_network), + network_get_report_actions(false), 'action', $action, '', @@ -155,25 +155,14 @@ echo ''; // Print the data. $data = []; -if ($is_network) { - $data = network_matrix_get_top( - $top, - $action === 'talkers', - $utimestamp_lower, - $utimestamp_greater, - $main_value, - $order_by !== 'pkts' - ); -} else { - $data = netflow_get_top_summary( - $top, - $action, - $utimestamp_lower, - $utimestamp_greater, - $main_value, - $order_by - ); -} +$data = netflow_get_top_summary( + $top, + $action, + $utimestamp_lower, + $utimestamp_greater, + $main_value, + $order_by +); // Get the params to return the builder. $hidden_main_link = [ @@ -193,17 +182,16 @@ $table->styleTable = 'width: 60%'; // Print the header. $table->head = []; $table->head['main'] = __('IP'); -if (!$is_network) { - $table->head['flows'] = network_print_explorer_header( - __('Flows'), - 'flows', - $order_by, - array_merge( - $hidden_main_link, - ['main_value' => $main_value] - ) - ); -} +$table->head['flows'] = network_print_explorer_header( + __('Flows'), + 'flows', + $order_by, + array_merge( + $hidden_main_link, + ['main_value' => $main_value] + ) +); + $table->head['pkts'] = network_print_explorer_header( __('Packets'), @@ -242,9 +230,7 @@ if (get_parameter('export_csv')) { // Print the header. echo reset($table->head).$div; - if (!$is_network) { - echo __('Flows').$div; - } + echo __('Flows').$div; echo __('Packets').$div; echo __('Bytes').$div; @@ -295,20 +281,14 @@ foreach ($data as $item) { } $row['main'] .= ''; - if (!$is_network) { - $row['flows'] = format_for_graph($item['sum_flows'], 2); - $row['flows'] .= ' ('.$item['pct_flows'].'%)'; - } + $row['flows'] = format_for_graph($item['sum_flows'], 2); + $row['flows'] .= ' ('.$item['pct_flows'].'%)'; $row['pkts'] = format_for_graph($item['sum_pkts'], 2); - if (!$is_network) { - $row['pkts'] .= ' ('.$item['pct_pkts'].'%)'; - } + $row['pkts'] .= ' ('.$item['pct_pkts'].'%)'; $row['bytes'] = network_format_bytes($item['sum_bytes']); - if (!$is_network) { - $row['bytes'] .= ' ('.$item['pct_bytes'].'%)'; - } + $row['bytes'] .= ' ('.$item['pct_bytes'].'%)'; $table->data[] = $row; diff --git a/pandora_console/operation/network/network_usage_map.php b/pandora_console/operation/network/network_usage_map.php index 391905197d..5a91e0563b 100644 --- a/pandora_console/operation/network/network_usage_map.php +++ b/pandora_console/operation/network/network_usage_map.php @@ -121,7 +121,6 @@ $table->data['0']['2'] .= html_print_select( true ); - $table->data['1']['0'] = __('Data to show').'  '; $table->data['1']['0'] .= html_print_select( network_get_report_actions(), @@ -145,23 +144,9 @@ if ((bool) $config['activate_netflow'] === true) { ); } -$nta_button = ''; -if ((bool) $config['activate_nta'] === true) { - $nta_button = html_print_submit_button( - __('Show NTA map'), - 'update_nta', - false, - 'class="sub upd"', - true - ); -} - $table->data['1']['2'] .= implode( '  ', - [ - $netflow_button, - $nta_button, - ] + [$netflow_button] ); echo '
'; @@ -181,15 +166,6 @@ if ((bool) get_parameter('update_netflow') === true) { ); $has_data = !empty($map_data['nodes']); $first_load = false; -} else if ((bool) get_parameter('update_nta') === true) { - $map_data = network_build_map_data( - $utimestamp_lower, - $utimestamp_greater, - $top, - $action === 'talkers' - ); - $has_data = !empty($map_data['nodes']); - $first_load = false; } if ($has_data === true) {