mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-09-11 02:08:44 -06:00
Use Python disk_usage for Windows storage metrics
This commit is contained in:
@@ -17,6 +17,8 @@ import time # Heartbeat timestamps
|
||||
import subprocess
|
||||
import getpass
|
||||
import datetime
|
||||
import shutil
|
||||
import string
|
||||
|
||||
import requests
|
||||
try:
|
||||
@@ -469,6 +471,24 @@ def collect_storage():
|
||||
"used": usage.used,
|
||||
})
|
||||
elif plat == "windows":
|
||||
found = False
|
||||
for letter in string.ascii_uppercase:
|
||||
drive = f"{letter}:\\"
|
||||
if os.path.exists(drive):
|
||||
try:
|
||||
usage = shutil.disk_usage(drive)
|
||||
except Exception:
|
||||
continue
|
||||
disks.append({
|
||||
"drive": drive,
|
||||
"disk_type": "Fixed Disk",
|
||||
"usage": (usage.used / usage.total * 100) if usage.total else 0,
|
||||
"total": usage.total,
|
||||
"free": usage.free,
|
||||
"used": usage.used,
|
||||
})
|
||||
found = True
|
||||
if not found:
|
||||
try:
|
||||
out = subprocess.run(
|
||||
["wmic", "logicaldisk", "get", "DeviceID,Size,FreeSpace"],
|
||||
|
Reference in New Issue
Block a user