From da08acce4f171279d89ff25059c59c10d672b8b2 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Thu, 14 Mar 2019 10:36:15 +0100 Subject: [PATCH] [Netflow live] Removed units Former-commit-id: 37d9182a46a85b44a400a50eae48cd7778a3dc84 --- pandora_console/include/functions_graph.php | 6 +- pandora_console/include/functions_netflow.php | 63 ++++--------------- .../operation/netflow/nf_live_view.php | 15 ----- 3 files changed, 14 insertions(+), 70 deletions(-) diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 6843dab8da..6e881a06b9 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -4109,7 +4109,7 @@ function fullscale_data( /** * Print an area graph with netflow aggregated */ -function graph_netflow_aggregate_area($data, $period, $width, $height, $unit='', $ttl=1, $only_image=false, $date=null) +function graph_netflow_aggregate_area($data, $period, $width, $height, $ttl=1, $only_image=false, $date=null) { global $config; global $graphic_type; @@ -4155,7 +4155,7 @@ function graph_netflow_aggregate_area($data, $period, $width, $height, $unit='', 'period' => $period, 'width' => '90%', 'height' => 450, - 'unit' => $unit, + 'unit' => 'bytes', 'only_image' => $only_image, 'homeurl' => $homeurl, 'menu' => true, @@ -4306,7 +4306,7 @@ function graph_netflow_circular_mesh($data, $radius=700) /** * Print a rectangular graph with the traffic of the ports for each IP */ -function graph_netflow_host_traffic($data, $unit, $width=700, $height=700) +function graph_netflow_host_traffic($data, $width=700, $height=700) { global $config; diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 18a604dfb3..76b75f44ae 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -289,7 +289,7 @@ function netflow_stat_table($data, $start_date, $end_date, $aggregate) * * @return The statistics table. */ -function netflow_data_table($data, $start_date, $end_date, $aggregate, $unit) +function netflow_data_table($data, $start_date, $end_date, $aggregate) { global $nfdump_date_format; @@ -346,7 +346,7 @@ function netflow_data_table($data, $start_date, $end_date, $aggregate, $unit) foreach ($data as $timestamp => $value) { $table->data[$i][0] = date($time_format, $timestamp); - $table->data[$i][1] = format_numeric($value['data']).' '.netflow_format_unit($unit); + $table->data[$i][1] = network_format_bytes($value['data']); $i++; } } @@ -463,7 +463,7 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag // Requesting remote data if (defined('METACONSOLE') && $connection_name != '') { - $data = metaconsole_call_remote_api($connection_name, 'netflow_get_data', "$start_date|$end_date|$interval_length|".base64_encode(json_encode($filter))."|$aggregate|$max|$unit".(int) $address_resolution); + $data = metaconsole_call_remote_api($connection_name, 'netflow_get_data', "$start_date|$end_date|$interval_length|".base64_encode(json_encode($filter))."|$aggregate|$max|1".(int) $address_resolution); return json_decode($data, true); } @@ -611,7 +611,7 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag $filter, $aggregate, $max, - $unit, + $absolute, $connection_name ); @@ -1107,7 +1107,6 @@ function netflow_get_valid_intervals() function netflow_draw_item($start_date, $end_date, $interval_length, $type, $filter, $max_aggregates, $connection_name='', $output='HTML', $address_resolution=false) { $aggregate = $filter['aggregate']; - $unit = $filter['output']; $interval = ($end_date - $start_date); if (defined('METACONSOLE')) { $width = 950; @@ -1121,22 +1120,20 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil switch ($type) { case '0': case 'netflow_area': - $data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, true, $connection_name, $address_resolution); + $data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, false, $connection_name, $address_resolution); if (empty($data)) { break; } if ($output == 'HTML' || $output == 'PDF') { - $html = ''.__('Unit').': '.netflow_format_unit($unit); $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); if ($interval_length != 0) { $html .= ' '._('Resolution').': '.netflow_get_resolution_name($interval_length); } - $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit), 1, false, $end_date); + $html .= graph_netflow_aggregate_area($data, $interval, $width, $height, 1, false, $end_date); return $html; } else if ($output == 'XML') { - $xml = "$unit\n"; $xml .= "$aggregate\n"; $xml .= "$interval_length\n"; $xml .= netflow_aggregate_area_xml($data); @@ -1146,26 +1143,24 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil case '2': case 'netflow_data': - $data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, false, $connection_name, $address_resolution); + $data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, true, $connection_name, $address_resolution); if (empty($data)) { break; } if ($output == 'HTML' || $output == 'PDF') { - $html = ''.__('Unit').': '.netflow_format_unit($unit); $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); if ($interval_length != 0) { $html .= ' '._('Resolution').': '.netflow_get_resolution_name($interval_length); } $html .= "
"; - $html .= netflow_data_table($data, $start_date, $end_date, $aggregate, $unit); + $html .= netflow_data_table($data, $start_date, $end_date, $aggregate); $html .= '
'; return $html; } else if ($output == 'XML') { - $xml = "$unit\n"; $xml .= "$aggregate\n"; $xml .= "$interval_length\n"; // Same as netflow_aggregate_area_xml @@ -1225,7 +1220,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $filter, $aggregate, $max_aggregates, - $unit, + true, $connection_name, $address_resolution ); @@ -1234,17 +1229,14 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil } if ($output == 'HTML') { - $html = ''.__('Unit').': '.netflow_format_unit($unit); $html .= ' '.__('Aggregate').': '.netflow_format_aggregate($aggregate); $html .= graph_netflow_aggregate_pie($data_pie, netflow_format_aggregate($aggregate)); return $html; } else if ($output == 'PDF') { - $html = ''.__('Unit').': '.netflow_format_unit($unit); $html .= ' '.__('Aggregate').": $aggregate"; $html .= graph_netflow_aggregate_pie($data_pie, netflow_format_aggregate($aggregate), 2, true); return $html; } else if ($output == 'XML') { - $xml = "$unit\n"; $xml .= "$aggregate\n"; $xml .= netflow_aggregate_pie_xml($data_pie); return $xml; @@ -1268,7 +1260,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $filter, $aggregate, $max_aggregates, - $unit, + true, $connection_name, $address_resolution ); @@ -1415,7 +1407,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil $data['children'][] = $children; } } - return graph_netflow_host_traffic($data, netflow_format_unit($unit), 'auto', 400); + return graph_netflow_host_traffic($data, 'auto', 400); break; default: @@ -1493,7 +1485,6 @@ function netflow_xml_report($id, $start_date, $end_date, $interval_length=0) echo ' '.io_safe_output($filter['src_port'])."\n"; echo ' '.io_safe_output($filter['advanced_filter'])."\n"; echo ' '.io_safe_output($filter['aggregate'])."\n"; - echo ' '.io_safe_output($filter['output'])."\n"; echo " \n"; echo netflow_draw_item($start_date, $end_date, $interval_length, $content['show_graph'], $filter, $content['max'], $report['server_name'], 'XML'); @@ -1642,38 +1633,6 @@ function netflow_summary_xml($data) } -/** - * Return a string describing the given unit. - * - * @param string Netflow unit. - */ -function netflow_format_unit($unit) -{ - switch ($unit) { - case 'megabytes': - return __('MB'); - - case 'megabytespersecond': - return __('MB/s'); - - case 'kilobytes': - return __('kB'); - - case 'kilobytespersecond': - return __('kB/s'); - - case 'bytes': - return __('Bytes'); - - case 'bytespersecond': - return __('B/s'); - - default: - return ''; - } -} - - /** * Return a string describing the given aggregate. * diff --git a/pandora_console/operation/netflow/nf_live_view.php b/pandora_console/operation/netflow/nf_live_view.php index 4724371b0f..65a7f31f12 100644 --- a/pandora_console/operation/netflow/nf_live_view.php +++ b/pandora_console/operation/netflow/nf_live_view.php @@ -80,7 +80,6 @@ $filter_id = (int) get_parameter('filter_id', 0); $filter['id_name'] = get_parameter('name', ''); $filter['id_group'] = (int) get_parameter('assign_group', 0); $filter['aggregate'] = get_parameter('aggregate', ''); -$filter['output'] = get_parameter('output', 'bytes'); $filter['ip_dst'] = get_parameter('ip_dst', ''); $filter['ip_src'] = get_parameter('ip_src', ''); $filter['dst_port'] = get_parameter('dst_port', ''); @@ -453,17 +452,6 @@ if (is_metaconsole()) { echo ''.__('Router ip').''; echo ''.html_print_input_text('router_ip', $filter['router_ip'], false, 30, 80, true).''; - echo ''.__('Output format').''; - $show_output = [ - 'bytes' => __('Bytes'), - 'bytespersecond' => __('Bytes per second'), - 'kilobytes' => __('Kilobytes'), - 'megabytes' => __('Megabytes'), - 'kilobytespersecond' => __('Kilobytes per second'), - 'megabytespersecond' => __('Megabytes per second'), - ]; - echo ''.html_print_select($show_output, 'output', $filter['output'], '', '', 0, true, false, true, '', false).''; - echo ''; echo ''; @@ -625,7 +613,6 @@ if (is_metaconsole()) { $("#text-router_ip").val(''); $("#textarea_advanced_filter").val(''); $("#aggregate").val(''); - $("#output").val(''); // Hide update filter button $("#submit-update_button").hide(); @@ -694,8 +681,6 @@ if (is_metaconsole()) { $("#textarea_advanced_filter").val(val); if (i == 'aggregate') $("#aggregate").val(val); - if (i == 'output') - $("#output").val(val); }); }, "json");