This commit is contained in:
cppla
2026-02-27 17:24:33 +08:00
parent 4bbd54dd06
commit 678cf43077
+7 -10
View File
@@ -82,10 +82,10 @@ def get_memory():
def get_hdd():
valid_fs = {
"ext4", "ext3", "ext2", "reiserfs", "jfs", "ntfs", "fat32",
"btrfs", "fuseblk", "zfs", "simfs", "xfs", "exfat", "f2fs"
"ext4", "ext3", "ext2", "reiserfs", "jfs", "btrfs", "fuseblk",
"zfs", "simfs", "ntfs", "fat32", "exfat", "xfs"
}
seen = set()
disks = {}
size = 0
used = 0
try:
@@ -94,11 +94,13 @@ def get_hdd():
parts = line.split()
if len(parts) < 3:
continue
device = parts[0]
mountpoint = parts[1]
fstype = parts[2].lower()
if fstype not in valid_fs or mountpoint in seen:
if fstype not in valid_fs or device in disks:
continue
seen.add(mountpoint)
disks[device] = mountpoint
for mountpoint in disks.values():
st = os.statvfs(mountpoint)
total_bytes = st.f_blocks * st.f_frsize
used_bytes = (st.f_blocks - st.f_bavail) * st.f_frsize
@@ -106,11 +108,6 @@ def get_hdd():
used += used_bytes
except Exception:
pass
# Keep client alive even on minimal/containerized systems.
if size <= 0:
st = os.statvfs("/")
size = st.f_blocks * st.f_frsize
used = (st.f_blocks - st.f_bavail) * st.f_frsize
return int(size / 1024 / 1024), int(used / 1024 / 1024)
def get_time():