mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 00:04:37 +02:00
[Netflow live] Separate relationships data from circular mesh parsing
Former-commit-id: 68485217517ab70bcabed8855fdc9127b83547a6
This commit is contained in:
parent
030bcc69c4
commit
94cf43d6ab
@ -720,24 +720,22 @@ function netflow_get_summary($start_date, $end_date, $filter, $connection_name='
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a traffic record for the given period in an array.
|
* Returns a relationships data for the given period in an array.
|
||||||
*
|
*
|
||||||
* @param string $start_date Period start date.
|
* @param string $start_date Period start date.
|
||||||
* @param string $end_date Period end date.
|
* @param string $end_date Period end date.
|
||||||
* @param string $filter Netflow filter.
|
* @param string $filter Netflow filter.
|
||||||
* @param integer $max Maximum number of elements.
|
* @param integer $max Maximum number of elements.
|
||||||
* @param string $aggregate One of srcip, srcport, dstip, dstport.
|
* @param string $aggregate One of srcip, srcport, dstip, dstport.
|
||||||
* @param boolean $address_resolution True to resolve ips to hostnames.
|
|
||||||
*
|
*
|
||||||
* @return array With netflow record data.
|
* @return array With raw relationship data.
|
||||||
*/
|
*/
|
||||||
function netflow_get_circular_mesh_data(
|
function netflow_get_relationships_raw_data(
|
||||||
$start_date,
|
$start_date,
|
||||||
$end_date,
|
$end_date,
|
||||||
$filter,
|
$filter,
|
||||||
$max,
|
$max,
|
||||||
$aggregate,
|
$aggregate
|
||||||
$address_resolution=false
|
|
||||||
) {
|
) {
|
||||||
global $nfdump_date_format;
|
global $nfdump_date_format;
|
||||||
global $config;
|
global $config;
|
||||||
@ -752,7 +750,7 @@ function netflow_get_circular_mesh_data(
|
|||||||
|
|
||||||
// Update src and dst filter (both).
|
// Update src and dst filter (both).
|
||||||
$sources_array = array_keys($max_data['sources']);
|
$sources_array = array_keys($max_data['sources']);
|
||||||
$is_ip = (in_array($aggregate, ['dstip', 'srcip']));
|
$is_ip = netflow_aggregate_is_ip($aggregate);
|
||||||
netflow_update_second_level_filter(
|
netflow_update_second_level_filter(
|
||||||
$filter,
|
$filter,
|
||||||
($is_ip === true) ? 'dstip' : 'dstport',
|
($is_ip === true) ? 'dstip' : 'dstport',
|
||||||
@ -782,6 +780,34 @@ function netflow_get_circular_mesh_data(
|
|||||||
exec($command, $result);
|
exec($command, $result);
|
||||||
|
|
||||||
if (! is_array($result)) {
|
if (! is_array($result)) {
|
||||||
|
return [
|
||||||
|
'lines' => [],
|
||||||
|
'sources' => [],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'lines' => $result,
|
||||||
|
'sources' => $sources_array,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the raw relationships data to be painted by circular mesh chart.
|
||||||
|
*
|
||||||
|
* @param array $result Lines gotten from nfdump call.
|
||||||
|
* @param array $sources_array Array with sources involved in the chart.
|
||||||
|
* @param boolean $is_ip Is ip or port.
|
||||||
|
*
|
||||||
|
* @return array With data to be parsed on circular mesh chart.
|
||||||
|
*/
|
||||||
|
function netflow_parse_relationships_for_circular_mesh(
|
||||||
|
$result,
|
||||||
|
$sources_array,
|
||||||
|
$is_ip
|
||||||
|
) {
|
||||||
|
if (empty($result)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1171,7 +1197,7 @@ function netflow_draw_item(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'netflow_mesh':
|
case 'netflow_mesh':
|
||||||
$data = netflow_get_circular_mesh_data(
|
$data = netflow_get_relationships_raw_data(
|
||||||
$start_date,
|
$start_date,
|
||||||
$end_date,
|
$end_date,
|
||||||
$filter,
|
$filter,
|
||||||
@ -1179,9 +1205,14 @@ function netflow_draw_item(
|
|||||||
$aggregate,
|
$aggregate,
|
||||||
$address_resolution
|
$address_resolution
|
||||||
);
|
);
|
||||||
|
$data_circular = netflow_parse_relationships_for_circular_mesh(
|
||||||
|
$data['lines'],
|
||||||
|
$data['sources'],
|
||||||
|
netflow_aggregate_is_ip($aggregate)
|
||||||
|
);
|
||||||
|
|
||||||
$html = '<div style="text-align:center;">';
|
$html = '<div style="text-align:center;">';
|
||||||
$html .= graph_netflow_circular_mesh($data);
|
$html .= graph_netflow_circular_mesh($data_circular);
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
return $html;
|
return $html;
|
||||||
|
|
||||||
@ -1741,3 +1772,9 @@ function netflow_address_resolution(&$values, &$get_hostnames, $aggregate)
|
|||||||
|
|
||||||
$values['sources'] = $sources;
|
$values['sources'] = $sources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function netflow_aggregate_is_ip($aggregate)
|
||||||
|
{
|
||||||
|
return in_array($aggregate, ['dstip', 'srcip']);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user