mirror of
https://github.com//cppla/ServerStatus
synced 2025-09-05 01:12:20 +08:00
update readme
This commit is contained in:
parent
4d9372768f
commit
a46ed4ea1a
44
README.md
44
README.md
@ -35,7 +35,7 @@ wget --no-check-certificate -qO client-linux.py 'https://raw.githubusercontent.c
|
||||
```
|
||||
|
||||
|
||||
# 手动安装教程:
|
||||
# 教程:
|
||||
|
||||
**【服务端配置】**
|
||||
|
||||
@ -165,30 +165,34 @@ web-dir参数为上一步设置的网站根目录,务必修改成自己网站
|
||||
```
|
||||
|
||||
**【客户端配置】**
|
||||
|
||||
#### client-linux.py Linux版
|
||||
```bash
|
||||
# 1、修改 client-linux.py 中的 SERVER、username、password
|
||||
python3 client-linux.py
|
||||
# 2、以传参的方式启动
|
||||
python3 client-linux.py SERVER=127.0.0.1 USER=s01
|
||||
|
||||
客户端有两个版本,client-linux为普通linux,client-psutil为跨平台版,普通版不成功,换成跨平台版即可。
|
||||
|
||||
## 4.1、client-linux版配置:
|
||||
1、vim client-linux.py, 修改SERVER地址,username帐号, password密码
|
||||
2、python3 client-linux.py 运行即可。
|
||||
|
||||
## 4.2、client-psutil版配置:
|
||||
1、安装psutil跨平台依赖库
|
||||
```
|
||||
`Debian/Ubuntu`: apt -y install python3-psutil
|
||||
`Centos/Redhat`: yum -y install python3-pip gcc python3-devel && pip3 install psutil
|
||||
`Windows`: https://pypi.org/project/psutil/
|
||||
|
||||
#### client-psutil.py 跨平台版
|
||||
```bash
|
||||
# 安装依赖
|
||||
# Debian/Ubuntu
|
||||
apt -y install python3-psutil
|
||||
# Centos/Redhat
|
||||
yum -y install python3-pip gcc python3-devel && pip3 install psutil
|
||||
# Windows: 从 https://pypi.org/project/psutil/ 安装
|
||||
```
|
||||
2、vim client-psutil.py, 修改SERVER地址,username帐号, password密码
|
||||
3、python3 client-psutil.py 运行即可。
|
||||
|
||||
## 4.3 服务器和客户端自行加入开机启动,或后台方式运行。
|
||||
1、后台运行: nohup python3 client-linux.py &
|
||||
2、开机启动(crontab -e): @reboot /usr/bin/python3 /root/client-linux.py
|
||||
|
||||
`extra scene (run web/ssview.py)`
|
||||

|
||||
#### 后台运行与开机启动
|
||||
```bash
|
||||
# 后台运行
|
||||
nohup python3 client-linux.py &
|
||||
|
||||
# 开机启动 (crontab -e)
|
||||
@reboot /usr/bin/python3 /path/to/client-linux.py
|
||||
```
|
||||
|
||||
# Make Better
|
||||
|
||||
|
@ -1,83 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# coding: utf-8
|
||||
# Update by : https://github.com/cppla/ServerStatus, Update date: 20211009
|
||||
# 支持Python版本:2.7 to 3.9; requirements.txt: requests, PrettyTable
|
||||
# 主要是为了受到CC attack时候方便查看机器状态
|
||||
|
||||
import os
|
||||
import sys
|
||||
import requests
|
||||
import time
|
||||
from prettytable import PrettyTable
|
||||
|
||||
scroll = True
|
||||
clear = lambda: os.system('clear' if 'linux' in sys.platform or 'darwin' in sys.platform else 'cls')
|
||||
|
||||
|
||||
def sscmd(address):
|
||||
while True:
|
||||
r = requests.get(
|
||||
url=address,
|
||||
headers={
|
||||
"User-Agent": "ServerStatus/20181203",
|
||||
}
|
||||
)
|
||||
jsonR = r.json()
|
||||
|
||||
ss = PrettyTable(
|
||||
[
|
||||
"月流量 ↓|↑",
|
||||
"节点名",
|
||||
"位置",
|
||||
"在线时间",
|
||||
"负载",
|
||||
"网络 ↓|↑",
|
||||
"总流量 ↓|↑",
|
||||
"处理器",
|
||||
"内存",
|
||||
"硬盘"
|
||||
],
|
||||
)
|
||||
for i in jsonR["servers"]:
|
||||
if i["online4"] is False and i["online6"] is False:
|
||||
ss.add_row(
|
||||
[
|
||||
'0.00G',
|
||||
"%s" % i["name"],
|
||||
"%s" % i["location"],
|
||||
'-',
|
||||
'-',
|
||||
'-',
|
||||
'-',
|
||||
'-',
|
||||
'-',
|
||||
'-',
|
||||
]
|
||||
)
|
||||
else:
|
||||
ss.add_row(
|
||||
[
|
||||
"%.2fG|%.2fG" % (float(i["last_network_in"]) / 1024 / 1024 / 1024, float(i["last_network_out"]) / 1024 / 1024 / 1024),
|
||||
"%s" % i["name"],
|
||||
# "%s" % i["type"],
|
||||
"%s" % i["location"],
|
||||
"%s" % i["uptime"],
|
||||
"%s" % (i["load_1"]),
|
||||
"%.2fM|%.2fM" % (float(i["network_rx"]) / 1000 / 1000, float(i["network_tx"]) / 1000 / 1000),
|
||||
"%.2fG|%.2fG" % (
|
||||
float(i["network_in"]) / 1024 / 1024 / 1024, float(i["network_out"]) / 1024 / 1024 / 1024),
|
||||
"%d%%" % (i["cpu"]),
|
||||
"%d%%" % (float(i["memory_used"]) / i["memory_total"] * 100),
|
||||
"%d%%" % (float(i["hdd_used"]) / i["hdd_total"] * 100),
|
||||
]
|
||||
)
|
||||
if scroll is True:
|
||||
clear()
|
||||
print(ss)
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
default = 'https://tz.cloudcpp.com/json/stats.json'
|
||||
ads = sys.argv[1] if len(sys.argv) == 2 else default
|
||||
sscmd(ads)
|
Loading…
x
Reference in New Issue
Block a user