mirror of
https://github.com//cppla/ServerStatus
synced 2026-08-06 11:13:56 +08:00
version 1.1.8
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
# ServerStatus中文版:
|
||||
# ServerStatus 中文版
|
||||
|
||||
* ServerStatus中文版是一个酷炫高逼格的云探针、云监控、服务器云监控、多服务器探针~。
|
||||
* 在线演示:https://tz.cloudcpp.com
|
||||
ServerStatus 是一个轻量的服务器探针和云监控面板,支持多节点在线状态、资源占用、三网延迟、服务监测、SSL 证书检查、Watchdog 告警和 Web 配置管理。
|
||||
|
||||
在线演示:https://tz.cloudcpp.com
|
||||
|
||||
[](https://github.com/cppla/ServerStatus)
|
||||
[](https://github.com/cppla/ServerStatus)
|
||||
@@ -10,219 +11,371 @@
|
||||
|
||||

|
||||
|
||||
`Watchdog触发式告警,interval只是为了防止频繁收到报警,并不是探测间隔。值得注意的是Exprtk使用窄字符类型,中文等Unicode字符无法解析计算。 AI已经能够取代大部分程序员`
|
||||
|
||||
## 功能
|
||||
|
||||
# 部署:
|
||||
- 主机监控:在线状态、CPU、内存、虚存、硬盘、IO、负载、进程、连接、流量。
|
||||
- 网络质量:联通、电信、移动三网延迟和丢包。
|
||||
- 服务监测:通过客户端上报自定义监测结果。
|
||||
- SSL 证书:检查证书剩余天数、域名不匹配和过期风险。
|
||||
- Watchdog:基于表达式规则触发告警回调。
|
||||
- WebUI:主机、服务、证书、配置四个页面;配置页可增删改节点、监测、证书和 Watchdog 规则。
|
||||
- HTTP 管理 API:方便 WebUI 或 AI Agent 读写配置、重载和重启服务。
|
||||
|
||||
注意:Watchdog 的 `interval` 是最小通知间隔,用于避免频繁报警,并不是探测间隔。`rule` 使用 Exprtk 表达式,当前窄字符解析对中文等 Unicode 字符不友好,规则中建议使用英文、数字和字段名。
|
||||
|
||||
## 快速启动
|
||||
|
||||
### 服务端 Docker Compose
|
||||
|
||||
推荐用 Compose 启动服务端。默认 Web 端口映射为 `8080:80`,客户端连接端口为 `35601`。
|
||||
|
||||
【服务端】:
|
||||
```bash
|
||||
|
||||
`Docker`:
|
||||
|
||||
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-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 -f docker-compose-server.yml up -d
|
||||
|
||||
`Dockerfile.server`(本地构建服务端):
|
||||
docker build -f Dockerfile.server -t serverstatus-server .
|
||||
ADMIN_TOKEN='your-strong-token' docker compose -f docker-compose-server.yml up -d --build
|
||||
```
|
||||
|
||||
【客户端】:
|
||||
启动后访问:
|
||||
|
||||
- WebUI:http://127.0.0.1:8080/
|
||||
- HTTP API 自检:http://127.0.0.1:8080/api/health
|
||||
- HTTP API 文档:http://127.0.0.1:8080/api/schema
|
||||
|
||||
`ADMIN_TOKEN` 可选;不设置时 WebUI 仍可查看监控数据,但「配置」页和写入类 API 不允许修改配置。
|
||||
|
||||
`docker-compose-server.yml` 默认挂载:
|
||||
|
||||
```text
|
||||
./server/config.json -> /ServerStatus/server/config.json
|
||||
./web/json -> /usr/share/nginx/html/json
|
||||
```
|
||||
|
||||
### 服务端 Docker Run
|
||||
|
||||
```bash
|
||||
wget --no-check-certificate -qO ~/serverstatus-config.json \
|
||||
https://raw.githubusercontent.com/cppla/ServerStatus/master/server/config.json
|
||||
mkdir -p ~/serverstatus-monthtraffic
|
||||
|
||||
`Shell`:
|
||||
|
||||
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 run -d --restart=always --name=serverstatus-client --network=host --pid=host -e SERVER=127.0.0.1 -e USER=s01 cppla/serverstatus:client
|
||||
|
||||
`Docker-compose`:
|
||||
SERVER=127.0.0.1 USER=s01 docker compose -f docker-compose-client.yml up -d --force-recreate
|
||||
|
||||
`Dockerfile.client`(本地构建客户端):
|
||||
docker build -f Dockerfile.client -t serverstatus-client .
|
||||
|
||||
`docker环境变量`:
|
||||
SERVER --- 可选 - 默认 127.0.0.1
|
||||
USER --- 可选 - 默认 s01
|
||||
PORT --- 可选 - 默认 35601
|
||||
PASSWORD --- 可选 - 默认 USER_DEFAULT_PASSWORD
|
||||
INTERVAL --- 可选 - 默认 1
|
||||
PROBEPORT --- 可选 - 默认 80
|
||||
PROBE_PROTOCOL_PREFER --- 可选 - 默认 ipv4
|
||||
PING_PACKET_HISTORY_LEN --- 可选 - 默认 100
|
||||
CU --- 可选 - 默认 cu.tz.cloudcpp.com
|
||||
CT --- 可选 - 默认 ct.tz.cloudcpp.com
|
||||
CM --- 可选 - 默认 cm.tz.cloudcpp.com
|
||||
CLIENT --- 可选 - 默认psutil, client可选
|
||||
docker run -d --restart=always --name=serverstatus-server \
|
||||
-e ADMIN_TOKEN='your-strong-token' \
|
||||
-v ~/serverstatus-config.json:/ServerStatus/server/config.json \
|
||||
-v ~/serverstatus-monthtraffic:/usr/share/nginx/html/json \
|
||||
-p 8080:80 -p 35601:35601 \
|
||||
cppla/serverstatus:server
|
||||
```
|
||||
|
||||
# 教程:
|
||||
|
||||
**【服务端配置】**
|
||||
|
||||
#### 一、生成服务端程序
|
||||
```
|
||||
`Debian/Ubuntu`: apt-get -y install gcc g++ make libcurl4-openssl-dev
|
||||
`Centos/Redhat`: yum -y install gcc gcc-c++ make libcurl-devel
|
||||
### 客户端 Docker Compose
|
||||
|
||||
cd ServerStatus/server && make
|
||||
./sergate
|
||||
```
|
||||
如果没错误提示,OK,ctrl+c关闭;如果有错误提示,检查35601端口是否被占用
|
||||
客户端必须使用服务端 `config.json` 中存在的 `username/password`。默认示例用户名是 `s01`。
|
||||
|
||||
#### 二、修改配置文件
|
||||
```diff
|
||||
! watchdog rule 可以为任何已知字段的表达式。注意Exprtk库默认使用窄字符类型,中文等Unicode字符无法解析计算,等待修复
|
||||
! watchdog interval 最小通知间隔
|
||||
! watchdog callback 可自定义为Post方法的URL,告警内容将拼接其后并发起回调
|
||||
|
||||
! Telegram: https://api.telegram.org/bot你自己的密钥/sendMessage?parse_mode=HTML&disable_web_page_preview=true&chat_id=你自己的标识&text=
|
||||
! Server酱: https://sctapi.ftqq.com/你自己的密钥.send?title=ServerStatus&desp=
|
||||
! PushDeer: https://api2.pushdeer.com/message/push?pushkey=你自己的密钥&text=
|
||||
! HttpBasicAuth: https://用户名:密码@你自己的域名/api/push?message=
|
||||
```bash
|
||||
SERVER=127.0.0.1 USER=s01 PASSWORD=USER_DEFAULT_PASSWORD \
|
||||
docker compose -f docker-compose-client.yml up -d --force-recreate
|
||||
```
|
||||
|
||||
注意:`USER` 是 docker compose 常见的宿主机环境变量名。如果没有在运行命令里显式传递,或传递方式不正确,Compose 可能会把系统里的 `$USER` 解析成本机用户名,而不是默认 `s01`。推荐优先级:
|
||||
|
||||
1. 运行命令显式传递 `USER=...`
|
||||
2. 用户修改 `docker-compose-client.yml` 里的 `USER` 默认值
|
||||
3. 依赖 Docker/系统环境
|
||||
|
||||
### 客户端 Docker Run
|
||||
|
||||
```bash
|
||||
docker run -d --restart=always --name=serverstatus-client \
|
||||
--network=host --pid=host \
|
||||
-e SERVER=127.0.0.1 \
|
||||
-e USER=s01 \
|
||||
-e PASSWORD=USER_DEFAULT_PASSWORD \
|
||||
cppla/serverstatus:client
|
||||
```
|
||||
|
||||
### 客户端环境变量
|
||||
|
||||
| 变量 | 默认值 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `SERVER` | `127.0.0.1` | 服务端地址 |
|
||||
| `USER` | `s01` | 客户端用户名,必须匹配服务端配置 |
|
||||
| `PORT` | `35601` | 服务端 sergate 端口 |
|
||||
| `PASSWORD` | `USER_DEFAULT_PASSWORD` | 客户端密码,必须匹配服务端配置 |
|
||||
| `INTERVAL` | `1` | 上报间隔 |
|
||||
| `PROBEPORT` | `80` | 探测端口 |
|
||||
| `PROBE_PROTOCOL_PREFER` | `ipv4` | 探测协议偏好 |
|
||||
| `PING_PACKET_HISTORY_LEN` | `100` | Ping 历史长度 |
|
||||
| `CU` | `cu.tz.cloudcpp.com` | 联通探测地址 |
|
||||
| `CT` | `ct.tz.cloudcpp.com` | 电信探测地址 |
|
||||
| `CM` | `cm.tz.cloudcpp.com` | 移动探测地址 |
|
||||
| `CLIENT` | `psutil` | 客户端实现,可选 `psutil` 或 `linux` |
|
||||
|
||||
## WebUI 配置管理
|
||||
|
||||
WebUI 顶部保留四个入口:
|
||||
|
||||
- `主机`:节点列表、筛选、排序和右侧详情。
|
||||
- `服务`:服务监测结果。
|
||||
- `证书`:SSL 证书检查结果。
|
||||
- `配置`:编辑 `servers`、`monitors`、`sslcerts`、`watchdog`。
|
||||
|
||||
使用配置页前需要:
|
||||
|
||||
1. 服务端设置 `ADMIN_TOKEN`。
|
||||
2. 打开 http://127.0.0.1:8080/。
|
||||
3. 进入「配置」页,输入 `ADMIN_TOKEN`。
|
||||
4. 保存后服务端会写入 `config.json` 并向 `sergate` 发送 `SIGHUP` 重载。
|
||||
|
||||
如果你使用 Docker 单文件 bind mount 挂载 `config.json`,管理 API 会自动兼容 Docker 的 `EBUSY` 写入限制:先备份,再原地写回。
|
||||
|
||||
## HTTP 管理 API
|
||||
|
||||
Docker 服务端镜像已内置 HTTP API,并通过 nginx 暴露在 Web 端口下。源码手动运行时需要单独启动 `server/manage_api.py`;如果要让 WebUI 的「配置」页可用,还需要把 `/api/` 反代到 `manage_api.py`。认证方式:
|
||||
|
||||
```bash
|
||||
Authorization: Bearer your-strong-token
|
||||
```
|
||||
|
||||
无需认证的接口:
|
||||
|
||||
```bash
|
||||
curl http://127.0.0.1:8080/api/health
|
||||
curl http://127.0.0.1:8080/api/schema
|
||||
```
|
||||
|
||||
读取完整配置:
|
||||
|
||||
```bash
|
||||
curl -H 'Authorization: Bearer your-strong-token' \
|
||||
http://127.0.0.1:8080/api/config
|
||||
```
|
||||
|
||||
节点 CRUD:
|
||||
|
||||
```bash
|
||||
curl -X POST http://127.0.0.1:8080/api/servers \
|
||||
-H 'Authorization: Bearer your-strong-token' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"username":"s05","name":"node5","type":"kvm","host":"host5","location":"SG","password":"USER_DEFAULT_PASSWORD","monthstart":1}'
|
||||
|
||||
curl -X PUT http://127.0.0.1:8080/api/servers/s05 \
|
||||
-H 'Authorization: Bearer your-strong-token' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"username":"s05","name":"node5-new","type":"kvm","host":"host5","location":"SG","password":"USER_DEFAULT_PASSWORD","monthstart":1}'
|
||||
|
||||
curl -X DELETE -H 'Authorization: Bearer your-strong-token' \
|
||||
http://127.0.0.1:8080/api/servers/s05
|
||||
```
|
||||
|
||||
`monitors`、`sslcerts`、`watchdog` 也支持细粒度 CRUD。更新和删除可以用数字 `index`;如果 `name` 唯一,也可以用 URL 编码后的 `name`。
|
||||
|
||||
```bash
|
||||
curl -X POST http://127.0.0.1:8080/api/monitors \
|
||||
-H 'Authorization: Bearer your-strong-token' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"name":"demo","host":"https://example.com","type":"https","interval":600}'
|
||||
|
||||
curl -X PUT http://127.0.0.1:8080/api/sslcerts/0 \
|
||||
-H 'Authorization: Bearer your-strong-token' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{"name":"example","domain":"https://example.com","port":443,"interval":7200,"callback":"https://yourSMSurl"}'
|
||||
|
||||
curl -X DELETE -H 'Authorization: Bearer your-strong-token' \
|
||||
http://127.0.0.1:8080/api/watchdog/0
|
||||
```
|
||||
|
||||
重载配置或重启 `sergate`:
|
||||
|
||||
```bash
|
||||
curl -X POST -H 'Authorization: Bearer your-strong-token' \
|
||||
http://127.0.0.1:8080/api/reload
|
||||
|
||||
curl -X POST -H 'Authorization: Bearer your-strong-token' \
|
||||
http://127.0.0.1:8080/api/restart
|
||||
```
|
||||
|
||||
完整端点以 `/api/schema` 输出为准。
|
||||
|
||||
## 配置文件
|
||||
|
||||
配置文件默认路径:
|
||||
|
||||
- Docker 服务端:`/ServerStatus/server/config.json`
|
||||
- 源码运行:`server/config.json`,或通过 `--config` 指定
|
||||
|
||||
基础示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"servers":
|
||||
[
|
||||
{
|
||||
"username": "s01",
|
||||
"name": "vps-1",
|
||||
"type": "kvm",
|
||||
"host": "chengdu",
|
||||
"location": "🇨🇳",
|
||||
"password": "USER_DEFAULT_PASSWORD",
|
||||
"monthstart": 1
|
||||
}
|
||||
],
|
||||
"monitors": [
|
||||
{
|
||||
"name": "抖音",
|
||||
"host": "https://www.douyin.com",
|
||||
"interval": 600,
|
||||
"type": "https"
|
||||
},
|
||||
{
|
||||
"name": "百度",
|
||||
"host": "https://www.baidu.com",
|
||||
"interval": 600,
|
||||
"type": "https"
|
||||
}
|
||||
],
|
||||
"sslcerts": [
|
||||
{
|
||||
"name": "demo域名",
|
||||
"domain": "https://demo.example.com",
|
||||
"port": 443,
|
||||
"interval": 600,
|
||||
"callback": "https://yourSMSurl"
|
||||
}
|
||||
],
|
||||
"watchdog":
|
||||
[
|
||||
{
|
||||
"name": "服务器负载高监控,排除内存大于32G物理机,同时排除node1机器",
|
||||
"rule": "cpu>90&load_1>4&memory_total<33554432&name!='node1'",
|
||||
"interval": 600,
|
||||
"callback": "https://yourSMSurl"
|
||||
},
|
||||
{
|
||||
"name": "服务器内存使用率过高监控,排除小于1G的机器",
|
||||
"rule": "(memory_used/memory_total)*100>90&memory_total>1048576",
|
||||
"interval": 600,
|
||||
"callback": "https://yourSMSurl"
|
||||
},
|
||||
{
|
||||
"name": "服务器宕机告警",
|
||||
"rule": "online4=0&online6=0",
|
||||
"interval": 600,
|
||||
"callback": "https://yourSMSurl"
|
||||
},
|
||||
{
|
||||
"name": "DDOS和CC攻击监控,限制甲骨文机器",
|
||||
"rule": "tcp_count>600&type='Oracle'",
|
||||
"interval": 300,
|
||||
"callback": "https://yourSMSurl"
|
||||
},
|
||||
{
|
||||
"name": "服务器月出口流量999GB告警",
|
||||
"rule": "(network_out-last_network_out)/1024/1024/1024>999",
|
||||
"interval": 3600,
|
||||
"callback": "https://yourSMSurl"
|
||||
},
|
||||
{
|
||||
"name": "阿里云服务器流量18GB告警,限制username为乌兰察布",
|
||||
"rule": "(network_out-last_network_out)/1024/1024/1024>18&(username='wlcb1'|username='wlcb2'|username='wlcb3'|username='wlcb4')",
|
||||
"interval": 3600,
|
||||
"callback": "https://yourSMSurl"
|
||||
},
|
||||
{
|
||||
"name": "重要线路丢包率过高检查",
|
||||
"rule": "(ping_10010>10|ping_189>10|ping_10086>10)&(host='sgp'|host='qqhk'|host='hk-21-x'|host='hk-31-x')",
|
||||
"interval": 600,
|
||||
"callback": "https://yourSMSurl"
|
||||
},
|
||||
{
|
||||
"name": "你可以组合任何已知字段的表达式",
|
||||
"rule": "(hdd_used/hdd_total)*100>95",
|
||||
"interval": 1800,
|
||||
"callback": "https://yourSMSurl"
|
||||
}
|
||||
]
|
||||
}
|
||||
"servers": [
|
||||
{
|
||||
"username": "s01",
|
||||
"name": "node1",
|
||||
"type": "kvm",
|
||||
"host": "host1",
|
||||
"location": "CN",
|
||||
"password": "USER_DEFAULT_PASSWORD",
|
||||
"monthstart": 1
|
||||
}
|
||||
],
|
||||
"monitors": [
|
||||
{
|
||||
"name": "example",
|
||||
"host": "https://example.com",
|
||||
"interval": 600,
|
||||
"type": "https"
|
||||
}
|
||||
],
|
||||
"sslcerts": [
|
||||
{
|
||||
"name": "example",
|
||||
"domain": "https://example.com",
|
||||
"port": 443,
|
||||
"interval": 7200,
|
||||
"callback": "https://yourSMSurl"
|
||||
}
|
||||
],
|
||||
"watchdog": [
|
||||
{
|
||||
"name": "offline warning",
|
||||
"rule": "online4=0&online6=0",
|
||||
"interval": 600,
|
||||
"callback": "https://yourSMSurl"
|
||||
},
|
||||
{
|
||||
"name": "cpu high warning",
|
||||
"rule": "cpu>90&load_1>5&username!='s01'",
|
||||
"interval": 600,
|
||||
"callback": "https://yourSMSurl"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### 三、拷贝ServerStatus/status到你的网站目录
|
||||
例如:
|
||||
```
|
||||
sudo cp -r ServerStatus/web/* /home/wwwroot/default
|
||||
常见 Watchdog 回调:
|
||||
|
||||
```text
|
||||
Telegram: https://api.telegram.org/bot你的密钥/sendMessage?parse_mode=HTML&disable_web_page_preview=true&chat_id=你的标识&text=
|
||||
Server酱: https://sctapi.ftqq.com/你的密钥.send?title=ServerStatus&desp=
|
||||
PushDeer: https://api2.pushdeer.com/message/push?pushkey=你的密钥&text=
|
||||
HttpBasicAuth: https://用户名:密码@你的域名/api/push?message=
|
||||
```
|
||||
|
||||
#### 四、运行服务端:
|
||||
web-dir参数为上一步设置的网站根目录,务必修改成自己网站的路径
|
||||
```
|
||||
./sergate --config=config.json --web-dir=/home/wwwroot/default
|
||||
```
|
||||
## 源码编译和运行
|
||||
|
||||
服务端依赖:
|
||||
|
||||
**【客户端配置】**
|
||||
|
||||
#### 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
|
||||
# Debian/Ubuntu
|
||||
apt-get -y install gcc g++ make libcurl4-openssl-dev python3 nginx openssl
|
||||
|
||||
# CentOS/RedHat
|
||||
yum -y install gcc gcc-c++ make libcurl-devel python3 nginx openssl
|
||||
```
|
||||
|
||||
#### client-psutil.py 跨平台版
|
||||
编译并运行 `sergate`:
|
||||
|
||||
```bash
|
||||
cd ServerStatus/server
|
||||
make
|
||||
mkdir -p ../web/json
|
||||
./sergate --config=config.json --web-dir=../web &
|
||||
echo $! > /tmp/serverstatus-sergate.pid
|
||||
```
|
||||
|
||||
如果只需要 HTTP API,可以再启动 `manage_api.py`:
|
||||
|
||||
```bash
|
||||
cd ServerStatus/server
|
||||
ADMIN_TOKEN='your-strong-token' \
|
||||
CONFIG_PATH="$PWD/config.json" \
|
||||
SERGATE_PID_FILE=/tmp/serverstatus-sergate.pid \
|
||||
ADMIN_API_BIND=127.0.0.1 \
|
||||
ADMIN_API_PORT=35602 \
|
||||
python3 manage_api.py
|
||||
```
|
||||
|
||||
源码方式直连 API:
|
||||
|
||||
```bash
|
||||
curl http://127.0.0.1:35602/api/health
|
||||
curl -H 'Authorization: Bearer your-strong-token' \
|
||||
http://127.0.0.1:35602/api/config
|
||||
```
|
||||
|
||||
如果要通过 WebUI 使用「配置」页,需要 nginx 同时提供静态文件并反代 `/api/`。示例配置:
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
|
||||
root /path/to/ServerStatus/web;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
|
||||
location /json/ {
|
||||
add_header Cache-Control "no-store";
|
||||
try_files $uri =404;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://127.0.0.1:35602;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 30s;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
启动失败时优先检查端口占用:`35601` 是 `sergate` 客户端上报端口,`35602` 是源码方式的管理 API 端口,`8080` 是上面示例的 Web 端口。源码手动运行没有 Docker 入口脚本守护;调用 `/api/restart` 会向 `sergate` 发送 `SIGTERM`,需要你用 systemd、supervisor 或 shell 循环自行拉起。
|
||||
|
||||
## 客户端源码运行
|
||||
|
||||
`client-linux.py`:
|
||||
|
||||
```bash
|
||||
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=127.0.0.1 USER=s01 PASSWORD=USER_DEFAULT_PASSWORD \
|
||||
>/dev/null 2>&1 &
|
||||
```
|
||||
|
||||
`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/ 安装
|
||||
|
||||
# CentOS/RedHat
|
||||
yum -y install python3-pip gcc python3-devel
|
||||
pip3 install psutil
|
||||
|
||||
python3 clients/client-psutil.py SERVER=127.0.0.1 USER=s01 PASSWORD=USER_DEFAULT_PASSWORD
|
||||
```
|
||||
|
||||
#### 后台运行与开机启动
|
||||
后台运行与开机启动:
|
||||
|
||||
```bash
|
||||
# 后台运行
|
||||
nohup python3 client-linux.py &
|
||||
nohup python3 client-linux.py SERVER=127.0.0.1 USER=s01 PASSWORD=USER_DEFAULT_PASSWORD &
|
||||
|
||||
# 开机启动 (crontab -e)
|
||||
@reboot /usr/bin/python3 /path/to/client-linux.py
|
||||
# crontab -e
|
||||
@reboot /usr/bin/python3 /path/to/client-linux.py SERVER=127.0.0.1 USER=s01 PASSWORD=USER_DEFAULT_PASSWORD
|
||||
```
|
||||
|
||||
# Make Better
|
||||
## 本地构建镜像
|
||||
|
||||
```bash
|
||||
docker build -f Dockerfile.server -t cppla/serverstatus:server .
|
||||
docker build -f Dockerfile.client -t cppla/serverstatus:client .
|
||||
```
|
||||
|
||||
## Make Better
|
||||
|
||||
* BotoX:https://github.com/BotoX/ServerStatus
|
||||
* mojeda: https://github.com/mojeda
|
||||
* mojeda's ServerStatus: https://github.com/mojeda/ServerStatus
|
||||
* BlueVM's project: http://www.lowendtalk.com/discussion/comment/169690#Comment_169690
|
||||
* mojeda:https://github.com/mojeda
|
||||
* mojeda's ServerStatus:https://github.com/mojeda/ServerStatus
|
||||
* BlueVM's project:http://www.lowendtalk.com/discussion/comment/169690#Comment_169690
|
||||
|
||||
Reference in New Issue
Block a user