Do not calculate percentages. Catch it from netflow
Former-commit-id: b06a18df02d90a29660a34309a9d40c5774816b9
This commit is contained in:
parent
a191823d83
commit
6fc0a4924b
|
@ -1929,7 +1929,7 @@ function netflow_get_top_summary(
|
||||||
$command = netflow_get_command($netflow_filter);
|
$command = netflow_get_command($netflow_filter);
|
||||||
|
|
||||||
// Execute nfdump.
|
// Execute nfdump.
|
||||||
$command .= " -o csv -n $max -s $sort/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
|
$command .= " -q -o csv -n $max -s $sort/bytes -t ".date($nfdump_date_format, $start_date).'-'.date($nfdump_date_format, $end_date);
|
||||||
exec($command, $result);
|
exec($command, $result);
|
||||||
|
|
||||||
if (! is_array($result)) {
|
if (! is_array($result)) {
|
||||||
|
@ -1940,11 +1940,6 @@ function netflow_get_top_summary(
|
||||||
$result = array_reverse($result);
|
$result = array_reverse($result);
|
||||||
array_pop($result);
|
array_pop($result);
|
||||||
$result = array_reverse($result);
|
$result = array_reverse($result);
|
||||||
// Get the globals.
|
|
||||||
$globals = explode(',', array_pop($result));
|
|
||||||
// Remove globals header.
|
|
||||||
array_pop($result);
|
|
||||||
array_pop($result);
|
|
||||||
|
|
||||||
$top_info = [];
|
$top_info = [];
|
||||||
foreach ($result as $line) {
|
foreach ($result as $line) {
|
||||||
|
@ -1957,14 +1952,14 @@ function netflow_get_top_summary(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$top_info[$data[4]] = [
|
$top_info[(string) $data[4]] = [
|
||||||
'host' => $data[4],
|
'host' => $data[4],
|
||||||
'sum_bytes' => $data[9],
|
'sum_bytes' => $data[9],
|
||||||
'sum_pkts' => $data[7],
|
'sum_pkts' => $data[7],
|
||||||
'sum_flows' => $data[5],
|
'sum_flows' => $data[5],
|
||||||
'pct_bytes' => number_format((($data[9] / $globals[1]) * 100), 2),
|
'pct_bytes' => $data[10],
|
||||||
'pct_pkts' => number_format((($data[7] / $globals[2]) * 100), 2),
|
'pct_pkts' => $data[8],
|
||||||
'pct_flows' => number_format((($data[5] / $globals[0]) * 100), 2),
|
'pct_flows' => $data[6],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,10 @@ if (!$is_period) {
|
||||||
|
|
||||||
$top = (int) get_parameter('top', 10);
|
$top = (int) get_parameter('top', 10);
|
||||||
$main_value = ((bool) get_parameter('remove_filter', 0)) ? '' : get_parameter('main_value', '');
|
$main_value = ((bool) get_parameter('remove_filter', 0)) ? '' : get_parameter('main_value', '');
|
||||||
|
if (is_numeric($main_value) && !in_array($action, ['udp', 'tcp'])) {
|
||||||
|
$main_value = '';
|
||||||
|
}
|
||||||
|
|
||||||
$style_end = ($is_period) ? 'display: none;' : '';
|
$style_end = ($is_period) ? 'display: none;' : '';
|
||||||
$style_period = ($is_period) ? '' : 'display: none;';
|
$style_period = ($is_period) ? '' : 'display: none;';
|
||||||
|
|
||||||
|
@ -219,7 +223,7 @@ if (get_parameter('export_csv')) {
|
||||||
// Print the filter remove link.
|
// Print the filter remove link.
|
||||||
if (!empty($main_value)) {
|
if (!empty($main_value)) {
|
||||||
echo html_print_link_with_params(
|
echo html_print_link_with_params(
|
||||||
__('Filtered by IP %s. Click here to remove the filter.', $main_value),
|
in_array($action, ['udp', 'tcp']) ? __('Filtered by port %s. Click here to remove the filter.', $main_value) : __('Filtered by IP %s. Click here to remove the filter.', $main_value),
|
||||||
array_merge(
|
array_merge(
|
||||||
$hidden_main_link,
|
$hidden_main_link,
|
||||||
[
|
[
|
||||||
|
|
Loading…
Reference in New Issue