Fix storage display: deduplicate volumes by device
This commit is contained in:
@@ -29,8 +29,10 @@ async def send_notification(body: dict):
|
|||||||
def system_stats():
|
def system_stats():
|
||||||
disk = shutil.disk_usage("/volume1")
|
disk = shutil.disk_usage("/volume1")
|
||||||
volumes = []
|
volumes = []
|
||||||
|
seen_devices = set()
|
||||||
for mount in psutil.disk_partitions():
|
for mount in psutil.disk_partitions():
|
||||||
if mount.mountpoint.startswith(("/volume",)):
|
if mount.mountpoint.startswith(("/volume",)) and mount.device not in seen_devices:
|
||||||
|
seen_devices.add(mount.device)
|
||||||
try:
|
try:
|
||||||
u = shutil.disk_usage(mount.mountpoint)
|
u = shutil.disk_usage(mount.mountpoint)
|
||||||
volumes.append({"mount": mount.mountpoint, "total": u.total, "used": u.used, "free": u.free, "percent": round(u.used / u.total * 100, 1)})
|
volumes.append({"mount": mount.mountpoint, "total": u.total, "used": u.used, "free": u.free, "percent": round(u.used / u.total * 100, 1)})
|
||||||
|
|||||||
Reference in New Issue
Block a user