mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
[Netflow live] Removed unit functionallity from area graph and data table
Former-commit-id: 2d60141028e01e1fdf5a9d5716aa69a2cfe08d08
This commit is contained in:
parent
c2c8287d3e
commit
473a40e7d2
@ -357,11 +357,14 @@ function netflow_data_table($data, $start_date, $end_date, $aggregate, $unit)
|
|||||||
foreach ($data['data'] as $timestamp => $values) {
|
foreach ($data['data'] as $timestamp => $values) {
|
||||||
$table->data[$i][0] = date($time_format, $timestamp);
|
$table->data[$i][0] = date($time_format, $timestamp);
|
||||||
for ($j = 0; $j < $source_count; $j++) {
|
for ($j = 0; $j < $source_count; $j++) {
|
||||||
if (isset($values[$source_index[$j]])) {
|
$table->data[$i][($j + 1)] = format_for_graph(
|
||||||
$table->data[$i][($j + 1)] = format_numeric($values[$source_index[$j]]).' '.netflow_format_unit($unit);
|
(isset($values[$source_index[$j]])) ? $values[$source_index[$j]] : 0,
|
||||||
} else {
|
2,
|
||||||
$table->data[$i][($j + 1)] = (0).' '.netflow_format_unit($unit);
|
'.',
|
||||||
}
|
',',
|
||||||
|
1024,
|
||||||
|
'B'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
@ -453,11 +456,13 @@ function netflow_is_net($address)
|
|||||||
* @param string filter Netflow filter.
|
* @param string filter Netflow filter.
|
||||||
* @param string aggregate Aggregate field.
|
* @param string aggregate Aggregate field.
|
||||||
* @param int max Maximum number of aggregates.
|
* @param int max Maximum number of aggregates.
|
||||||
* @param string unit Unit to show.
|
* @param int max Maximum number of aggregates.
|
||||||
|
* @param boolean absolute True to give the absolute data and false to get
|
||||||
|
* troughput.
|
||||||
*
|
*
|
||||||
* @return An array with netflow stats.
|
* @return An array with netflow stats.
|
||||||
*/
|
*/
|
||||||
function netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max, $unit, $connection_name='', $address_resolution=false)
|
function netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max, $absolute, $connection_name='', $address_resolution=false)
|
||||||
{
|
{
|
||||||
global $nfdump_date_format;
|
global $nfdump_date_format;
|
||||||
global $config;
|
global $config;
|
||||||
@ -669,17 +674,18 @@ function netflow_get_data($start_date, $end_date, $interval_length, $filter, $ag
|
|||||||
* @param string filter Netflow filter.
|
* @param string filter Netflow filter.
|
||||||
* @param string aggregate Aggregate field.
|
* @param string aggregate Aggregate field.
|
||||||
* @param int max Maximum number of aggregates.
|
* @param int max Maximum number of aggregates.
|
||||||
* @param string unit Unit to show.
|
* @param boolean absolute True to give the absolute data and false to get
|
||||||
|
* troughput.
|
||||||
*
|
*
|
||||||
* @return An array with netflow stats.
|
* @return An array with netflow stats.
|
||||||
*/
|
*/
|
||||||
function netflow_get_stats($start_date, $end_date, $filter, $aggregate, $max, $unit, $connection_name='', $address_resolution=false)
|
function netflow_get_stats($start_date, $end_date, $filter, $aggregate, $max, $absolute=true, $connection_name='', $address_resolution=false)
|
||||||
{
|
{
|
||||||
global $config, $nfdump_date_format;
|
global $config, $nfdump_date_format;
|
||||||
|
|
||||||
// Requesting remote data
|
// Requesting remote data
|
||||||
if (defined('METACONSOLE') && $connection_name != '') {
|
if (defined('METACONSOLE') && $connection_name != '') {
|
||||||
$data = metaconsole_call_remote_api($connection_name, 'netflow_get_stats', "$start_date|$end_date|".base64_encode(json_encode($filter))."|$aggregate|$max|$unit|".(int) $address_resolution);
|
$data = metaconsole_call_remote_api($connection_name, 'netflow_get_stats', "$start_date|$end_date|".base64_encode(json_encode($filter))."|$aggregate|$max|$absolute|".(int) $address_resolution);
|
||||||
return json_decode($data, true);
|
return json_decode($data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -740,30 +746,9 @@ function netflow_get_stats($start_date, $end_date, $filter, $aggregate, $max, $u
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($unit) {
|
$values[$i]['data'] = $val[9];
|
||||||
case 'megabytes':
|
if (!$absolute) {
|
||||||
$values[$i]['data'] = ($val[9] / 1048576);
|
$values[$i]['data'] = ($values[$i]['data'] / $interval_length);
|
||||||
break;
|
|
||||||
|
|
||||||
case 'megabytespersecond':
|
|
||||||
$values[$i]['data'] = ($val[9] / 1048576 / $interval_length);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'kilobytes':
|
|
||||||
$values[$i]['data'] = ($val[9] / 1024);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'kilobytespersecond':
|
|
||||||
$values[$i]['data'] = ($val[9] / 1024 / $interval_length);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
case 'bytes':
|
|
||||||
$values[$i]['data'] = $val[9];
|
|
||||||
break;
|
|
||||||
case 'bytespersecond':
|
|
||||||
$values[$i]['data'] = ($val[9] / $interval_length);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
@ -1168,29 +1153,20 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil
|
|||||||
switch ($type) {
|
switch ($type) {
|
||||||
case '0':
|
case '0':
|
||||||
case 'netflow_area':
|
case 'netflow_area':
|
||||||
$data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, $unit, $connection_name, $address_resolution);
|
$data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, true, $connection_name, $address_resolution);
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($output == 'HTML') {
|
if ($output == 'HTML' || $output == 'PDF') {
|
||||||
$html = '<b>'.__('Unit').':</b> '.netflow_format_unit($unit);
|
$html = '<b>'.__('Unit').':</b> '.netflow_format_unit($unit);
|
||||||
$html .= ' <b>'.__('Aggregate').':</b> '.netflow_format_aggregate($aggregate);
|
$html .= ' <b>'.__('Aggregate').':</b> '.netflow_format_aggregate($aggregate);
|
||||||
if ($interval_length != 0) {
|
if ($interval_length != 0) {
|
||||||
$html .= ' <b>'._('Resolution').":</b> $interval_length ".__('seconds');
|
$html .= ' <b>'._('Resolution').':</b> '.netflow_get_resolution_name($interval_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit), 1, false, $end_date);
|
$html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit), 1, false, $end_date);
|
||||||
return $html;
|
return $html;
|
||||||
} else if ($output == 'PDF') {
|
|
||||||
$html = '<b>'.__('Unit').':</b> '.netflow_format_unit($unit);
|
|
||||||
$html .= ' <b>'.__('Aggregate').':</b> '.netflow_format_aggregate($aggregate);
|
|
||||||
if ($interval_length != 0) {
|
|
||||||
$html .= ' <b>'._('Resolution').":</b> $interval_length ".__('seconds');
|
|
||||||
}
|
|
||||||
|
|
||||||
$html .= graph_netflow_aggregate_area($data, $interval, $width, $height, netflow_format_unit($unit), 2, true, $end_date);
|
|
||||||
return $html;
|
|
||||||
} else if ($output == 'XML') {
|
} else if ($output == 'XML') {
|
||||||
$xml = "<unit>$unit</unit>\n";
|
$xml = "<unit>$unit</unit>\n";
|
||||||
$xml .= "<aggregate>$aggregate</aggregate>\n";
|
$xml .= "<aggregate>$aggregate</aggregate>\n";
|
||||||
@ -1202,7 +1178,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil
|
|||||||
|
|
||||||
case '2':
|
case '2':
|
||||||
case 'netflow_data':
|
case 'netflow_data':
|
||||||
$data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, $unit, $connection_name, $address_resolution);
|
$data = netflow_get_data($start_date, $end_date, $interval_length, $filter, $aggregate, $max_aggregates, false, $connection_name, $address_resolution);
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
break;
|
break;
|
||||||
@ -1212,7 +1188,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil
|
|||||||
$html = '<b>'.__('Unit').':</b> '.netflow_format_unit($unit);
|
$html = '<b>'.__('Unit').':</b> '.netflow_format_unit($unit);
|
||||||
$html .= ' <b>'.__('Aggregate').':</b> '.netflow_format_aggregate($aggregate);
|
$html .= ' <b>'.__('Aggregate').':</b> '.netflow_format_aggregate($aggregate);
|
||||||
if ($interval_length != 0) {
|
if ($interval_length != 0) {
|
||||||
$html .= ' <b>'._('Resolution').":</b> $interval_length ".__('seconds');
|
$html .= ' <b>'._('Resolution').':</b> '.netflow_get_resolution_name($interval_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= "<div style='width: 100%; overflow: auto;'>";
|
$html .= "<div style='width: 100%; overflow: auto;'>";
|
||||||
@ -1969,3 +1945,17 @@ function netflow_resolution_select_params()
|
|||||||
NETFLOW_RES_DAILY => __('Daily'),
|
NETFLOW_RES_DAILY => __('Daily'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the resolution name.
|
||||||
|
*
|
||||||
|
* @param mixed $value Type.
|
||||||
|
*
|
||||||
|
* @return string Translated name. Unknown for unrecognized resolution names.
|
||||||
|
*/
|
||||||
|
function netflow_get_resolution_name($value)
|
||||||
|
{
|
||||||
|
$resolutions = netflow_resolution_select_params();
|
||||||
|
return (isset($resolutions[$value])) ? $resolutions[$value] : __('Unknown');
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user