diff --git a/Plugin/unraid/include/common.php b/Plugin/unraid/include/common.php index bdccdb0..96293c8 100644 --- a/Plugin/unraid/include/common.php +++ b/Plugin/unraid/include/common.php @@ -394,10 +394,21 @@ function vv_network_stats(): array { file_put_contents($tmp, json_encode($now)); rename($tmp, $stateFile); + // ×8, because /proc/net/dev counts octets and everything downstream of here says bits. + // + // The field is named rx_bps, vvFmtBps() renders it as Kb/s, Mb/s and Gb/s, and the Monitor + // card prints it directly beneath the NIC's link speed — which comes from + // /sys/class/net/*/speed and genuinely is megabits. So the one number on that card you would + // read against the link was understating traffic by a factor of eight: 811 KB/s of real + // traffic displayed as "0.8 Mb/s" next to a 10 Gb/s link, when it was 6.5 Mb/s. + // + // Converted at the source rather than in the formatter so the field name stops lying. Both + // consumers are the Monitor card's rate readout and its history graph, and both are relative + // or bit-labelled, so neither changes meaning — only magnitude, to the correct one. $rxRate = $txRate = 0; if (!empty($prev['ts']) && ($dt = $now['ts'] - $prev['ts']) > 0.1) { - $rxRate = max(0, (int)(($rxBytes - ($prev['rx'] ?? $rxBytes)) / $dt)); - $txRate = max(0, (int)(($txBytes - ($prev['tx'] ?? $txBytes)) / $dt)); + $rxRate = max(0, (int)(($rxBytes - ($prev['rx'] ?? $rxBytes)) * 8 / $dt)); + $txRate = max(0, (int)(($txBytes - ($prev['tx'] ?? $txBytes)) * 8 / $dt)); } $speedMbps = (int)@file_get_contents("/sys/class/net/$iface/speed");