Git Product home page Git Product logo

serverstatus's Introduction

ServerStatus中文版:

  • ServerStatus中文版是一个酷炫高逼格的云探针、云监控、服务器云监控、多服务器探针~。
  • 在线演示:https://tz.cloudcpp.com

Python Support C++ Compiler License Version

Latest Host Version Latest Server Version

Watchdog触发式告警,interval只是为了防止频繁收到报警信息造成的*扰,并不是探测间隔。值得注意的是,Exprtk库默认使用窄字符类型,中文等Unicode字符无法解析计算,等待修复。

目录:

  • clients 客户端文件

  • server 服务端文件

  • web 网站文件

  • server/config.json 探针配置文件      

  • web/json 探针月流量

部署:

【服务端】:

`Docker`:     

wget --no-check-certificate -qO ~/serverstatus-config.json https://raw.githubusercontent.com/cppla/ServerStatus/master/server/config.json && mkdir ~/serverstatus-monthtraffic    
docker run -d --restart=always --name=serverstatus -v ~/serverstatus-config.json:/ServerStatus/server/config.json -v ~/serverstatus-monthtraffic:/usr/share/nginx/html/json -p 80:80 -p 35601:35601 cppla/serverstatus:latest     

`Docker-compose(推荐)`: docker-compose up -d

【客户端】:

wget --no-check-certificate -qO client-linux.py 'https://raw.githubusercontent.com/cppla/ServerStatus/master/clients/client-linux.py' && nohup python3 client-linux.py SERVER={$SERVER} USER={$USER} PASSWORD={$PASSWORD} >/dev/null 2>&1 &

eg:
wget --no-check-certificate -qO client-linux.py 'https://raw.githubusercontent.com/cppla/ServerStatus/master/clients/client-linux.py' && nohup python3 client-linux.py SERVER=45.79.67.132 USER=s04  >/dev/null 2>&1 &

主题:

手动安装教程:

【服务端配置】

一、生成服务端程序

`Debian/Ubuntu`: apt-get -y install gcc g++ make libcurl4-openssl-dev
`Centos/Redhat`: yum -y install gcc gcc-c++ make libcurl-devel

cd ServerStatus/server && make
./sergate

如果没错误提示,OK,ctrl+c关闭;如果有错误提示,检查35601端口是否被占用

二、修改配置文件

! watchdog rule 可以为任何已知字段的表达式。注意Exprtk库默认使用窄字符类型,中文等Unicode字符无法解析计算,等待修复       
! watchdog interval 最小通知间隔
! watchdog callback 可自定义为Post方法的URL,告警内容将拼接其后并发起回调 

! watchdog callback Telegram: https://api.telegram.org/bot你自己的密钥/sendMessage?parse_mode=HTML&disable_web_page_preview=true&chat_id=你自己的标识&text=
! watchdog callback Server酱: https://sctapi.ftqq.com/你自己的密钥.send?title=ServerStatus&desp=
! watchdog callback PushDeer: https://api2.pushdeer.com/message/push?pushkey=你自己的密钥&text=
! watchdog callback BasicAuth: https://用户名:密码@你自己的域名/api/push?message=
{
        "servers":
	[
		{
			"username": "s01",
			"name": "vps-1",
			"type": "kvm",
			"host": "chengdu",
			"location": "🇨🇳",
			"password": "USER_DEFAULT_PASSWORD",
			"monthstart": 1
		}
	],
	"monitors": [
		{
			"name": "监测网站以及MySQL、Redis,默认为七天在线率",
			"host": "https://www.baidu.com",
			"interval": 60,
			"type": "https"
		}
	],
	"watchdog":
	[
	        {
			"name": "服务器负载高监控,排除内存大于32G物理机,同时排除node1机器",
			"rule": "cpu>90&load_1>4&memory_total<33554432&name!='node1'",
			"interval": 600,
			"callback": "https://yourSMSurl"
		},
		{
                        "name": "服务器内存使用率过高监控",
                        "rule": "(memory_used/memory_total)*100>90",
                        "interval": 600,
                        "callback": "https://yourSMSurl"
                },
                {
                        "name": "服务器宕机告警",
                        "rule": "online4=0&online6=0",
                        "interval": 600,
                        "callback": "https://yourSMSurl"
                },
		{
                        "name": "DDOS和CC攻击监控",
                        "rule": "tcp_count>600",
                        "interval": 300,
                        "callback": "https://yourSMSurl"
                },
		{
			"name": "服务器月出口流量999GB告警",
			"rule": "(network_out-last_network_out)/1024/1024/1024>999",
			"interval": 3600,
			"callback": "https://yourSMSurl"
		},
		{
			"name": "你可以组合任何已知字段的表达式",
			"rule": "(hdd_used/hdd_total)*100>95",
			"interval": 1800,
			"callback": "https://yourSMSurl"
		}
	]
}       

三、拷贝ServerStatus/status到你的网站目录

例如:

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

四、运行服务端:

web-dir参数为上一步设置的网站根目录,务必修改成自己网站的路径

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

【客户端配置】

客户端有两个版本,client-linux为普通linux,client-psutil为跨平台版,普通版不成功,换成跨平台版即可。

一、client-linux版配置:

1、vim client-linux.py, 修改SERVER地址,username帐号, password密码
2、python3 client-linux.py 运行即可。

二、client-psutil版配置:

1、安装psutil跨平台依赖库

`Debian/Ubuntu`: apt -y install python3-pip && pip3 install psutil    
`Centos/Redhat`: yum -y install python3-pip gcc python3-devel && pip3 install psutil      
`Windows`: https://pypi.org/project/psutil/    

2、vim client-psutil.py, 修改SERVER地址,username帐号, password密码
3、python3 client-psutil.py 运行即可。

服务器和客户端自行加入开机启动,或进程守护,或后台方式运行。 例如: nohup python3 client-linux.py &

extra scene (run web/ssview.py) Shell View

Make Better

Jetbrains

serverstatus's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

serverstatus's Issues

命令行工具

如果有命令行工具可以快速查看就好了,因为不是任何时候都想打开网页去看的。

能否在列表中加入空栏?

首先非常感谢作者的无私奉献!
小弟已经部署成功,提出一个小要求,不知道是能自定义加入一些空栏,因为如果客户端太多需要分类时这样显示出来的列表更直观了!例如:在第四行加入一行空栏,如果空栏能写入内容更好了,例如:US-SSR ; 这样多客户端时看得更舒服明白! 谢谢

不能自动刷新

使用docker部署服务器端,基于bt的nginx反向代理,不能自动刷新,stats.json总是from disk cache

统计流量

有一个服务器的上下行流量统计不上,

国内部分地区阻断了jquery官方https链接

建议把 code.jquery.com/jquery-1.10.2.min.js 替换成国内cdn
更好的方法是本地化并加一句判断,如果cdn连不上就用本地文件

示例:

<script src="https://cdn.bootcss.com/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
<![CDATA[
if (typeof jQuery == 'undefined') {
  document.write(unescape("%3Cscript src='/js/jquery-2.1.4.min.js' type='text/javascript'%3E%3C/script%3E"));}
 ]]>
</script>

能否将docker做小一点?

我用这个Dockerfile构建出来的镜像大小高达387MB,已经很占我服务器的空间了。能否用caddy替代nginx?nginx本身就很大,用alpine镜像构建就更好了

REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
serverstatus_server          latest              8ad86276b7a7        2 weeks ago         387MB

archlinux上应该怎么运行客户端?

有软件需求必须用archlinux

现在运行客户端就报错

[root@archlinux alice]# /usr/bin/python "/usr/local/ServerStatus/client-linux.py"
Connecting...
Caught Exception: argument should be integer or bytes-like object, not 'str'
Connecting...
Caught Exception: argument should be integer or bytes-like object, not 'str'
Connecting...
Caught Exception: argument should be integer or bytes-like object, not 'str'
Connecting...
Caught Exception: argument should be integer or bytes-like object, not 'str'
Connecting...
Caught Exception: argument should be integer or bytes-like object, not 'str'
Connecting...
Caught Exception: argument should be integer or bytes-like object, not 'str'
^CTraceback (most recent call last):
File "/usr/local/ServerStatus/client-linux.py", line 243, in
if data.find("Authentication required") > -1:
TypeError: argument should be integer or bytes-like object, not 'str'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/ServerStatus/client-linux.py", line 317, in
time.sleep(3)
KeyboardInterrupt

求助下大佬是什么原因?

某些情况下无法客户端无法获取信息

Python 2.7.3
反复重启提示错误
You are connecting via: IPv4 ('Caught Exception:', AttributeError("'module' object has no attribute 'check_output'",)) Connecting... Authentication successful. Access granted.

丢包率

建议去掉丢包率, 加 了丢包率,3台全见红, 连我家里的客户端都见红.

能否将在线时间精确到秒?

超过1天的在线时间,精度只到天,不超过1天的却精确到秒,能否也让超过1天的在线时间精确到秒?最后更新也显示准确时间而不是几秒前

Thread count by ps -eLf

Please replace "ps -xH" in line 148 of client-linux.py (and in line 114 of client-psutil.py) with "ps -eLf".

ping: invalid option -- 'O' !in Centos 6.1 python 3.6.1

大佬,client客户端中client-linux.py 和 client-psutil.py都尝试了。
都是出现

ping: invalid option -- 'O'
Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline]
[-p pattern] [-s packetsize] [-t ttl] [-I interface or address]
[-M mtu discovery hint] [-S sndbuf]
[ -T timestamp option ] [ -Q tos ] [hop1 ...] destination
ping: invalid option -- 'O'
Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline]
[-p pattern] [-s packetsize] [-t ttl] [-I interface or address]
[-M mtu discovery hint] [-S sndbuf]
[ -T timestamp option ] [ -Q tos ] [hop1 ...] destination
Connecting...
ping: invalid option -- 'O'
Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline]
[-p pattern] [-s packetsize] [-t ttl] [-I interface or address]
[-M mtu discovery hint] [-S sndbuf]
[ -T timestamp option ] [ -Q tos ] [hop1 ...] destination
Caught Exception: a bytes-like object is required, not 'str'
Connecting...
Caught Exception: a bytes-like object is required, not 'str'

求解~感谢!

网速有点不准

小鸡都限制在50M以内的速度 后台可以看到实际速度

但是监控速度 上下100M

是不是因为是开的LXC的虚拟机原因? 计算了2次?

新增加的三网延迟,宿主机显示均为0ms

看到新增了三网ping延迟,更新了一下。

各个节点显示都没问题。

但是ServerStatus服务端宿主机上本机运行客户端监控自己的情况,从网页上看三网延迟均为0ms,大佬看一下这个问题,谢谢

负载显示

Readme内显示在20170807修改了负载的显示方法,可是commit是从2018626开始的。请问是修改了那几个文件?

开机

怎么样才能支持开机自动启动呢
请问,折腾了好久没有成功

关于客户端的指令

大大,请教一下,客户端的维护指令,例如客户端停止、重启、状态查询、卸载等。谢谢!

关于网络延迟的问题

经过这几天的观察,发现除了移动的线路是固定IP获取信息外,电信和联通都加了cdn,获取的信息不准确。望加以修正。

banned ip

banned '****' for 1 minute (You're an idiot, go away.)
发现会自动ban ip,请问这是什么原因呢?

时延显示

已经有了丢包率,如果还有时延显示就更好了。

希望大佬添加支持vnStat ,这样就完美了!

我自己尝试添加这个模块,无奈本人对C#不熟悉,折腾了几个晚上均以失败告终

https://github.com/P3terChan/ServerStatus-V
这个项目里面有现成的,但是他没有三网监控,91yun的也是如此
如果大佬添加支持vnStat,那就相当的完美了
而且他这个项目的轮子过于老旧,客户端也问题多多,基本不太能用!

还有一个功能建议
其实目前那个“负载”功能基本上没什么用,因为后面已经有CPU 内存等信息
而且这个“负载”功能又占栏位,大佬大可将这个负载变成
https://github.com/ToyoDAdoubi/ServerStatus-Toyo
的在线数统计功能,逗比这个功能非常实用,配合SS V2 什么之类的,超级实用,

结合vnStat ,在线统计,这两个功能加入,这个项目将会是目前最强大的探针!
望大佬有时间抽空出来写写BUG!
仰望!

偶尔会显示错误

tim 20181211063645
偶尔会如上图一样,每台服务器之间隔得特别开。
正常状态如下图。
tim 20181211064355
请问有没有什么办法解决?

Windows客户端频繁掉线

情况是这样的,我的服务端在洛杉矶,但是我有一台Windows Server 2012 VPS在重庆,在此机器上运行client-psutil版实现对其监测,但是它频繁掉线(几分钟掉一次)。服务端显示 OnDelClient,网页显示掉线二十多秒后能在客户端看到Disconnected...,然后显示Connecting...,然后看到服务端显示OnNewClient,最后网页重新出现数据。
我尝试使用tcping工具ping服务端对应端口,几乎没有丢包情况(小于1%)。个人感觉问题不应该出在网络传输上。
请问其他朋友有无遇到此问题,是否有解决方案?感谢!

手机端网页显示无适配

不管是竖屏、横屏,还是请求桌面站点,都没有适配,信息看不全,也无法点击。

with iPhone8 Plus, iOS 12, Safari

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.