[Netflow live] Removed unit from circular mesh
Former-commit-id: 4f6fceadcf504ccf5006722b26a5b2259adc2970
This commit is contained in:
parent
e16d48804e
commit
cf8915af36
|
@ -4289,7 +4289,7 @@ function graph_netflow_aggregate_pie($data, $aggregate, $ttl=1, $only_image=fals
|
|||
/**
|
||||
* Print a circular graph with the data transmitted between IPs
|
||||
*/
|
||||
function graph_netflow_circular_mesh($data, $unit, $radius=700)
|
||||
function graph_netflow_circular_mesh($data, $radius=700)
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
@ -4299,7 +4299,7 @@ function graph_netflow_circular_mesh($data, $unit, $radius=700)
|
|||
|
||||
include_once $config['homedir'].'/include/graphs/functions_d3.php';
|
||||
|
||||
return d3_relationship_graph($data['elements'], $data['matrix'], $unit, $radius, true);
|
||||
return d3_relationship_graph($data['elements'], $data['matrix'], $radius, true);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -809,11 +809,10 @@ function netflow_get_summary($start_date, $end_date, $filter, $connection_name='
|
|||
* @param string end_date Period end date.
|
||||
* @param string filter Netflow filter.
|
||||
* @param int max Maximum number of elements.
|
||||
* @param string unit to show.
|
||||
*
|
||||
* @return An array with netflow stats.
|
||||
*/
|
||||
function netflow_get_record($start_date, $end_date, $filter, $max, $unit, $address_resolution=false)
|
||||
function netflow_get_record($start_date, $end_date, $filter, $max, $address_resolution=false)
|
||||
{
|
||||
global $nfdump_date_format;
|
||||
global $config;
|
||||
|
@ -852,32 +851,7 @@ function netflow_get_record($start_date, $end_date, $filter, $max, $unit, $addre
|
|||
$data['source_port'] = $items[5];
|
||||
$data['destination_port'] = $items[6];
|
||||
$data['protocol'] = $items[7];
|
||||
|
||||
switch ($unit) {
|
||||
case 'megabytes':
|
||||
$data['data'] = ($items[12] / 1048576);
|
||||
break;
|
||||
|
||||
case 'megabytespersecond':
|
||||
$data['data'] = ($items[12] / 1048576 / $data['duration']);
|
||||
break;
|
||||
|
||||
case 'kilobytes':
|
||||
$data['data'] = ($items[12] / 1024);
|
||||
break;
|
||||
|
||||
case 'kilobytespersecond':
|
||||
$data['data'] = ($items[12] / 1024 / $data['duration']);
|
||||
break;
|
||||
|
||||
default:
|
||||
case 'bytes':
|
||||
$data['data'] = $items[12];
|
||||
break;
|
||||
case 'bytespersecond':
|
||||
$data['data'] = ($items[12] / $data['duration']);
|
||||
break;
|
||||
}
|
||||
$data['data'] = $items[12];
|
||||
|
||||
$values[] = $data;
|
||||
}
|
||||
|
@ -1329,7 +1303,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil
|
|||
break;
|
||||
|
||||
case 'netflow_mesh':
|
||||
$netflow_data = netflow_get_record($start_date, $end_date, $filter, $max_aggregates, $unit, $address_resolution);
|
||||
$netflow_data = netflow_get_record($start_date, $end_date, $filter, $max_aggregates, $address_resolution);
|
||||
|
||||
switch ($aggregate) {
|
||||
case 'srcport':
|
||||
|
@ -1374,14 +1348,14 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil
|
|||
}
|
||||
|
||||
$html = '<div style="text-align:center;">';
|
||||
$html .= graph_netflow_circular_mesh($data, netflow_format_unit($unit), 700);
|
||||
$html .= graph_netflow_circular_mesh($data, 700);
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
|
||||
break;
|
||||
case 'netflow_host_treemap':
|
||||
$netflow_data = netflow_get_record($start_date, $end_date, $filter, $max_aggregates, $unit, $address_resolution);
|
||||
$netflow_data = netflow_get_record($start_date, $end_date, $filter, $max_aggregates, $address_resolution);
|
||||
|
||||
switch ($aggregate) {
|
||||
case 'srcip':
|
||||
|
@ -1434,7 +1408,7 @@ function netflow_draw_item($start_date, $end_date, $interval_length, $type, $fil
|
|||
$children_data['id'] = $id++;
|
||||
$children_data['name'] = $port;
|
||||
$children_data['value'] = $value;
|
||||
$children_data['tooltip_content'] = "$port: <b>".format_numeric($value).' '.netflow_format_unit($unit).'</b>';
|
||||
$children_data['tooltip_content'] = $port.': <b>'.network_format_bytes($value).'</b>';
|
||||
$children['children'][] = $children_data;
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ function include_javascript_d3($return=false)
|
|||
}
|
||||
|
||||
|
||||
function d3_relationship_graph($elements, $matrix, $unit, $width=700, $return=false)
|
||||
function d3_relationship_graph($elements, $matrix, $width=700, $return=false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
@ -53,7 +53,7 @@ function d3_relationship_graph($elements, $matrix, $unit, $width=700, $return=fa
|
|||
$output = '<div id="chord_diagram"></div>';
|
||||
$output .= include_javascript_d3(true);
|
||||
$output .= "<script language=\"javascript\" type=\"text/javascript\">
|
||||
chordDiagram('#chord_diagram', $elements, $matrix, '$unit', $width);
|
||||
chordDiagram('#chord_diagram', $elements, $matrix, $width);
|
||||
</script>";
|
||||
|
||||
if (!$return) {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
// matrix = [[0, 0, 2], // a[a => a, a => b, a => c]
|
||||
// [5, 0, 1], // b[b => a, b => b, b => c]
|
||||
// [2, 3, 0]]; // c[c => a, c => b, c => c]
|
||||
function chordDiagram(recipient, elements, matrix, unit, width) {
|
||||
function chordDiagram(recipient, elements, matrix, width) {
|
||||
d3.chart = d3.chart || {};
|
||||
d3.chart.chordWheel = function(options) {
|
||||
// Default values
|
||||
|
@ -206,18 +206,14 @@ function chordDiagram(recipient, elements, matrix, unit, width) {
|
|||
" → " +
|
||||
elements[d.target.index] +
|
||||
": <b>" +
|
||||
d.source.value.toFixed(2) +
|
||||
" " +
|
||||
unit +
|
||||
valueToBytes(d.source.value) +
|
||||
"</b>" +
|
||||
"<br>" +
|
||||
elements[d.target.index] +
|
||||
" → " +
|
||||
elements[d.source.index] +
|
||||
": <b>" +
|
||||
d.target.value.toFixed(2) +
|
||||
" " +
|
||||
unit +
|
||||
valueToBytes(d.target.value) +
|
||||
"</b>"
|
||||
)
|
||||
);
|
||||
|
@ -227,18 +223,14 @@ function chordDiagram(recipient, elements, matrix, unit, width) {
|
|||
" → " +
|
||||
elements[d.target.index] +
|
||||
": <b>" +
|
||||
d.source.value.toFixed(2) +
|
||||
" " +
|
||||
unit +
|
||||
valueToBytes(d.source.value) +
|
||||
"</b>" +
|
||||
"<br>" +
|
||||
elements[d.target.index] +
|
||||
" → " +
|
||||
elements[d.source.index] +
|
||||
": <b>" +
|
||||
d.target.value.toFixed(2) +
|
||||
" " +
|
||||
unit +
|
||||
valueToBytes(d.target.value) +
|
||||
"</b>"
|
||||
);
|
||||
}
|
||||
|
@ -2744,3 +2736,17 @@ function printClockDigital1(
|
|||
setTimeout(tick, 1000 - (now % 1000));
|
||||
})();
|
||||
}
|
||||
|
||||
function valueToBytes(value) {
|
||||
var shorts = ["", "K", "M", "G", "T", "P", "E", "Z", "Y"];
|
||||
var pos = 0;
|
||||
while (value >= 1024) {
|
||||
// As long as the number can be divided by divider.
|
||||
pos++;
|
||||
// Position in array starting with 0.
|
||||
value = value / 1024;
|
||||
}
|
||||
|
||||
// This will actually do the rounding and the decimals.
|
||||
return value.toFixed(2) + shorts[pos] + "B";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue