fix: nur physische Netzwerk-Interfaces zählen
Virtuelle Interfaces (Bridges, veth, Docker, VPN-Tunnel) führen denselben Traffic wie die physische Karte und wurden bisher doppelt gezählt. Gezählt werden jetzt nur Interfaces mit /sys/class/net/<iface>/device; Loopback fällt damit ebenfalls raus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+4
-2
@@ -81,7 +81,8 @@ fn query_cpu_temp() -> String {
|
||||
}
|
||||
}
|
||||
|
||||
// Sums rx/tx byte counters across all interfaces except loopback.
|
||||
// Sums rx/tx byte counters across physical interfaces only. Virtual ones
|
||||
// (loopback, bridges, veth, VPN tunnels) would count the same traffic twice.
|
||||
fn read_net_bytes() -> (u64, u64) {
|
||||
let mut down = 0u64;
|
||||
let mut up = 0u64;
|
||||
@@ -96,7 +97,8 @@ fn read_net_bytes() -> (u64, u64) {
|
||||
let Some((iface, rest)) = line.split_once(':') else {
|
||||
continue;
|
||||
};
|
||||
if iface.trim() == "lo" {
|
||||
// Only physical interfaces have a backing device in sysfs.
|
||||
if !Path::new("/sys/class/net").join(iface.trim()).join("device").exists() {
|
||||
continue;
|
||||
}
|
||||
let fields: Vec<&str> = rest.split_whitespace().collect();
|
||||
|
||||
Reference in New Issue
Block a user