[Netflow usage map] Added data to show

Former-commit-id: ca4db091b4c0f40061b9f7b8f13c4fe915ce022e
This commit is contained in:
fermin831 2019-03-25 13:10:47 +01:00
parent 1dceb93a76
commit d37acbb159
3 changed files with 28 additions and 13 deletions

View File

@ -1794,10 +1794,11 @@ function netflow_aggregate_is_ip($aggregate)
* @param integer $start_date Time in timestamp format. * @param integer $start_date Time in timestamp format.
* @param integer $end_date Time in timestamp format. * @param integer $end_date Time in timestamp format.
* @param integer $top Max data to show. * @param integer $top Max data to show.
* @param integer $aggregate One of dstip or srcip.
* *
* @return array With map structure. * @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( $data = netflow_get_relationships_raw_data(
$start_date, $start_date,
@ -1805,7 +1806,7 @@ function netflow_build_map_data($start_date, $end_date, $top)
[ [
'id_name' => '', 'id_name' => '',
'id_group' => 0, 'id_group' => 0,
'aggregate' => 'srcip', 'aggregate' => $aggregate,
'id_dst' => '', 'id_dst' => '',
'ip_src' => '', 'ip_src' => '',
'dst_port' => '', 'dst_port' => '',
@ -1814,7 +1815,7 @@ function netflow_build_map_data($start_date, $end_date, $top)
'router_ip' => '', 'router_ip' => '',
], ],
$top, $top,
'srcip' $aggregate
); );
$nodes = array_map( $nodes = array_map(

View File

@ -92,7 +92,7 @@ function network_matrix_get_top(
* *
* @return array With the actions to print in a select. * @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 = [ $common_actions = [
'listeners' => __('Top listeners'), 'listeners' => __('Top listeners'),
@ -172,15 +172,16 @@ function network_format_bytes($value)
/** /**
* Build netflow data structure to network map. * Build netflow data structure to network map.
* *
* @param integer $start Time in timestamp format. * @param integer $start Time in timestamp format.
* @param integer $end Time in timestamp format. * @param integer $end Time in timestamp format.
* @param integer $top Max data to show. * @param integer $top Max data to show.
* @param boolean $talker True to get top tolkers. False for listeners.
* *
* @return array With map structure. * @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( $hosts = array_map(
function ($elem) { function ($elem) {
@ -207,7 +208,7 @@ function network_build_map_data($start, $end, $top)
foreach ($hosts as $host) { foreach ($hosts as $host) {
$host_top = network_matrix_get_top( $host_top = network_matrix_get_top(
$top, $top,
false, !$talker,
$start, $start,
$end, $end,
$host, $host,

View File

@ -40,6 +40,7 @@ if (! check_acl($config['id_user'], 0, 'AR')) {
ui_include_time_picker(); ui_include_time_picker();
// Query params and other initializations. // Query params and other initializations.
$action = get_parameter('action', 'talkers');
$time_greater = get_parameter('time_greater', date(TIME_FORMAT)); $time_greater = get_parameter('time_greater', date(TIME_FORMAT));
$date_greater = get_parameter('date_greater', date(DATE_FORMAT)); $date_greater = get_parameter('date_greater', date(DATE_FORMAT));
$utimestamp_greater = strtotime($date_greater.' '.$time_greater); $utimestamp_greater = strtotime($date_greater.' '.$time_greater);
@ -114,7 +115,17 @@ $table->data['0']['2'] .= html_print_select(
true 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'] = ''; $table->data['1']['1'] = '';
$netflow_button = ''; $netflow_button = '';
@ -158,14 +169,16 @@ if ((bool) get_parameter('update_netflow') === true) {
$map_data = netflow_build_map_data( $map_data = netflow_build_map_data(
$utimestamp_lower, $utimestamp_lower,
$utimestamp_greater, $utimestamp_greater,
$top $top,
($action === 'talkers') ? 'srcip' : 'dstip'
); );
$has_data = !empty($map_data['nodes']); $has_data = !empty($map_data['nodes']);
} else if ((bool) get_parameter('update_nta') === true) { } else if ((bool) get_parameter('update_nta') === true) {
$map_data = network_build_map_data( $map_data = network_build_map_data(
$utimestamp_lower, $utimestamp_lower,
$utimestamp_greater, $utimestamp_greater,
$top $top,
$action === 'talkers'
); );
$has_data = !empty($map_data['nodes']); $has_data = !empty($map_data['nodes']);
} else { } else {