奇诺分享 | ccino.org

  • 首页
  • VPS
    • VPS申请
    • VPS配置
    • 科学上网
  • 网站建设
    • WordPress
  • 程序猿
    • 开发工具
    • 微服务
    • 容器
    • 分布式
    • 数据库
    • 人工智能
  • 杂项
  • 关于
  • Privacy Policy
生活不只是眼前的苟且,还有诗和远方!
  1. 首页
  2. VPS
  3. VPS配置
  4. 正文

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

2017年5月14日 2031点热度 0人点赞 0条评论

介绍

serverstatus 是非常优秀的服务器监控开源系统。非常直观。具体 demo 可以看: https://tz.cloudcpp.com/

如果你有多台服务器,特别是想监控带宽之类的常用指标,这个云监控非常好用。

Hhwf.png

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

我自用的代码: https://github.com/91yun/ServerStatus-1
我自用的代码修改了流量方面的统计,使用 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++

 

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

 

第三步:编辑 config 文件

vim 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 :请确保 passwordd 和 username 是对应的,为了方便起见,可以所有子服务器的 password 是一样的,但是 username 必须唯一。

对应关系如下图:
H84U.png

 

第四步:把 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 (注意服务器和被监控的客户端防火墙都要开相应的端口)

如果启动服务器端没问题,可以使用 nohup 后台启动

nohup ./sergate --config=config.json --web-dir=/home/wwwroot/default --port=91 &> /dev/null &

 

客户端的安装

安装依赖包

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
vim client-psutil.py

 

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

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

 

后台运行客户端代码

python client-psutil.py

 

如果客户端没有出错的话,那么可以使用 nohup 后台运行的方式启动

 

本文出自:

 

https://www.91yun.org/archives/8661

标签: 监控
最后更新:2017年5月23日

奇诺分享 | ccino.org

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理。

COPYRIGHT © 2022 奇诺分享 | ccino.org. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang