mirror of
https://github.com//cppla/ServerStatus
synced 2026-06-22 15:16:09 +08:00
fix bug
This commit is contained in:
+7
-10
@@ -82,10 +82,10 @@ def get_memory():
|
|||||||
|
|
||||||
def get_hdd():
|
def get_hdd():
|
||||||
valid_fs = {
|
valid_fs = {
|
||||||
"ext4", "ext3", "ext2", "reiserfs", "jfs", "ntfs", "fat32",
|
"ext4", "ext3", "ext2", "reiserfs", "jfs", "btrfs", "fuseblk",
|
||||||
"btrfs", "fuseblk", "zfs", "simfs", "xfs", "exfat", "f2fs"
|
"zfs", "simfs", "ntfs", "fat32", "exfat", "xfs"
|
||||||
}
|
}
|
||||||
seen = set()
|
disks = {}
|
||||||
size = 0
|
size = 0
|
||||||
used = 0
|
used = 0
|
||||||
try:
|
try:
|
||||||
@@ -94,11 +94,13 @@ def get_hdd():
|
|||||||
parts = line.split()
|
parts = line.split()
|
||||||
if len(parts) < 3:
|
if len(parts) < 3:
|
||||||
continue
|
continue
|
||||||
|
device = parts[0]
|
||||||
mountpoint = parts[1]
|
mountpoint = parts[1]
|
||||||
fstype = parts[2].lower()
|
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
|
continue
|
||||||
seen.add(mountpoint)
|
disks[device] = mountpoint
|
||||||
|
for mountpoint in disks.values():
|
||||||
st = os.statvfs(mountpoint)
|
st = os.statvfs(mountpoint)
|
||||||
total_bytes = st.f_blocks * st.f_frsize
|
total_bytes = st.f_blocks * st.f_frsize
|
||||||
used_bytes = (st.f_blocks - st.f_bavail) * st.f_frsize
|
used_bytes = (st.f_blocks - st.f_bavail) * st.f_frsize
|
||||||
@@ -106,11 +108,6 @@ def get_hdd():
|
|||||||
used += used_bytes
|
used += used_bytes
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
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)
|
return int(size / 1024 / 1024), int(used / 1024 / 1024)
|
||||||
|
|
||||||
def get_time():
|
def get_time():
|
||||||
|
|||||||
Reference in New Issue
Block a user