From db7aeabe7b05d8a23ec8d434fe4bea0f4b7e5d03 Mon Sep 17 00:00:00 2001 From: snowykami Date: Thu, 3 Oct 2024 17:38:10 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=8E=92=E9=99=A4linux=E4=B8=8B?= =?UTF-8?q?=E6=97=A0=E5=85=B3=E5=88=86=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 +++ server_status/api.py | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 9c296d0..69a7541 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,9 @@ sudo systemctl start server-status-client ```shell git pull sudo systemctl restart server-status-client +# +git pull +systemctl restart server-status-client ``` ### 服务端 diff --git a/server_status/api.py b/server_status/api.py index 23cba46..fa64d00 100644 --- a/server_status/api.py +++ b/server_status/api.py @@ -6,6 +6,8 @@ from typing import Any import psutil import requests +excluded_partition_prefix = ("/var", "/boot", "/run", "/proc", "/sys", "/dev", "/tmp", "/snap") + def log(*args): # 在输出前加上时间 @@ -229,6 +231,10 @@ class Client: for part in psutil.disk_partitions(): try: usage = psutil.disk_usage(part.mountpoint) + + if part.mountpoint.startswith(excluded_partition_prefix): + continue + self.hardware.disks[part.device] = { "total": usage.total, "used": usage.used,