mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
systemstats: ignore loopback interfaces
This commit is contained in:
@@ -1082,9 +1082,24 @@ Singleton {
|
||||
root.prevCpuStats = stats;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------
|
||||
// Check whether a network interface is virtual/tunnel/bridge.
|
||||
// Only physical interfaces (eth*, en*, wl*, ww*) are kept so
|
||||
// that traffic routed through VPNs, Docker bridges, etc. is
|
||||
// not double-counted.
|
||||
readonly property var _virtualPrefixes: ["lo", "docker", "veth", "br-", "virbr", "vnet", "tun", "tap", "wg", "tailscale", "nordlynx", "proton", "mullvad", "flannel", "cni", "cali", "vxlan", "genev", "gre", "sit", "ip6tnl", "dummy", "ifb", "nlmon", "bond"]
|
||||
|
||||
function isVirtualInterface(name) {
|
||||
for (let i = 0; i < _virtualPrefixes.length; ++i) {
|
||||
if (name.startsWith(_virtualPrefixes[i]))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------
|
||||
// Calculate RX and TX speed from /proc/net/dev
|
||||
// Average speed of all interfaces excepted 'lo'
|
||||
// Sums speeds of all physical interfaces
|
||||
function calculateNetworkSpeed(text) {
|
||||
if (!text) {
|
||||
return;
|
||||
@@ -1108,7 +1123,7 @@ Singleton {
|
||||
}
|
||||
|
||||
const iface = line.substring(0, colonIndex).trim();
|
||||
if (iface === 'lo') {
|
||||
if (isVirtualInterface(iface)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user