#7963 Fixed netflow view 2

This commit is contained in:
Daniel Maya 2021-09-29 10:57:57 +02:00
parent af4e49e156
commit fb449910c9
2 changed files with 62 additions and 15 deletions

View File

@ -420,7 +420,8 @@ function netflow_get_data(
$max, $max,
$absolute, $absolute,
$connection_name='', $connection_name='',
$address_resolution=false $address_resolution=false,
$network_format_bytes=false
) { ) {
global $nfdump_date_format; global $nfdump_date_format;
global $config; global $config;
@ -560,7 +561,25 @@ function netflow_get_data(
continue; continue;
} }
$values['data'][$interval_end][$line['agg']] = $line['data']; if ($network_format_bytes == true) {
$pos = 0;
$number = $line['data'];
while ($number >= 1024) {
// As long as the number can be divided by divider.
$pos++;
// Position in array starting with 0.
$number = ($number / 1024);
}
while ($pos > 0) {
$number = ($number * 1000);
$pos --;
}
$values['data'][$interval_end][$line['agg']] = $number;
} else {
$values['data'][$interval_end][$line['agg']] = $line['data'];
}
} }
} }
@ -1082,7 +1101,8 @@ function netflow_draw_item(
$max_aggregates, $max_aggregates,
true, true,
$connection_name, $connection_name,
$address_resolution $address_resolution,
true
); );
if (empty($data) === true) { if (empty($data) === true) {

View File

@ -99,18 +99,26 @@ function chordDiagram(recipient, elements, matrix, width) {
.transition() .transition()
.style("opacity", opacity); .style("opacity", opacity);
svg.selectAll(".chord").filter(function(d) { if (event.type == "mouseover") {
if ( const chords = chord.chords();
event.type == "mouseover" && $.each(chords, function(key, value) {
(d.source.index == i || d.target.index == i) if (
) { (value.source.index == i && value.target.subindex == i) ||
show_tooltip(d); (value.source.subindex == i && value.target.index == i)
return; ) {
} else { if (
hide_tooltip(); $("#tooltip").is(":hidden") ||
return; $("#tooltip").length == 0
} ) {
}); show_tooltip(value);
} else {
add_tooltip(value);
}
}
});
} else {
hide_tooltip();
}
}; };
}; };
@ -273,6 +281,25 @@ function chordDiagram(recipient, elements, matrix, width) {
); );
} }
function add_tooltip(d) {
$("#tooltip").append(
"</br>" +
elements[d.source.index] +
" → " +
elements[d.target.index] +
": <b>" +
valueToBytes(d.source.value) +
"</b>" +
"<br>" +
elements[d.target.index] +
" → " +
elements[d.source.index] +
": <b>" +
valueToBytes(d.target.value) +
"</b>"
);
}
function show_tooltip(d) { function show_tooltip(d) {
x = d3.event.pageX + 10; x = d3.event.pageX + 10;
y = d3.event.pageY + 10; y = d3.event.pageY + 10;