2019-7-19 官方文档已经非常简单了,还有一键脚本安装,方便! 感谢大神的无私奉献。
https://github.com/cppla/ServerStatus
服务端平台:Ubuntu server 16.04
cd /home
git clone http://github.com/tenyue/ServerStatus.git
在 /home 目录就会生成一个 ServerStatus 文件夹,然后继续
cd ServerStatus/server
make
./sergate
这时如果有报错的话,有可能是Python问题或者是35601端口被占用的问题。请自行解决!
{“servers”:
[
{
“username”: “Test01”,
“name”: ” 1″,
“type”: “Linux Server”,
“host”: “Demo Svr 01”,
“location”: “USA”,
“password”: “abcd1234”
},
]
}
其中username、password是对应客户端的,其他参数是描述内容,喜欢填什么都行!
3)复制监测页面
在源码的目录里有 ServerStatus/web 目录,把该目录里的所有文件复制到服务端的网页默认目录,例如:
ubuntu apache的默认目录为 /var/www/html ,执行以下指令
cp -r /home/ServerStatus/web/* /var/www/html
4)运行服务端
cd /home/ServerStatus/server
sergate –config=/home/ServerStatus/server/config.json –web-dir=/var/www/html
如果需要自启动该服务,可以在 /etc/rc.local 里加入一行
/home/ServerStatus/server/sergate –config=/home/ServerStatus/server/config.json –web-dir=/var/www/html &
这样的服务器每次启动,该服务就会在后台运行了。
客户端安装:
1)上面源代码目录里还有一个 client 的目录,目录里有一个client-linux.py 的文件
2)编辑该文件,修改里面的几个参数:
SERVER = “1.2.3.4” <- 修改为你服务端的IP地址或者域名
PORT = 35601 <- 默认端口,要对应服务端端口
USER = “USER” <- 对应服务端配置文件里的
PASSWORD = “USER_PASSWORD” <- 对应服务端配置文件里的
3)运行客户端
/usr/bin/python /home/ServerStatus/clients/client-linux.py
自启动脚本建立在 /etc/init.d/autocpp ,脚本内容如下
#!/bin/bash
sleep 10 && python /home/ServerStatus/clients/client-linux.py
然后授权:
chmod 755 /etc/init.d/autocpp
4)最后用 sysv-rc-conf 授权autocpp服务启用开机运行
客户端自启动方法:
1、chmod 755 /root/client-linux.py
2、vim /etc/crontab,尾部追加以下指令
@reboot root /path/client-linux.py SERVER=服务器IP或者域名 USER=你的用户名 PASSWORD=你的密码