Added filter to ntop part in network explorer

Former-commit-id: 688f737c26599da309ed414f4291e24e521d74a0
This commit is contained in:
Fermin 2019-03-08 12:11:18 +01:00
parent ed25536a97
commit fbd5648d60
2 changed files with 19 additions and 9 deletions

View File

@ -29,12 +29,20 @@
* @param integer $start Utimestamp of start time. * @param integer $start Utimestamp of start time.
* @param integer $end Utimestamp of end time. * @param integer $end Utimestamp of end time.
* @param string $ip_filter Ip to filter. * @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. * @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_group = ($talker === true) ? 'source' : 'destination';
$field_to_order = ($order_by_bytes === true) ? 'sum_bytes' : 'sum_pkts';
$filter_sql = ''; $filter_sql = '';
if (!empty($ip_filter)) { if (!empty($ip_filter)) {
$filter_field = ($talker === true) ? 'destination' : 'source'; $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 WHERE utimestamp > %d AND utimestamp < %d
%s %s
GROUP BY %s GROUP BY %s
ORDER BY sum_bytes DESC ORDER BY %s DESC
LIMIT %d', LIMIT %d',
$field_to_group, $field_to_group,
$start, $start,
$end, $end,
$filter_sql, $filter_sql,
$field_to_group, $field_to_group,
$field_to_order,
$top $top
); );

View File

@ -150,7 +150,8 @@ if ($is_network) {
$action === 'talkers', $action === 'talkers',
$utimestamp_lower, $utimestamp_lower,
$utimestamp_greater, $utimestamp_greater,
$main_value $main_value,
$order_by !== 'pkts'
); );
} else { } else {
$data = netflow_get_top_summary( $data = netflow_get_top_summary(