ServerStatus
这个云探针我就不多说了,你们都懂的。
本帖要讲的是我自己更改过的版本,说明下使用方法。
关于本 Repo 的详细请看: https://github.com/nanqinlang-mogic/ServerStatus
Live Demo: https://sometimesnaive.org/status/
这个云探针包括 服务端
和 客户端
两部分:
服务端
首先要获取文件
git clone https://github.com/nanqinlang-mogic/ServerStatus.git
文件获取完成后,你需要按照如下示例的样式修改配置文件 /ServerStatus/server/config.json
。其中,每一台客户端对应一个唯一的 username
,服务端和客户端的 password
必须对应。
{ "servers": [ { "username": "nanqinlang1", "name": "南琴浪博客", "type": "KVM", "location": "LosAngeles", "password": "nanqinlang", }, { "username": "nanqinlang2", "name": "sometimesnaive.org", "type": "KVM", "location": "LosAngeles", "password": "nanqinlang", } ] }
然后修改 /ServerStatus/website/index.html
为你自己想要的样式后,就要启动服务端了
cd ~/server chmod 7777 ServerStatus nohup ./ServerStatus --config=config.json --web-dir=~/website &
其中,--web-dir
是你的 website 文件夹所在的绝对路径,这里的 website 文件夹指的是 git clone 获得的那个。
以上完成后,用 HTTP Server
加载你的 index.html
,以下以 Nginx
为例:
# if use nginx, just need to add this rule server { root ~/website; index index.html; }
至此,服务端就 ok 了。
客户端
客户端需要使用 Python 2.7+
运行且仅支持 Linux 平台,客户端文件位于 /ServerStatus/client/client.py
修改客户端文件 client.py
的前五行
SERVER = "你的服务端的公网 IP" PORT = 65535 #监听端口,固定,不能修改 USER = "你的服务端上对应的 username" PASSWORD = "你的服务端上对应的 password" INTERVAL = 1 #客户端向服务端提交数据更新的间隔周期,单位是秒
其中,SERVER
项所填的 IP,如果客户端和服务端是同一台机就填 127.0.0.1,其它情况就填服务端公网 IP。username
和 password
必须严格对应,username 在服务端配置中不能重复。
例如,以上面服务端示例中对应的客户端配置为(以第二个配置为例):
SERVER = "x.x.x.x" PORT = 65535 USER = "nanqinlang2" PASSWORD = "nanqinlang" INTERVAL = 1
修改完成后,运行客户端
nohup python client.py &
至此,ServerStatus 这个云探针就部署完成了。
转载请注明:逗比根据地 » ServerStatus 云探针 使用指南