Added filter by ip requesting network matrix datas
Former-commit-id: 20a88fe66f9bcb2c39a9121b46e7204ed006470d
This commit is contained in:
parent
c95b057c14
commit
d62b7f0d79
|
@ -24,26 +24,35 @@
|
|||
/**
|
||||
* 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 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.
|
||||
*
|
||||
* @return array With requested data.
|
||||
*/
|
||||
function network_matrix_get_top($top, $talker, $start, $end)
|
||||
function network_matrix_get_top($top, $talker, $start, $end, $ip_filter='')
|
||||
{
|
||||
$field_to_group = ($talker === true) ? 'source' : 'destination';
|
||||
$filter_sql = '';
|
||||
if (!empty($ip_filter)) {
|
||||
$filter_field = ($talker === true) ? 'destination' : 'source';
|
||||
$filter_sql = sprintf('AND %s="%s"', $filter_field, $ip_filter);
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT SUM(bytes) sum_bytes, SUM(pkts) sum_pkts, %s host
|
||||
FROM tnetwork_matrix
|
||||
WHERE utimestamp > %d AND utimestamp < %d
|
||||
%s
|
||||
GROUP BY %s
|
||||
ORDER BY sum_bytes DESC
|
||||
LIMIT %d',
|
||||
$field_to_group,
|
||||
$start,
|
||||
$end,
|
||||
$filter_sql,
|
||||
$field_to_group,
|
||||
$top
|
||||
);
|
||||
|
|
|
@ -134,12 +134,14 @@ if ($is_network) {
|
|||
$top,
|
||||
$action === 'talkers',
|
||||
$utimestamp_lower,
|
||||
$utimestamp_greater
|
||||
$utimestamp_greater,
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
unset($table);
|
||||
$table = new stdClass();
|
||||
$table->styleTable = 'width: 100%';
|
||||
// Print the header.
|
||||
$table->head = [];
|
||||
$table->head[] = __('IP');
|
||||
|
|
Loading…
Reference in New Issue