本文最后更新于2020年12月16日,可能会因为没有后期更新而失效。如果您发现本文已经失效或者需要修正,请留言给博主!感谢
前言
ServerStatus 中文版是一个酷炫高逼格的云探针、云监控、服务器云监控、多服务器探针~。
项目地址:https://github.com/cppla/ServerStatus
服务端部署
一、安装运行环境
yum /y install gcc-c++ git
二、生成服务端程序
cd /usr/local/ git clone https://github.com/cppla/ServerStatus.git cd ServerStatus/server make ./sergate
如果没错误提示,OK,ctrl+c 关闭;如果有错误提示,检查 35601 端口是否被占用
三、修改配置文件
vi /usr/local/ServerStatus/server/config.json
{“servers”:
[
{
“disabled”: true/false(定义是否可用:否/是),
“username”: “账户名”,
“name”: “节点名”,
“type”: “虚拟化架构”,
“host”: “主机属性”,
“location”: “地区”,
“password”: “密码”
},
]
}
四、拷贝 ServerStatus/status 到你的网站目录
如:
cp -r /usr/local/ServerStatus/web/* /usr/share/nginx/html/
五、运行服务端:
web-dir 参数为上一步设置的网站根目录,务必修改成自己网站的路径
/usr/local/ServerStatus/server/sergate --config=/usr/local/ServerStatus/server/config.json --web-dir=/usr/share/nginx/html/
六、添加 ServerStatus 开机自启动
配置自启动服务
cat > /usr/lib/systemd/system/sergate.service <<-EOF [Unit] Description=sergate After=network.target [Service] Type=simple PIDFile= ExecStart=/usr/local/ServerStatus/server/sergate --config=/usr/local/ServerStatus/server/config.json --web-dir=/usr/share/nginx/html ExecReload= ExecStop=killall sergate PrivateTmp=true [Install] WantedBy=multi-user.target EOF
添加 sergate 启动项
systemctl enable sergate
客户端配置
本文客户端程序放在ServerStatus/clients
下
客户端有两个版本,client-linux 为普通 linux,client-psutil 为跨平台版,若普通版不成功,换成跨平台版即可。
使用命令下载客户端文件:
mkdir /opt/script cd /opt/script wget https://raw.githubusercontent.com/cppla/ServerStatus/master/clients/client-linux.py
client-linux 版配置:
修改 SERVER 地址:使用指向服务端 IP 地址的域名或服务端 IP 地址
username 帐号与 password 密码同服务端定义的的匹配:(建议使用不同帐号、相同密码即可。不同账号用于服务端识别接收的数据是哪个客户端的数据)
vi /opt/script/client-linux.py
添加自启动
cat >/etc/rc.d/init.d/autostart.sh <<-EOF #!/bin/bash #chkconfig: 345 81 96 #description: python client-linux.py python /opt/script/client-linux.py EOF
授予可执行权限
chmod +x /etc/rc.d/init.d/autostart.sh
打开开机启动
cd /etc/rc.d/init.d chkconfig --add autostart.sh chkconfig autostart.sh on
重启测试效果
reboot