Fix: Disk I/O im LXC-Container ausgeblendet
_is_container() prüft via systemd-detect-virt ob der Prozess in einem Container läuft. Im LXC gibt get_disk_io() leere Liste zurück, da /proc/diskstats die Host-Geräte zeigt und nicht dem Container gehören. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -297,7 +297,17 @@ def get_network_traffic() -> Dict[str, Any]:
|
||||
return {"error": str(e)}
|
||||
|
||||
|
||||
def _is_container() -> bool:
|
||||
try:
|
||||
r = subprocess.run(["/usr/bin/systemd-detect-virt"], capture_output=True, text=True, timeout=3)
|
||||
return r.returncode == 0 and r.stdout.strip() not in ("none", "")
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
|
||||
def get_disk_io() -> Dict[str, Any]:
|
||||
if _is_container():
|
||||
return {"disks": []}
|
||||
try:
|
||||
with open("/proc/diskstats", "r") as f:
|
||||
lines = f.readlines()
|
||||
|
||||
Reference in New Issue
Block a user