fixed several netflow bugs
This commit is contained in:
parent
c736fbe726
commit
1a030bcd42
|
@ -174,6 +174,7 @@ if ($create) {
|
|||
}
|
||||
}
|
||||
|
||||
$table = new stdClass();
|
||||
$table->id = 'table1';
|
||||
$table->width = '100%';
|
||||
$table->border = 0;
|
||||
|
|
|
@ -242,7 +242,7 @@ function netflow_stat_table($data, $start_date, $end_date, $aggregate)
|
|||
*
|
||||
* @return string HTML data table.
|
||||
*/
|
||||
function netflow_data_table($data, $start_date, $end_date, $aggregate)
|
||||
function netflow_data_table($data, $start_date, $end_date, $aggregate, $pdf=false)
|
||||
{
|
||||
global $nfdump_date_format;
|
||||
|
||||
|
@ -265,8 +265,12 @@ function netflow_data_table($data, $start_date, $end_date, $aggregate)
|
|||
|
||||
$values = [];
|
||||
$table = new stdClass();
|
||||
|
||||
if ($pdf === false) {
|
||||
$table->size = ['100%'];
|
||||
$table->class = 'databox';
|
||||
}
|
||||
|
||||
$table->class = 'databox w100p';
|
||||
$table->cellspacing = 0;
|
||||
$table->data = [];
|
||||
|
||||
|
@ -1279,7 +1283,7 @@ function netflow_draw_item(
|
|||
|
||||
if ($output === 'HTML' || $output === 'PDF') {
|
||||
$html = "<div class='w100p overflow'>";
|
||||
$html .= netflow_data_table($data, $start_date, $end_date, $aggregate);
|
||||
$html .= netflow_data_table($data, $start_date, $end_date, $aggregate, $output === 'PDF');
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
|
@ -1485,6 +1489,8 @@ function netflow_draw_item(
|
|||
*
|
||||
* @param string $start_date Period start date.
|
||||
* @param string $end_date Period end date.
|
||||
* @param mixed $interval_length Resolution points or hourly or daily.
|
||||
* @param string $type_netflow Period end date.
|
||||
* @param array $filter Netflow filter.
|
||||
* @param integer $max_aggregates Maximum number of aggregates.
|
||||
* @param string $connection_name Node name when data is get in meta.
|
||||
|
@ -1494,10 +1500,17 @@ function netflow_draw_item(
|
|||
function netflow_get_item_data(
|
||||
string $start_date,
|
||||
string $end_date,
|
||||
$interval_length,
|
||||
string $type_netflow,
|
||||
array $filter,
|
||||
int $max_aggregates,
|
||||
string $connection_name
|
||||
) {
|
||||
$data = [];
|
||||
|
||||
switch ($type_netflow) {
|
||||
case 'netflow_top_N':
|
||||
/*
|
||||
$data_summary = netflow_get_summary(
|
||||
$start_date,
|
||||
$end_date,
|
||||
|
@ -1513,58 +1526,55 @@ function netflow_get_item_data(
|
|||
$connection_name
|
||||
);
|
||||
|
||||
return [
|
||||
$data = [
|
||||
'summary' => $data_summary,
|
||||
'top_n' => $data_top_n,
|
||||
];*/
|
||||
break;
|
||||
|
||||
case 'netflow_summary':
|
||||
$aggregate = $filter['aggregate'];
|
||||
|
||||
$data_summary = netflow_get_summary(
|
||||
$start_date,
|
||||
$end_date,
|
||||
$filter,
|
||||
$connection_name
|
||||
);
|
||||
|
||||
$data_stats = netflow_get_stats(
|
||||
$start_date,
|
||||
$end_date,
|
||||
$filter,
|
||||
$aggregate,
|
||||
$max_aggregates,
|
||||
true,
|
||||
$connection_name
|
||||
);
|
||||
|
||||
$data = [
|
||||
'summary' => $data_summary,
|
||||
'stats' => $data_stats,
|
||||
];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$aggregate = $filter['aggregate'];
|
||||
|
||||
/**
|
||||
* Render an aggregated area chart as an XML.
|
||||
*
|
||||
* @param array $data Netflow data.
|
||||
*
|
||||
* @return void XML is echoed.
|
||||
*/
|
||||
function netflow_aggregate_area_xml($data)
|
||||
{
|
||||
// Print source information.
|
||||
if (isset($data['sources'])) {
|
||||
echo "<aggregates>\n";
|
||||
foreach ($data['sources'] as $source => $discard) {
|
||||
echo '<aggregate>'.$source."</aggregate>\n";
|
||||
$data = netflow_get_data(
|
||||
$start_date,
|
||||
$end_date,
|
||||
$interval_length,
|
||||
$filter,
|
||||
$aggregate,
|
||||
$max_aggregates,
|
||||
true,
|
||||
$connection_name
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
echo "</aggregates>\n";
|
||||
|
||||
// Print flow information.
|
||||
echo "<flows>\n";
|
||||
foreach ($data['data'] as $timestamp => $flow) {
|
||||
echo "<flow>\n";
|
||||
echo ' <timestamp>'.$timestamp."</timestamp>\n";
|
||||
echo " <aggregates>\n";
|
||||
foreach ($flow as $source => $data) {
|
||||
echo ' <aggregate>'.$source."</aggregate>\n";
|
||||
echo ' <data>'.$data."</data>\n";
|
||||
}
|
||||
|
||||
echo " </aggregates>\n";
|
||||
echo "</flow>\n";
|
||||
}
|
||||
|
||||
echo "</flows>\n";
|
||||
} else {
|
||||
echo "<flows>\n";
|
||||
foreach ($data as $timestamp => $flow) {
|
||||
echo "<flow>\n";
|
||||
echo ' <timestamp>'.$timestamp."</timestamp>\n";
|
||||
echo ' <data>'.$flow['data']."</data>\n";
|
||||
echo "</flow>\n";
|
||||
}
|
||||
|
||||
echo "</flows>\n";
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5648,8 +5648,9 @@ function reporting_netflow(
|
|||
);
|
||||
|
||||
if ($type_netflow === 'netflow_top_N') {
|
||||
// Always aggregate by destination port.
|
||||
// Aggregate by destination port.
|
||||
$filter['aggregate'] = 'dstport';
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'dinamic':
|
||||
|
@ -5667,42 +5668,23 @@ function reporting_netflow(
|
|||
break;
|
||||
|
||||
case 'data':
|
||||
$return['data'] = netflow_get_item_data(
|
||||
($report['datetime'] - $content['period']),
|
||||
$report['datetime'],
|
||||
$filter,
|
||||
$content['top_n_value'],
|
||||
$content['server_name']
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Nothing to do.
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch ($type) {
|
||||
case 'dinamic':
|
||||
case 'static':
|
||||
case 'data':
|
||||
$return['chart'] = netflow_draw_item(
|
||||
$data = netflow_get_item_data(
|
||||
($report['datetime'] - $content['period']),
|
||||
$report['datetime'],
|
||||
$content['top_n'],
|
||||
$type_netflow,
|
||||
$filter,
|
||||
$content['top_n_value'],
|
||||
$content['server_name'],
|
||||
$pdf ? 'PDF' : 'HTML'
|
||||
$content['server_name']
|
||||
);
|
||||
|
||||
$return['data'] = (array_key_exists('data', $data) === true) ? $data['data'] : $data;
|
||||
break;
|
||||
|
||||
case 'data':
|
||||
default:
|
||||
// Nothing to do.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$return['subtitle'] = netflow_generate_subtitle_report(
|
||||
$filter['aggregate'],
|
||||
|
|
Loading…
Reference in New Issue