mirror of
https://github.com//cppla/ServerStatus
synced 2026-03-26 00:09:49 +08:00
fix bug
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
`Docker`:
|
`Docker`:
|
||||||
|
|
||||||
wget --no-check-certificate -qO ~/serverstatus-config.json https://raw.githubusercontent.com/cppla/ServerStatus/master/server/config.json && mkdir ~/serverstatus-monthtraffic
|
wget --no-check-certificate -qO ~/serverstatus-config.json https://raw.githubusercontent.com/cppla/ServerStatus/master/server/config.json && mkdir ~/serverstatus-monthtraffic
|
||||||
docker run -d --restart=always --name=serverstatus -v ~/serverstatus-config.json:/ServerStatus/server/config.json -v ~/serverstatus-monthtraffic:/usr/share/nginx/html/json -p 80:80 -p 35601:35601 cppla/serverstatus:server
|
docker run -d --restart=always --name=serverstatus-server -v ~/serverstatus-config.json:/ServerStatus/server/config.json -v ~/serverstatus-monthtraffic:/usr/share/nginx/html/json -p 80:80 -p 35601:35601 cppla/serverstatus:server
|
||||||
|
|
||||||
`Docker-compose`:
|
`Docker-compose`:
|
||||||
docker compose -f docker-compose-server.yml up -d
|
docker compose -f docker-compose-server.yml up -d
|
||||||
@@ -38,7 +38,7 @@ docker build -f Dockerfile.server -t serverstatus-server .
|
|||||||
wget --no-check-certificate -qO client-linux.py 'https://raw.githubusercontent.com/cppla/ServerStatus/master/clients/client-linux.py' && nohup python3 client-linux.py SERVER={$SERVER} USER={$USER} >/dev/null 2>&1 &
|
wget --no-check-certificate -qO client-linux.py 'https://raw.githubusercontent.com/cppla/ServerStatus/master/clients/client-linux.py' && nohup python3 client-linux.py SERVER={$SERVER} USER={$USER} >/dev/null 2>&1 &
|
||||||
|
|
||||||
`Docker`:
|
`Docker`:
|
||||||
docker run --network=host -e SERVER=127.0.0.1 -e USER=s01 cppla/serververstatus:client
|
docker run --restart=always --name=serverstatus-client --network=host -e SERVER=127.0.0.1 -e USER=s01 cppla/serverstatus:client
|
||||||
|
|
||||||
`Docker-compose`:
|
`Docker-compose`:
|
||||||
docker compose -f docker-compose-client.yml up -d
|
docker compose -f docker-compose-client.yml up -d
|
||||||
|
|||||||
@@ -81,11 +81,37 @@ def get_memory():
|
|||||||
return int(MemTotal), int(MemUsed), int(SwapTotal), int(SwapFree)
|
return int(MemTotal), int(MemUsed), int(SwapTotal), int(SwapFree)
|
||||||
|
|
||||||
def get_hdd():
|
def get_hdd():
|
||||||
p = subprocess.check_output(['df', '-Tlm', '--total', '-t', 'ext4', '-t', 'ext3', '-t', 'ext2', '-t', 'reiserfs', '-t', 'jfs', '-t', 'ntfs', '-t', 'fat32', '-t', 'btrfs', '-t', 'fuseblk', '-t', 'zfs', '-t', 'simfs', '-t', 'xfs']).decode("Utf-8")
|
valid_fs = {
|
||||||
total = p.splitlines()[-1]
|
"ext4", "ext3", "ext2", "reiserfs", "jfs", "ntfs", "fat32",
|
||||||
used = total.split()[3]
|
"btrfs", "fuseblk", "zfs", "simfs", "xfs", "exfat", "f2fs"
|
||||||
size = total.split()[2]
|
}
|
||||||
return int(size), int(used)
|
seen = set()
|
||||||
|
size = 0
|
||||||
|
used = 0
|
||||||
|
try:
|
||||||
|
with open("/proc/mounts", "r") as f:
|
||||||
|
for line in f:
|
||||||
|
parts = line.split()
|
||||||
|
if len(parts) < 3:
|
||||||
|
continue
|
||||||
|
mountpoint = parts[1]
|
||||||
|
fstype = parts[2].lower()
|
||||||
|
if fstype not in valid_fs or mountpoint in seen:
|
||||||
|
continue
|
||||||
|
seen.add(mountpoint)
|
||||||
|
st = os.statvfs(mountpoint)
|
||||||
|
total_bytes = st.f_blocks * st.f_frsize
|
||||||
|
used_bytes = (st.f_blocks - st.f_bavail) * st.f_frsize
|
||||||
|
size += total_bytes
|
||||||
|
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():
|
def get_time():
|
||||||
with open("/proc/stat", "r") as f:
|
with open("/proc/stat", "r") as f:
|
||||||
|
|||||||
Reference in New Issue
Block a user