From fbd5648d60bd5fdcdcbeb4da817b15cae9c6dc1f Mon Sep 17 00:00:00 2001 From: Fermin Date: Fri, 8 Mar 2019 12:11:18 +0100 Subject: [PATCH] Added filter to ntop part in network explorer Former-commit-id: 688f737c26599da309ed414f4291e24e521d74a0 --- pandora_console/include/functions_network.php | 25 +++++++++++++------ .../operation/network/network_report.php | 3 ++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/pandora_console/include/functions_network.php b/pandora_console/include/functions_network.php index 60375b6174..186f751426 100644 --- a/pandora_console/include/functions_network.php +++ b/pandora_console/include/functions_network.php @@ -24,17 +24,25 @@ /** * 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 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. * * @return array With requested data. */ -function network_matrix_get_top($top, $talker, $start, $end, $ip_filter='') -{ +function network_matrix_get_top( + $top, + $talker, + $start, + $end, + $ip_filter='', + $order_by_bytes=true +) { $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'; @@ -47,13 +55,14 @@ function network_matrix_get_top($top, $talker, $start, $end, $ip_filter='') WHERE utimestamp > %d AND utimestamp < %d %s GROUP BY %s - ORDER BY sum_bytes DESC + ORDER BY %s DESC LIMIT %d', $field_to_group, $start, $end, $filter_sql, $field_to_group, + $field_to_order, $top ); diff --git a/pandora_console/operation/network/network_report.php b/pandora_console/operation/network/network_report.php index bd6fef1725..93488c5c90 100644 --- a/pandora_console/operation/network/network_report.php +++ b/pandora_console/operation/network/network_report.php @@ -150,7 +150,8 @@ if ($is_network) { $action === 'talkers', $utimestamp_lower, $utimestamp_greater, - $main_value + $main_value, + $order_by !== 'pkts' ); } else { $data = netflow_get_top_summary(