mirror of
https://github.com/snowykami/server-status-client.git
synced 2026-01-25 21:21:57 +00:00
Compare commits
5 Commits
0360e58cc1
...
v1.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| e03c99a9f6 | |||
| db7aeabe7b | |||
| 89d7fa3145 | |||
| 833c96cbc5 | |||
| 2e4fd493c5 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -122,6 +122,8 @@ celerybeat.pid
|
|||||||
*.sage.py
|
*.sage.py
|
||||||
|
|
||||||
pdm.lock
|
pdm.lock
|
||||||
|
start.cmd
|
||||||
|
start.sh
|
||||||
|
|
||||||
# Environments
|
# Environments
|
||||||
.env
|
.env
|
||||||
|
|||||||
10
README.md
10
README.md
@@ -85,6 +85,16 @@ sudo systemctl enable server-status-client
|
|||||||
sudo systemctl start 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)
|
请在中心服务器上部署 [server-status-server](https://github.com/snowykami/server-status-server)
|
||||||
@@ -6,6 +6,8 @@ from typing import Any
|
|||||||
import psutil
|
import psutil
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
excluded_partition_prefix = ("/var", "/boot", "/run", "/proc", "/sys", "/dev", "/tmp", "/snap")
|
||||||
|
|
||||||
|
|
||||||
def log(*args):
|
def log(*args):
|
||||||
# 在输出前加上时间
|
# 在输出前加上时间
|
||||||
@@ -120,7 +122,7 @@ class Api:
|
|||||||
|
|
||||||
class Client:
|
class Client:
|
||||||
def __init__(self, addr: str, token: str, client_id: str, name: str = "", location: str = "", labels: list[str] = [], link: str = "",
|
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 = Api(addr, {"token": token, "id": client_id})
|
||||||
self.api = self.api.group("/client")
|
self.api = self.api.group("/client")
|
||||||
self.api.add_headers(Authorization="{token}")
|
self.api.add_headers(Authorization="{token}")
|
||||||
@@ -224,11 +226,15 @@ class Client:
|
|||||||
self.hardware.mem_used = psutil.virtual_memory().used
|
self.hardware.mem_used = psutil.virtual_memory().used
|
||||||
self.hardware.swap_total = psutil.swap_memory().total
|
self.hardware.swap_total = psutil.swap_memory().total
|
||||||
self.hardware.swap_used = psutil.swap_memory().used
|
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)
|
self.hardware.cpu_logics = psutil.cpu_count(logical=True)
|
||||||
for part in psutil.disk_partitions():
|
for part in psutil.disk_partitions():
|
||||||
try:
|
try:
|
||||||
usage = psutil.disk_usage(part.mountpoint)
|
usage = psutil.disk_usage(part.mountpoint)
|
||||||
|
|
||||||
|
if part.mountpoint.startswith(excluded_partition_prefix) or usage.total == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
self.hardware.disks[part.device] = {
|
self.hardware.disks[part.device] = {
|
||||||
"total": usage.total,
|
"total": usage.total,
|
||||||
"used": usage.used,
|
"used": usage.used,
|
||||||
|
|||||||
Reference in New Issue
Block a user