mirror of
https://github.com//cppla/ServerStatus
synced 2026-08-06 10:23:57 +08:00
@@ -13,16 +13,6 @@ ServerStatus 是一个轻量的服务器探针和云监控面板,支持多节
|
||||
|
||||
`Watchdog 的 `interval` 是最小通知间隔,用于避免频繁报警,并不是探测间隔。`rule` 使用 Exprtk 表达式,当前窄字符解析对中文等 Unicode 字符不友好,规则中建议使用英文、数字和字段名。`
|
||||
|
||||
## 功能
|
||||
|
||||
- 主机监控:在线状态、CPU、内存、虚存、硬盘、IO、负载、进程、连接、流量。
|
||||
- 网络质量:联通、电信、移动三网延迟和丢包。
|
||||
- 服务监测:通过客户端上报自定义监测结果。
|
||||
- SSL 证书:检查证书剩余天数、域名不匹配和过期风险。
|
||||
- Watchdog:基于表达式规则触发告警回调。
|
||||
- WebUI:主机、服务、证书、配置四个页面;配置页可增删改节点、监测、证书和 Watchdog 规则。
|
||||
- HTTP 管理 API:方便 WebUI 或 AI Agent 读写配置、重载和重启服务。
|
||||
|
||||
|
||||
## 一、服务端
|
||||
|
||||
@@ -69,6 +59,11 @@ docker run -d --restart=always --name=serverstatus-client \
|
||||
cppla/serverstatus:client
|
||||
```
|
||||
|
||||
```bash
|
||||
# Shell Run
|
||||
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 >/dev/null 2>&1 &)
|
||||
```
|
||||
|
||||
客户端环境变量和注意事项:
|
||||
`USER` 是常见的宿主机环境变量名。如果没有显式传递,Compose 可能会把系统里的 `$USER` 解析成本机用户名。推荐优先级:1. 运行命令显式传递 `USER=...`,2. 用户修改 `docker-compose-client.yml` 里的 `USER` 默认值
|
||||
|
||||
@@ -317,16 +312,16 @@ apt -y install python3-psutil
|
||||
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
|
||||
python3 clients/client-psutil.py SERVER=127.0.0.1 USER=s01
|
||||
```
|
||||
|
||||
后台运行与开机启动:
|
||||
|
||||
```bash
|
||||
nohup python3 client-linux.py SERVER=127.0.0.1 USER=s01 PASSWORD=USER_DEFAULT_PASSWORD &
|
||||
nohup python3 client-linux.py SERVER=127.0.0.1 USER=s01 &
|
||||
|
||||
# crontab -e
|
||||
@reboot /usr/bin/python3 /path/to/client-linux.py SERVER=127.0.0.1 USER=s01 PASSWORD=USER_DEFAULT_PASSWORD
|
||||
@reboot /usr/bin/python3 /path/to/client-linux.py SERVER=127.0.0.1 USER=s01
|
||||
```
|
||||
|
||||
## 本地构建镜像
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ table.data th,table.data td{font-variant-numeric:tabular-nums}
|
||||
.caps-traffic.duo .half{flex:0 0 auto;display:flex;align-items:center;justify-content:center;padding:2px 4px;font-variant-numeric:tabular-nums;font-weight:600;line-height:1.25; /* 与 .pill 保持一致高度 */ letter-spacing:.25px;color:#fff;font-size:12px;white-space:nowrap;}
|
||||
/* 双色胶囊配色:
|
||||
normal (默认): 左绿右蓝
|
||||
heavy (>=500GB 总量): 黄色提醒,不再使用故障红
|
||||
heavy (>=1000GB 总量): 黄色提醒,不再使用故障红
|
||||
*/
|
||||
/* normal 初始:淡绿色(入) + 淡蓝色(出) */
|
||||
.caps-traffic.duo.normal .half.in{background:#d1fae5;color:#065f46;} /* emerald-100 / text-emerald-800 */
|
||||
|
||||
+2
-2
@@ -116,7 +116,7 @@ function metrics(s){
|
||||
const blocked = online && losses.every(p => p >= 100);
|
||||
const resourceCritical = online && (num(s.cpu) >= 90 || memPct >= 90 || hddPct >= 90);
|
||||
const resourceWarning = online && (num(s.cpu) >= 75 || memPct >= 80 || hddPct >= 85);
|
||||
const trafficWarning = online && traffic >= 500 * 1000 * 1000 * 1000;
|
||||
const trafficWarning = online && traffic >= 1000 * 1000 * 1000 * 1000;
|
||||
const lossCritical = online && loss >= 40;
|
||||
const lossWarning = online && !lossCritical && loss >= 30;
|
||||
const critical = online && (resourceCritical || blocked || lossCritical);
|
||||
@@ -263,7 +263,7 @@ function protoPill(s){
|
||||
}
|
||||
function trafficCaps(s, small){
|
||||
const m = metrics(s);
|
||||
const heavy = m.traffic >= 500 * 1000 * 1000 * 1000;
|
||||
const heavy = m.traffic >= 1000 * 1000 * 1000 * 1000;
|
||||
return `<span class="caps-traffic duo ${heavy ? 'heavy' : 'normal'}${small ? ' sm' : ''}" title="本月下行 | 上行"><span class="half in">${humanMinMBFromB(m.monthIn)}</span><span class="half out">${humanMinMBFromB(m.monthOut)}</span></span>`;
|
||||
}
|
||||
function gaugeHTML(type, value){
|
||||
|
||||
Reference in New Issue
Block a user