{"id":13456976,"url":"https://github.com/zdz/ServerStatus-Rust","last_synced_at":"2025-03-24T11:32:16.947Z","repository":{"id":37009179,"uuid":"451497282","full_name":"zdz/ServerStatus-Rust","owner":"zdz","description":"✨ Rust 版 ServerStatus 探针、威力加强版","archived":false,"fork":false,"pushed_at":"2024-10-24T01:45:22.000Z","size":2004,"stargazers_count":1803,"open_issues_count":29,"forks_count":326,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-10-25T03:44:30.892Z","etag":null,"topics":["probe","railway","rust","serverstatus","serverstatus-rust","telegram","vnstat","webhook","wechat"],"latest_commit_sha":null,"homepage":"https://ssr.rs","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zdz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"zdz"}},"created_at":"2022-01-24T14:28:52.000Z","updated_at":"2024-10-23T01:41:19.000Z","dependencies_parsed_at":"2023-01-17T13:00:25.822Z","dependency_job_id":"692cb4c7-4a35-488d-a997-8cf1e73e39f7","html_url":"https://github.com/zdz/ServerStatus-Rust","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zdz%2FServerStatus-Rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zdz%2FServerStatus-Rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zdz%2FServerStatus-Rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zdz%2FServerStatus-Rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zdz","download_url":"https://codeload.github.com/zdz/ServerStatus-Rust/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221537408,"owners_count":16839616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["probe","railway","rust","serverstatus","serverstatus-rust","telegram","vnstat","webhook","wechat"],"created_at":"2024-07-31T08:01:31.183Z","updated_at":"2024-10-29T00:31:42.730Z","avatar_url":"https://github.com/zdz.png","language":"Rust","readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/zdz/ServerStatus-Rust\"\u003e\n    \u003ch1 align=\"center\"\u003e✨ Rust 版 ServerStatus 云探针\u003c/h1\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003cp\u003e\n        \u003ca href=\"https://github.com/zdz/ServerStatus-Rust/actions/workflows/release.yml\"\u003e\n            \u003cimg src=\"https://github.com/zdz/ServerStatus-Rust/actions/workflows/release.yml/badge.svg\" alt=\"Release\"\u003e\u003c/a\u003e\n        \u003ca href=\"https://github.com/zdz/ServerStatus-Rust/issues\"\u003e\n            \u003cimg src=\"https://img.shields.io/github/issues/zdz/ServerStatus-Rust\"\n                  alt=\"GitHub issues\"\u003e\n        \u003c/a\u003e\n        \u003ca href=\"https://github.com/zdz/ServerStatus-Rust/discussions\"\u003e\n            \u003cimg src=\"https://img.shields.io/github/discussions/zdz/ServerStatus-Rust\"\n                  alt=\"GitHub Discussions\"\u003e\n        \u003c/a\u003e\n        \u003ca href=\"https://github.com/zdz/ServerStatus-Rust/releases\"\u003e\n            \u003cimg src=\"https://img.shields.io/github/v/release/zdz/ServerStatus-Rust\"\n                  alt=\"GitHub release (latest SemVer)\"\u003e\n        \u003c/a\u003e\n        \u003ca href=\"https://github.com/zdz/ServerStatus-Rust/releases\"\u003e\n            \u003cimg src=\"https://img.shields.io/github/downloads/zdz/ServerStatus-Rust/total\" alt=\"GitHub all releases\"\u003e\n        \u003c/a\u003e\n    \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cimg width=\"1317\" alt=\"image\" src=\"https://user-images.githubusercontent.com/152173/206825541-6eaeb856-0c03-479a-b07e-006b60b41c02.png\"\u003e\n\u003cimg width=\"1436\" alt=\"image\" src=\"https://user-images.githubusercontent.com/152173/165958225-25fc8fda-5798-42f8-bac5-72d778c0bab5.png\"\u003e\n\n\n\n\u003ch2\u003eTable of Contents\u003c/h2\u003e\n\n- [1. 介绍](#1-介绍)\n  - [🍀 主题](#-主题)\n- [2. 安装部署](#2-安装部署)\n  - [2.1 快速体验](#21-快速体验)\n  - [2.2 快速部署](#22-快速部署)\n  - [2.3 服务管理脚本](#23-服务管理脚本)\n  - [2.4 Railway 部署](#24-railway-部署)\n  - [2.5 Heroku 部署](#25-heroku-部署)\n- [3. 服务端说明](#3-服务端说明)\n  - [3.1 配置文件 `config.toml`](#31-配置文件-configtoml)\n  - [3.2 服务端运行](#32-服务端运行)\n- [4. 客户端说明](#4-客户端说明)\n  - [4.1 Rust 版 Client](#41-rust-版-client)\n  - [4.2 Python 版 Client](#42-python-版-client)\n- [5. 开启 `vnstat` 支持](#5-开启-vnstat-支持)\n- [6. FAQ](#6-faq)\n- [7. 相关项目](#7-相关项目)\n- [8. 最后](#8-最后)\n\n## 1. 介绍\n  `ServerStatus` 威力加强版，保持轻量和简单部署，增加以下主要特性：\n\n- 使用 `rust` 完全重写 `server`、`client`，单个执行文件部署\n- 多系统支持 `Linux`、`MacOS`、`Windows`、`Android`、`Raspberry Pi`\n- 支持上下线和简单自定义规则告警 (`telegram`、`wechat`、`email`、`webhook`)\n- 支持 `http` 协议上报，方便部署到各免费容器服务和配合 `cf` 等优化上报链路\n- 支持 `cloudflare tunnels` 和 `mTLS` 部署\n- 支持主机分组动态注册，简化配置\n- 支持 `vnstat` 统计月流量，重启不丢流量数据\n- 支持 `railway` 快速部署\n- 支持 `systemd` 开机自启\n- 其它功能，如 🗺️  见 [wiki](https://github.com/zdz/ServerStatus-Rust/wiki)\n\n演示：[ssr.rs](https://ssr.rs) | [cn dns](https://ck.ssr.rs)\n|\n下载：[Releases](https://github.com/zdz/ServerStatus-Rust/releases)\n|\n[Changelog](https://github.com/zdz/ServerStatus-Rust/releases)\n|\n反馈：[Discussions](https://github.com/zdz/ServerStatus-Rust/discussions)\n\n📚 完整文档迁移至 [doc.ssr.rs](https://doc.ssr.rs)\n\n📚 保姆级教程 [Google](https://www.google.com/search?q=%22serverstatus-rust%22)\n|\n[Bing](https://www.bing.com/search?q=%22serverstatus-rust%22)\n\n### 🍀 主题\n\n如果你觉得你创造/修改的主题还不错，欢迎分享/PR，前端单独部署方法参考 [#37](https://github.com/zdz/ServerStatus-Rust/discussions/37)\n\n\u003cdetails\u003e\n  \u003csummary\u003eServerStatus-theme 主题\u003c/summary\u003e\n\n作者 [@JingBh](https://github.com/JingBh)\n👉 [主题地址](https://github.com/JingBh/ServerStatus-theme)\n支持快速部署一键命令生成\n\n| \u003cimg width=\"1269\" alt=\"image\" src=\"https://github.com/zdz/ServerStatus-Rust/assets/152173/33eb8685-b0ed-4548-92af-8cfdded7d011\"\u003e | \u003cimg width=\"596\" alt=\"image\" src=\"https://github.com/zdz/ServerStatus-Rust/assets/152173/15e9c405-6491-4f41-ad0e-68aae96d709c\"\u003e |\n|-|-|\n\n[演示：Demo](https://status.jingbh.cloud)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eServerStatus-Theme-Light 主题\u003c/summary\u003e\n\n👉 [主题地址](https://github.com/orilights/ServerStatus-Theme-Light)\n作者 [@orilights](https://github.com/orilights)\n\n\u003cimg width=\"1836\" alt=\"image\" src=\"https://github.com/zdz/ServerStatus-Rust/assets/152173/35fdd138-31b8-46d0-8ea8-c2d4e7ef2b52\"\u003e\n\n[演示：Demo](https://sstl-demo.orilight.top)\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eHotaru 主题\u003c/summary\u003e\n\nHotaru 主题由 [@HinataKato](https://github.com/HinataKato) 修改提供，[主题地址](https://github.com/HinataKato/hotaru_theme_for_RustVersion)\n\n\u003cimg width=\"1202\" alt=\"image\" src=\"https://user-images.githubusercontent.com/152173/167900971-5ef0c23a-af43-4f52-aab5-d58e4a66c8ea.png\"\u003e\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003eServerStatus-web 主题\u003c/summary\u003e\n\nServerStatus-web 主题由 [@mjjrock](https://github.com/mjjrock) 修改提供，[主题地址](https://github.com/mjjrock/ServerStatus-web)\n\n\u003cimg width=\"1425\" alt=\"image\" src=\"https://user-images.githubusercontent.com/102237118/171837653-3a5b2cd6-bf02-4602-a132-2c80a6707f68.png\"\u003e\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n  \u003csummary\u003ev1.5.7 版本主题\u003c/summary\u003e\n\n[演示：Demo](https://tz-rust.vercel.app)\n\n\u003cimg width=\"1215\" alt=\"image\" src=\"https://user-images.githubusercontent.com/152173/165957689-d35714a9-f7f8-49f7-9573-97d4cf3c2f79.png\"\u003e\n\u003c/details\u003e\n\n## 2. 安装部署\n\n### 2.1 快速体验\n```bash\n# for CentOS/Debian/Ubuntu x86_64\nmkdir -p /opt/ServerStatus \u0026\u0026 cd /opt/ServerStatus\n# apt install -y unzip / yum install -y unzip\nwget --no-check-certificate -qO one-touch.sh 'https://raw.githubusercontent.com/zdz/ServerStatus-Rust/master/scripts/one-touch.sh'\nbash -ex one-touch.sh\n# 部署完毕，打开 http://127.0.0.1:8080/ 或 http://\u003c你的IP\u003e:8080/\n# 自定义部署可参照 scripts/one-touch.sh 脚本\n```\n\n### 2.2 快速部署\n\n👉 [快速部署](https://doc.ssr.rs/rapid_deploy)\n\n### 2.3 服务管理脚本\n\n\u003cdetails\u003e\n  \u003csummary\u003e服务管理脚本说明\u003c/summary\u003e\n\n由 [@Colsro](https://github.com/Colsro) \u0026\n[@Yooona-Lim](https://github.com/Yooona-Lim)  贡献\n\n```bash\n# 下载脚本\nwget --no-check-certificate -qO status.sh 'https://raw.githubusercontent.com/zdz/ServerStatus-Rust/master/scripts/status.sh'\n\n# 安装 服务端\nbash status.sh -i -s\n\n# 安装 客户端\nbash status.sh -i -c\n# or\nbash status.sh -i -c protocol://username:password@master:port\n# eg:\nbash status.sh -i -c grpc://h1:p1@127.0.0.1:9394\nbash status.sh -i -c http://h1:p1@127.0.0.1:8080\n\n# 更多用法：\n❯ bash status.sh\n\nhelp:\n    -i,--install    安装 Status\n        -i -s           安装 Server\n        -i -c           安装 Client\n        -i -c conf      自动安装 Client\n    -up,--upgrade   升级 Status\n        -up -s          升级 Server\n        -up -c          升级 Client\n        -up -a          升级 Server和Client\n    -un,--uninstall  卸载 Status\n        -un -s           卸载 Server\n        -un -c           卸载 Client\n        -un -a           卸载 Server and Client\n    -rc,--reconfig      更改 Status 配置\n        -rc          更改 Client 配置\n        -rc conf         自动更改 Client配置\n    -s,--server     管理 Status 运行状态\n        -s {status|start|stop|restart}\n    -c,--client     管理 Client 运行状态\n        -c {status|start|stop|restart}\n    -b,--bakup      备份 Status\n        -b -s          备份 Server\n        -b -c          备份 Client\n        -b -a          备份 Server and Client\n    -rs,--restore    恢复 Status\n        -rs -s          恢复 Server\n        -rs -c          恢复 Client\n        -rs -a          恢复 Server and Client\n    -h,--help       查看帮助\n若无法访问 Github:\n    CN=true bash status.sh args\n```\n\n\u003c/details\u003e\n\n### 2.4 Railway 部署\n\n懒得配置 `Nginx`，`SSL` 证书？试试\n[在 Railway 部署 Server](https://github.com/zdz/ServerStatus-Rust/wiki/Railway)\n\n[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template/kzT46l?referralCode=pJYbdU)\n\n### 2.5 Heroku 部署\n\n[如何在 Heroku 上部署 Rust 版 ServerStatus 云探针](https://github.com/zdz/ServerStatus-Rust/blob/master/heroku/README.md)\n\n## 3. 服务端说明\n\n### 3.1 配置文件 `config.toml`\n```toml\n# 侦听地址, ipv6 使用 [::]:9394\ngrpc_addr = \"0.0.0.0:9394\"\nhttp_addr = \"0.0.0.0:8080\"\n# 默认30s无上报判定下线\noffline_threshold = 30\n\n# 管理员账号,不设置默认随机生成，用于查看 /detail, /map\nadmin_user = \"\"\nadmin_pass = \"\"\n\n# hosts 跟 hosts_group 两种配置模式任挑一种配置即可\n# name 主机唯一标识，不可重复，alias 为展示名\n# notify = false 单独禁止单台机器的告警，一般针对网络差，频繁上下线\n# monthstart = 1 没启用vnstat时，表示月流量从每月哪天开始统计\n# disabled = true 单机禁用\n# location 支持国旗 emoji https://emojixd.com/group/flags\n# 或国家缩写，如 cn us 等等，所有国家见目录 web/static/flags\n# 自定义标签 labels = \"os=centos;ndd=2022/11/25;spec=2C/4G/60G;\"\n# os 标签可选，不填则使用上报数据，ndd(next due date) 下次续费时间, spec 为主机规格\n# os 可用值 centos debian ubuntu alpine pi arch windows linux\nhosts = [\n  {name = \"h1\", password = \"p1\", alias = \"n1\", location = \"🏠\", type = \"kvm\", labels = \"os=arch;ndd=2022/11/25;spec=2C/4G/60G;\"},\n  {name = \"h2\", password = \"p2\", alias = \"n2\", location = \"🏢\", type = \"kvm\", disabled = false},\n  {name = \"h3\", password = \"p3\", alias = \"n3\", location = \"🏡\", type = \"kvm\", monthstart = 1},\n  {name = \"h4\", password = \"p4\", alias = \"n4\", location = \"cn\", type = \"kvm\", notify = true, labels = \"ndd=2022/11/25;spec=2C/4G/60G;\"},\n]\n\n# 动态注册模式，不再需要针对每一个主机做单独配置\n# gid 为模板组id, 动态注册唯一标识，不可重复\nhosts_group = [\n  # 可以按国家地区或用途来做分组\n  {gid = \"g1\", password = \"pp\", location = \"🏠\", type = \"kvm\", notify = true},\n  {gid = \"g2\", password = \"pp\", location = \"🏢\", type = \"kvm\", notify = true},\n  # 例如不发送通知可以单独做一组\n  {gid = \"silent\", password = \"pp\", location = \"🏡\", type = \"kvm\", notify = false},\n]\n# 动态注册模式下，无效数据清理间隔，默认 30s\ngroup_gc = 30\n\n# 不开启告警，可忽略后面配置，或者删除不需要的通知方式\n# 告警间隔默认为30s\nnotify_interval = 30\n# https://core.telegram.org/bots/api\n# https://jinja.palletsprojects.com/en/3.0.x/templates/#if\n[tgbot]\n# 开关 true 打开\nenabled = false\nbot_token = \"\u003ctg bot token\u003e\"\nchat_id = \"\u003cchat id\u003e\"\n# host 可用字段见 payload.rs 文件 HostStat 结构, {{host.xxx}} 为占位变量\n# 例如 host.name 可替换为 host.alias，大家根据自己的喜好来编写通知消息\n# {{ip_info.query}} 主机 ip,  {{sys_info.host_name}} 主机 hostname\ntitle = \"❗\u003cb\u003eServer Status\u003c/b\u003e\"\nonline_tpl =  \"{{config.title}} \\n😆 {{host.location}} {{host.name}} 主机恢复上线啦\"\noffline_tpl = \"{{config.title}} \\n😱 {{host.location}} {{host.name}} 主机已经掉线啦\"\n# custom 模板置空则停用自定义告警，只保留上下线通知\ncustom_tpl = \"\"\"\n{% if host.memory_used / host.memory_total \u003e 0.5  %}\n\u003cpre\u003e😲 {{host.name}} 主机内存使用率超50%, 当前{{ (100 * host.memory_used / host.memory_total) | round }}%  \u003c/pre\u003e\n{% endif %}\n\n{% if host.hdd_used / host.hdd_total  \u003e 0.5  %}\n\u003cpre\u003e😲 {{host.name}} 主机硬盘使用率超50%, 当前{{ (100 * host.hdd_used / host.hdd_total) | round }}% \u003c/pre\u003e\n{% endif %}\n\"\"\"\n\n# wechat, email, webhook 等其它通知方式 配置详细见 config.toml\n```\n\n### 3.2 服务端运行\n```bash\n# systemd 方式， 参照 scripts/one-touch.sh 脚本 (推荐)\n\n# 💪 手动方式\n# help\n./stat_server -h\n# 手动运行\n./stat_server -c config.toml\n# 或\nRUST_BACKTRACE=1 RUST_LOG=trace ./stat_server -c config.toml\n\n# 测试配置文件是否有效\n./stat_server -c config.toml -t\n# 根据配置发送测试消息，验证通知是否生效\n./stat_server -c config.toml --notify-test\n\n# 🐳 docker 方式\nwget --no-check-certificate -qO docker-compose.yml 'https://raw.githubusercontent.com/zdz/ServerStatus-Rust/master/docker-compose.yml'\nwget --no-check-certificate -qO config.toml 'https://raw.githubusercontent.com/zdz/ServerStatus-Rust/master/config.toml'\ntouch stats.json\ndocker-compose up -d\n```\n\n## 4. 客户端说明\n\n\u003cdetails\u003e\n  \u003csummary\u003e系统版本\u0026架构\u003c/summary\u003e\n\n|  OS            | Release  |\n|  ----          | ----     |\n| Linux x86_64   | x86_64-unknown-linux-musl |\n| Linux arm64    | aarch64-unknown-linux-musl |\n| MacOS x86_64   | x86_64-apple-darwin |\n| MacOS arm64    | aarch64-apple-darwin |\n| Windows x86_64 | x86_64-pc-windows-msvc |\n| Raspberry Pi   | armv7-unknown-linux-musleabihf |\n| Android 64bit  | aarch64-linux-android |\n| Android 32bit  | armv7-linux-androideabi |\n\n\u003c/details\u003e\n\n### 4.1 Rust 版 Client\n```bash\n# 公网环境建议 headscale/nebula 组网或走 https, 使用 nginx 对 server 套 ssl 和自定义 location /report\n# alpine linux 需要安装相关命令 apk add procps iproute2 coreutils\n# 如果 Rust 版客户端在你的系统无法使用，请切换到下面 4.2 Python 跨平台版本\n\n# systemd 方式， 参照 scripts/one-touch.sh 脚本 (推荐)\n\n# 💪 手动方式\n# Rust 版本 Client\n./stat_client -h\n./stat_client -a \"http://127.0.0.1:8080/report\" -u h1 -p p1\n# 或\n./stat_client -a \"grpc://127.0.0.1:9394\" -u h1 -p p1\n# 不同的主机可以运行相同的命令注册到同一组\n./stat_client -a \"http://127.0.0.1:8080/report\" -g g1 -p pp --alias \"$(hostname)\"\n\n# rust client 可用参数\n./stat_client -h\nOPTIONS:\n    -6, --ipv6                   ipv6 only, default:false\n    -a, --addr \u003cADDR\u003e            [default: http://127.0.0.1:8080/report]\n        --alias \u003cALIAS\u003e          alias for host [default: unknown]\n        --cm \u003cCM_ADDR\u003e           China Mobile probe addr [default: cm.tz.cloudcpp.com:80]\n        --ct \u003cCT_ADDR\u003e           China Telecom probe addr [default: ct.tz.cloudcpp.com:80]\n        --cu \u003cCU_ADDR\u003e           China Unicom probe addr [default: cu.tz.cloudcpp.com:80]\n        --disable-extra          disable extra info report, default:false\n        --disable-notify         disable notify, default:false\n        --disable-ping           disable ping, default:false\n        --disable-tupd           disable t/u/p/d, default:false\n    -g, --gid \u003cGID\u003e              group id [default: ]\n    -h, --help                   Print help information\n        --ip-info                show ip info, default:false\n        --ip-source \u003cIP_SOURCE\u003e  ip info source [env: SSR_IP_SOURCE=] [default: ip-api.com]\n        --sys-info               show sys info, default:false\n        --json                   use json protocol, default:false\n        --location \u003cLOCATION\u003e    location [default: ]\n    -n, --vnstat                 enable vnstat, default:false\n        --vnstat-mr \u003cVNSTAT_MR\u003e  vnstat month rotate 1-28 [default: 1]\n    -p, --pass \u003cPASS\u003e            password [default: p1]\n    -t, --type \u003cHOST_TYPE\u003e       host type [default: ]\n    -u, --user \u003cUSER\u003e            username [default: h1]\n    -V, --version                Print version information\n    -w, --weight \u003cWEIGHT\u003e        weight for rank [default: 0]\n\n# 一些参数说明\n--ip-info       # 显示本机ip信息后立即退出，目前使用 ip-api.com 数据\n--ip-source     # 指定 ip 信息源，ip-api.com / ip.sb / ipapi.co / myip.la\n--sys-info      # 显示本机系统信息后立即退出\n--disable-extra # 不上报系统信息和IP信息\n--disable-ping  # 停用三网延时和丢包率探测\n--disable-tupd  # 不上报 tcp/udp/进程数/线程数，减少CPU占用\n-w, --weight    # 排序加分，微调让主机靠前显示，无强迫症可忽略\n-g, --gid       # 动态注册的组id\n--alias         # 动态注册模式下，指定主机的展示名字\n# 总流量，网卡流量/网速统计\n-i, --iface         # 非空时，只统计指定网口\n-e, --exclude-iface # 排除指定网口，默认排除 \"lo,docker,vnet,veth,vmbr,kube,br-\"\n```\n\n### 4.2 Python 版 Client\n\n\u003cdetails\u003e\n  \u003csummary\u003e Python 版 Client 说明\u003c/summary\u003e\n\n```bash\n# Python 版本 Client 依赖安装\n## Centos\nyum -y install epel-release\nyum -y install python3-pip gcc python3-devel\npython3 -m pip install psutil requests py-cpuinfo\n\n## Ubuntu/Debian\napt -y install python3-pip\npython3 -m pip install psutil requests py-cpuinfo\n\n## Alpine linux\napk add wget python3 py3-pip gcc python3-dev musl-dev linux-headers\napk add procps iproute2 coreutils\npython3 -m pip install psutil requests py-cpuinfo\n\nwget --no-check-certificate -qO stat_client.py 'https://raw.githubusercontent.com/zdz/ServerStatus-Rust/master/client/stat_client.py'\n\n## Windows\n# 安装 python 3.10 版本，并设置环境变量\n# 命令行执行 pip install psutil requests\n# 下载 https://raw.githubusercontent.com/zdz/ServerStatus-Rust/master/client/stat_client.py\npip install psutil requests py-cpuinfo\n\npython3 stat_client.py -h\npython3 stat_client.py -a \"http://127.0.0.1:8080/report\" -u h1 -p p1\n```\n\u003c/details\u003e\n\n## 5. 开启 `vnstat` 支持\n[vnstat](https://zh.wikipedia.org/wiki/VnStat) 是Linux下一个流量统计工具，开启 `vnstat` 后，`server` 完全依赖客户机的 `vnstat` 数据来显示月流量和总流量，优点是重启不丢流量数据。\n\n\u003cdetails\u003e\n  \u003csummary\u003e开启 vnstat 设置\u003c/summary\u003e\n\n```bash\n# 在client端安装 vnstat\n## Centos\nsudo yum install epel-release -y\nsudo yum install -y vnstat\n## Ubuntu/Debian\nsudo apt install -y vnstat\n\n# 修改 /etc/vnstat.conf\n# BandwidthDetection 0\n# MaxBandwidth 0\n# 默认不是 eth0 网口的需要置空 Interface 来自动选择网口\n# 没报错一般不需要改\n# Interface \"\"\nsystemctl restart vnstat\n\n# 确保 version \u003e= 2.6\nvnstat --version\n# 测试查看月流量 (刚安装可能需等一小段时间来采集数据)\nvnstat -m\nvnstat --json m\n\n# client 使用 -n 参数开启 vnstat 统计\n./stat_client -a \"grpc://127.0.0.1:9394\" -u h1 -p p1 -n\n# 或\npython3 stat_client.py -a \"http://127.0.0.1:8080/report\" -u h1 -p p1 -n\n```\n\u003c/details\u003e\n\n## 6. FAQ\n\n\u003cdetails\u003e\n  \u003csummary\u003e如何使用自定义主题\u003c/summary\u003e\n\n更简单的方式 👉 [#37](https://github.com/zdz/ServerStatus-Rust/discussions/37)\n\n```nginx\nserver {\n  # ssl, domain 等其它 nginx 配置\n\n  # 反代 /report 请求\n  location = /report {\n    proxy_set_header Host              $host;\n    proxy_set_header X-Real-IP         $remote_addr;\n    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;\n    proxy_set_header X-Forwarded-Proto $scheme;\n    proxy_set_header X-Forwarded-Host  $host;\n    proxy_set_header X-Forwarded-Port  $server_port;\n\n    proxy_pass http://127.0.0.1:8080/report;\n  }\n  # 反代 json 数据请求\n  location = /json/stats.json {\n    proxy_set_header Host              $host;\n    proxy_set_header X-Real-IP         $remote_addr;\n    proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;\n    proxy_set_header X-Forwarded-Proto $scheme;\n    proxy_set_header X-Forwarded-Host  $host;\n    proxy_set_header X-Forwarded-Port  $server_port;\n\n    proxy_pass http://127.0.0.1:8080/json/stats.json;\n  }\n  # v1.4.0后，同样需要反代  /detail, /map\n\n  # 其它 html,js,css 等，走本地文本\n  location / {\n    root   /opt/ServerStatus/web; # 你自己修改的主题目录\n    index  index.html index.htm;\n  }\n}\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e如何源码编译\u003c/summary\u003e\n\n```bash\n#\ncargo install stat_server\ncargo install stat_client\n# or\n# 按提示安装 rust 编译器\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\nyum install -y openssl-devel\ngit clone https://github.com/zdz/ServerStatus-Rust.git\ncd ServerStatus-Rust\ncargo build --release\n# 编译好的文件目录 target/release\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e如何自定义 ping 地址\u003c/summary\u003e\n\n```bash\n# 例如自定义移动探测地址，用 --cm 指定地址\n./stat_client -a \"grpc://127.0.0.1:9394\" -u h1 -p p1 --cm=cm.tz.cloudcpp.com:80\n\n# 电信联通参数可以使用 -h 命令查看\n./stat_client -h\nOPTIONS:\n    --cm \u003cCM_ADDR\u003e    China Mobile probe addr [default: cm.tz.cloudcpp.com:80]\n    --ct \u003cCT_ADDR\u003e    China Telecom probe addr [default: ct.tz.cloudcpp.com:80]\n    --cu \u003cCU_ADDR\u003e    China Unicom probe addr [default: cu.tz.cloudcpp.com:80]\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e关于这个轮子\u003c/summary\u003e\n\n  之前一直在使用 `Prometheus` + `Grafana` + `Alertmanager` + `node_exporter` 做VPS监控，这也是业界比较成熟的监控方案，用过一段时间后，发现非生产环境，很多监控指标都用不上，运维成本有点大。\n  而 `ServerStatus` 很好，足够简单和轻量，一眼可以看尽所有小机机，只是 `c++` 版本很久没迭代过，自己的一些需求在原版上不是很好修改，如自带 `tcp` 上报对跨区机器不是很友好，也不方便对上报的链路做优化 等等。这是学习 `Rust` 练手的小项目，所以不会增加复杂功能，保持小而美，简单部署，配合 [Uptime Kuma](https://github.com/louislam/uptime-kuma) 基本上可以满足个人大部分监控需求。\n\n\u003c/details\u003e\n\n## 7. 相关项目\n- https://github.com/BotoX/ServerStatus\n- https://github.com/cppla/ServerStatus\n- https://github.com/mojeda/ServerStatus\n- https://github.com/cokemine/ServerStatus-Hotaru\n- https://github.com/ToyoDAdoubiBackup/ServerStatus-Toyo\n\n## 8. 最后\n\n    很高兴我的代码能跑在你的服务器上，如果对你有帮助的话，欢迎留下你的 star ⭐ 支持一下\n\n","funding_links":["https://github.com/sponsors/zdz"],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzdz%2FServerStatus-Rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzdz%2FServerStatus-Rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzdz%2FServerStatus-Rust/lists"}