From d37acbb159444e5f138ad869fc3cef02f853a8d9 Mon Sep 17 00:00:00 2001 From: fermin831 Date: Mon, 25 Mar 2019 13:10:47 +0100 Subject: [PATCH] [Netflow usage map] Added data to show Former-commit-id: ca4db091b4c0f40061b9f7b8f13c4fe915ce022e --- pandora_console/include/functions_netflow.php | 7 ++++--- pandora_console/include/functions_network.php | 15 ++++++++------- .../operation/network/network_usage_map.php | 19 ++++++++++++++++--- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/pandora_console/include/functions_netflow.php b/pandora_console/include/functions_netflow.php index 41f2021cbf..056254f5f6 100644 --- a/pandora_console/include/functions_netflow.php +++ b/pandora_console/include/functions_netflow.php @@ -1794,10 +1794,11 @@ function netflow_aggregate_is_ip($aggregate) * @param integer $start_date Time in timestamp format. * @param integer $end_date Time in timestamp format. * @param integer $top Max data to show. + * @param integer $aggregate One of dstip or srcip. * * @return array With map structure. */ -function netflow_build_map_data($start_date, $end_date, $top) +function netflow_build_map_data($start_date, $end_date, $top, $aggregate) { $data = netflow_get_relationships_raw_data( $start_date, @@ -1805,7 +1806,7 @@ function netflow_build_map_data($start_date, $end_date, $top) [ 'id_name' => '', 'id_group' => 0, - 'aggregate' => 'srcip', + 'aggregate' => $aggregate, 'id_dst' => '', 'ip_src' => '', 'dst_port' => '', @@ -1814,7 +1815,7 @@ function netflow_build_map_data($start_date, $end_date, $top) 'router_ip' => '', ], $top, - 'srcip' + $aggregate ); $nodes = array_map( diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php index 69637c1971..67bf8f68d1 100644 --- a/pandora_console/include/functions_network.php +++ b/pandora_console/include/functions_network.php @@ -92,7 +92,7 @@ function network_matrix_get_top( * * @return array With the actions to print in a select. */ -function network_get_report_actions($network) +function network_get_report_actions($network=true) { $common_actions = [ 'listeners' => __('Top listeners'), @@ -172,15 +172,16 @@ 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 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) +function network_build_map_data($start, $end, $top, $talker) { - $data = network_matrix_get_top($top, true, $start, $end); + $data = network_matrix_get_top($top, $talker, $start, $end); $hosts = array_map( function ($elem) { @@ -207,7 +208,7 @@ function network_build_map_data($start, $end, $top) foreach ($hosts as $host) { $host_top = network_matrix_get_top( $top, - false, + !$talker, $start, $end, $host, diff --git a/pandora_console/operation/network/network_usage_map.php b/pandora_console/operation/network/network_usage_map.php index ca3e8db6d4..248cf699f1 100644 --- a/pandora_console/operation/network/network_usage_map.php +++ b/pandora_console/operation/network/network_usage_map.php @@ -40,6 +40,7 @@ if (! check_acl($config['id_user'], 0, 'AR')) { ui_include_time_picker(); // Query params and other initializations. +$action = get_parameter('action', 'talkers'); $time_greater = get_parameter('time_greater', date(TIME_FORMAT)); $date_greater = get_parameter('date_greater', date(DATE_FORMAT)); $utimestamp_greater = strtotime($date_greater.' '.$time_greater); @@ -114,7 +115,17 @@ $table->data['0']['2'] .= html_print_select( true ); -$table->data['1']['0'] = ''; + +$table->data['1']['0'] = __('Data to show').'  '; +$table->data['1']['0'] .= html_print_select( + network_get_report_actions(), + 'action', + $action, + '', + '', + 0, + true +); $table->data['1']['1'] = ''; $netflow_button = ''; @@ -158,14 +169,16 @@ if ((bool) get_parameter('update_netflow') === true) { $map_data = netflow_build_map_data( $utimestamp_lower, $utimestamp_greater, - $top + $top, + ($action === 'talkers') ? 'srcip' : 'dstip' ); $has_data = !empty($map_data['nodes']); } else if ((bool) get_parameter('update_nta') === true) { $map_data = network_build_map_data( $utimestamp_lower, $utimestamp_greater, - $top + $top, + $action === 'talkers' ); $has_data = !empty($map_data['nodes']); } else {