Serverstatus安装教程:好用直观简单的多服务器监控系统

serverstatus 是非常优秀的服务器监控开源系统。非常直观。具体 demo 可以看: https://tz.cloudcpp.com/如果你有多台服务器,特别是想监控带宽之类的常用指标,这个云监控非常好用。

中文版开源代码: https://github.com/tenyue/ServerStatus

91yun的代码: https://github.com/91yun/ServerStatus-1

91yun的代码修改了流量方面的统计,使用 vnstat 来统计月流量。有兴趣的朋友也可以自行看看。以下的教程是以 tenyue 的代码为准的。

安装服务器端

第一步:从 git 复制代码

git clone https://github.com/tenyue/ServerStatus.git

第二步:编译服务器端

cd ServerStatus/server
make

如果编译出错,请安装编译依赖文件:

centos :

yum -y update gcc
yum -y install gcc+ gcc-c++

ubuntu :

apt-get update gcc
apt-get install g++

第三步:编辑 config 文件

nano config.json
{"servers":
[
{
"username": "s01",
"name": "Mainserver 1",
"type": "Dedicated Server",
"host": "GenericServerHost123",
"location": "Austria",
"password": "some-hard-to-guess-copy-paste-password"
},
{
"username": "s02",
"name": "Mainserver 2",
"type": "Dedicated Server",
"host": "GenericServerHost123",
"location": "USA",
"password": "some-hard-to-guess-copy-paste-password"
},
]
}

请注意确保每个子服务器的 username 是唯一

username :子服务器, serverstatus 通过这来辨识子服务器的身份

name :随意取个名字

type :文本,随意,一般是指“ VPS ”“独服”这种

host :文本,随意

location :文本,随意,一般填服务器所在区域

password :请确保 password 和 username 是对应的,为了方便起见,可以所有子服务器的 password 是一样的,但是 username 必须唯一。

对应关系如下图:

第四步:把 web 文件拷到你自己的 web 访问的目录

cp -r ServerStatus/web/* /home/wwwroot/default

第五步:启动服务器端

./sergate --config=config.json --web-dir=/home/wwwroot/default --port=91

–config :配置文件地址

–web-dir:web 地址, serverstatus 会在这里生成 json 文件供网页调用

–port :监听的端口,默认是 35601 (注意服务器和被监控的客户端防火墙都要开相应的端口)

如果启动服务器端没问题,可以screen运行

screen -S web

./sergate --config=config.json --web-dir=/home/wwwroot/default --port=91

客户端的安装

安装依赖包

for Centos :

sudo yum -y install epel-release
sudo yum -y install python-pip
sudo yum clean all
sudo yum -y install gcc
sudo yum -y install python-devel
sudo pip install psutil

for Ubuntu/Debian:

sudo root
apt-get -y install python-setuptools python-dev build-essential
apt-get -y install python-pip
pip install psutil

for Windows:

打开网址: https://pypi.python.org/pypi?:action=display&name=psutil#downloads

下载 psutil for windows 程序包

安装即可

下载客户端代码并修改配置

github 提供了 2 种客户端的 python 文件,建议使用 client-psutil :

wget https://raw.githubusercontent.com/tenyue/ServerStatus/master/clients/client-psutil.py
nano client-psutil.py

修改 SERVER 地址, username 帐号, password 密码

SERVER = "服务器端地址"
PORT = 服务器端端口
USER = "这台服务器的username,对应服务器config.conf文件的username"
PASSWORD = "密码,也是对应服务器config.conf文件的password"
INTERVAL = 1

后台运行客户端代码

python client-psutil.py

如果客户端没有出错的话,那么可以在上一个screen里面运行

screen -r web

python client-psutil.py

 

 

 

 

转载自:91云(91yun.org) » Serverstatus安装教程:好用直观简单的多服务器监控系统

2 条评论

liwanglin12进行回复 取消回复

*