mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-09-11 04:58:41 -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 subprocess
|
||||||
import getpass
|
import getpass
|
||||||
import datetime
|
import datetime
|
||||||
|
import shutil
|
||||||
|
import string
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
try:
|
try:
|
||||||
@@ -469,6 +471,24 @@ def collect_storage():
|
|||||||
"used": usage.used,
|
"used": usage.used,
|
||||||
})
|
})
|
||||||
elif plat == "windows":
|
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:
|
try:
|
||||||
out = subprocess.run(
|
out = subprocess.run(
|
||||||
["wmic", "logicaldisk", "get", "DeviceID,Size,FreeSpace"],
|
["wmic", "logicaldisk", "get", "DeviceID,Size,FreeSpace"],
|
||||||
|
Reference in New Issue
Block a user