From 45524eaee50221bdadb3b30ea0b80125c4ec7146 Mon Sep 17 00:00:00 2001 From: Donald Zou Date: Wed, 27 Aug 2025 17:48:28 +0800 Subject: [PATCH] Done #854 --- src/modules/SystemStatus.py | 19 +++ .../networkInterface.vue | 161 ++++++++++++++++++ src/static/app/src/views/systemStatus.vue | 87 +++------- 3 files changed, 203 insertions(+), 64 deletions(-) create mode 100644 src/static/app/src/components/systemStatusComponents/networkInterface.vue diff --git a/src/modules/SystemStatus.py b/src/modules/SystemStatus.py index fd927327..dba3ea2f 100644 --- a/src/modules/SystemStatus.py +++ b/src/modules/SystemStatus.py @@ -1,3 +1,5 @@ +import shutil +import subprocess import time import threading import psutil @@ -29,6 +31,7 @@ class SystemStatus: }, "Disks": self.Disks, "NetworkInterfaces": self.NetworkInterfaces, + "NetworkInterfacesPriority": self.NetworkInterfaces.getInterfacePriorities(), "Processes": self.Processes } @@ -117,7 +120,23 @@ class Disk: class NetworkInterfaces: def __init__(self): self.interfaces = {} + + def getInterfacePriorities(self): + if shutil.which("ip"): + result = subprocess.check_output(["ip", "route", "show"]).decode() + priorities = {} + for line in result.splitlines(): + if "metric" in line and "dev" in line: + parts = line.split() + dev = parts[parts.index("dev")+1] + metric = int(parts[parts.index("metric")+1]) + if dev not in priorities: + priorities[dev] = metric + return priorities + return {} + def getData(self): + self.interfaces.clear() try: network = psutil.net_io_counters(pernic=True, nowrap=True) for i in network.keys(): diff --git a/src/static/app/src/components/systemStatusComponents/networkInterface.vue b/src/static/app/src/components/systemStatusComponents/networkInterface.vue new file mode 100644 index 00000000..3bae22b7 --- /dev/null +++ b/src/static/app/src/components/systemStatusComponents/networkInterface.vue @@ -0,0 +1,161 @@ + + + + + \ No newline at end of file diff --git a/src/static/app/src/views/systemStatus.vue b/src/static/app/src/views/systemStatus.vue index 7ab46d3d..acf57cba 100644 --- a/src/static/app/src/views/systemStatus.vue +++ b/src/static/app/src/views/systemStatus.vue @@ -1,5 +1,5 @@