5 Commits

Author SHA1 Message Date
e03c99a9f6 排除linux下无关分区 2024-10-03 17:42:28 +08:00
db7aeabe7b 排除linux下无关分区
Some checks failed
Compile / build (x64, windows-latest) (push) Failing after 14s
Compile / build (x64, ubuntu-latest) (push) Failing after 12m41s
2024-10-03 17:38:10 +08:00
89d7fa3145 提升上报时间
Some checks failed
Compile / build (x64, windows-latest) (push) Failing after 1m54s
Compile / build (x64, ubuntu-latest) (push) Has been cancelled
2024-10-03 17:28:57 +08:00
833c96cbc5 修复CPU物理核心计算错误 2024-10-03 17:03:57 +08:00
2e4fd493c5 修复CPU物理核心计算错误 2024-10-03 17:03:15 +08:00
3 changed files with 20 additions and 2 deletions

2
.gitignore vendored
View File

@@ -122,6 +122,8 @@ celerybeat.pid
*.sage.py
pdm.lock
start.cmd
start.sh
# Environments
.env

View File

@@ -85,6 +85,16 @@ sudo systemctl enable server-status-client
sudo systemctl start server-status-client
```
### 更新
```shell
git pull
sudo systemctl restart server-status-client
#
git pull
systemctl restart server-status-client
```
### 服务端
请在中心服务器上部署 [server-status-server](https://github.com/snowykami/server-status-server)

View File

@@ -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):
# 在输出前加上时间
@@ -120,7 +122,7 @@ class Api:
class Client:
def __init__(self, addr: str, token: str, client_id: str, name: str = "", location: str = "", labels: list[str] = [], link: str = "",
interval: int = 5):
interval: int = 2):
self.api = Api(addr, {"token": token, "id": client_id})
self.api = self.api.group("/client")
self.api.add_headers(Authorization="{token}")
@@ -224,11 +226,15 @@ class Client:
self.hardware.mem_used = psutil.virtual_memory().used
self.hardware.swap_total = psutil.swap_memory().total
self.hardware.swap_used = psutil.swap_memory().used
self.hardware.cpu_cores = psutil.cpu_count()
self.hardware.cpu_cores = psutil.cpu_count(logical=False)
self.hardware.cpu_logics = psutil.cpu_count(logical=True)
for part in psutil.disk_partitions():
try:
usage = psutil.disk_usage(part.mountpoint)
if part.mountpoint.startswith(excluded_partition_prefix) or usage.total == 0:
continue
self.hardware.disks[part.device] = {
"total": usage.total,
"used": usage.used,