Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

jumploop/ServerStatus

Open more actions menu
 
 

Repository files navigation

ServerStatus 中文版:

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

Python Support C++ Compiler License Version

Latest Host Version

Watchdog触发式告警,interval只是为了防止频繁收到报警,并不是探测间隔。值得注意的是Exprtk使用窄字符类型,中文等Unicode字符无法解析计算。 AI已经能够取代大部分程序员

  • clients 客户端文件

  • server 服务端文件

  • web 网站文件

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

  • web/json 探针月流量

Linux 服务器部署

支持操作系统:Debian/Ubuntu,Centos/Redhat,archlinux

PS:部署完如果有防火墙,请放行对应端口,否则无法访问,或者关闭防火墙(不建议)

一键脚本部署:

wget -N --no-check-certificate https://raw.githubusercontent.com/jumploop/ServerStatus/master/status.sh && chmod +x status.sh && bash status.sh

部署成功后,web 服务地址:http://ip:8888

容器部署:

PS:部署完如果有防火墙,请放行对应端口,否则无法访问,或者关闭防火墙(不建议)

【服务端】:

`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 &

以下一键部署脚本,由本人维护,放心使用

PS: 部署完服务端,会执行节点管理脚本,添加和删除要监控的节点,请确保服务器可以访问。

服务端一键脚本容器部署:

wget -N --no-check-certificate https://raw.githubusercontent.com/jumploop/ServerStatus/master/shell/serverstatus_deploy.sh && chmod +x serverstatus_deploy.sh && bash serverstatus_deploy.sh

Server 酱上下线提醒服务端一键脚本容器部署:

需要传入 Server 酱的 SendKey

wget -N --no-check-certificate https://raw.githubusercontent.com/jumploop/ServerStatus/master/shell/serverstatus_serverchan_deploy.sh && chmod +x serverstatus_serverchan_deploy.sh && bash serverstatus_serverchan_deploy.sh SendKey

Telegram 上下线提醒服务端一键脚本容器部署:

需要传入 Telegram 的 YOUR_TG_CHAT_ID,YOUR_TG_BOT_TOKEN

wget -N --no-check-certificate https://raw.githubusercontent.com/jumploop/ServerStatus/master/shell/serverstatus_telegram_deploy.sh && chmod +x serverstatus_telegram_deploy.sh && bash serverstatus_telegram_deploy.sh YOUR_TG_CHAT_ID YOUR_TG_BOT_TOKEN

pushplus 上下线提醒服务端一键脚本容器部署:

需要传入 pushplus 的 YOUR_PP_BOT_TOKEN

wget -N --no-check-certificate https://raw.githubusercontent.com/jumploop/ServerStatus/master/shell/serverstatus_pushplus_deploy.sh && chmod +x serverstatus_pushplus_deploy.sh && bash serverstatus_pushplus_deploy.sh YOUR_PP_BOT_TOKEN

部署成功后,web 服务地址:http://ip:8080

节点管理,生成一键客户端部署命令

通过 config_manager.py 脚本,可以很方便的进行节点的增删改查操作。特别在添加新节点时,会有提示如何在新节点安装对应的 agent 服务。节点管理时,把 config_manager.py 放到和 config.json 同一目录,运行 python3 config_manager.py 即可,默认配置文件 config.json 和脚本在同一目录,ServerStatus 默认服务重启命令为docker-compose restart。支持传入重启 ServerStatus 服务命令和 config.json 配置文件路径,改成你对应的服务启动方式和配置文件路径,例如用 systemd,则传入systemctl restart ServerStatus

脚本的参数,主要有 2 个:

wget -N --no-check-certificate https://raw.githubusercontent.com/jumploop/ServerStatus/master/plugin/config_manager.py

python3 config_manager.py -a xxx -c xxx

-a, --action ServerStatus服务重启命令,默认为docker-compose restart
-c, --config config.json配置文件路径,默认为脚本当前路径

eg:
python3 config_manager.py -a 'systemctl restart ServerStatus' -c config.json

效果如下: 添加节点

主题:

手动安装教程:

【服务端配置】

一、生成服务端程序

`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,告警内容将拼接其后并发起回调

! Telegram: https://api.telegram.org/bot你自己的密钥/sendMessage?parse_mode=HTML&disable_web_page_preview=true&chat_id=你自己的标识&text=
! Server酱: https://sctapi.ftqq.com/你自己的密钥.send?title=ServerStatus&desp=
! PushDeer: https://api2.pushdeer.com/message/push?pushkey=你自己的密钥&text=
! HttpBasicAuth: https://用户名:密码@你自己的域名/api/push?message=
! pushplus: https://www.pushplus.plus/send?token=你的token&title=ServerStatus&content=XXX&template=html

关于 Server 酱的具体使用可以查看Server 酱使用方法

{
        "servers":
	[
		{
			"username": "s01",
			"name": "vps-1",
			"type": "kvm",
			"host": "chengdu",
			"location": "🇨🇳",
			"password": "USER_DEFAULT_PASSWORD",
			"monthstart": 1
		}
	],
	"monitors": [
		{
			"name": "抖音",
			"host": "https://www.douyin.com",
			"interval": 600,
			"type": "https"
		},
		{
			"name": "百度",
			"host": "https://www.baidu.com",
			"interval": 600,
			"type": "https"
		}
	],
	"sslcerts": [
		{
			"name": "demo域名",
			"domain": "https://demo.example.com",
			"port": 443,
			"interval": 600,
			"callback": "https://yourSMSurl"
		}
	],
	"watchdog":
	[
	        {
			"name": "服务器负载高监控,排除内存大于32G物理机,同时排除node1机器",
			"rule": "cpu>90&load_1>4&memory_total<33554432&name!='node1'",
			"interval": 600,
			"callback": "https://yourSMSurl"
		},
		{
                        "name": "服务器内存使用率过高监控,排除小于1G的机器",
                        "rule": "(memory_used/memory_total)*100>90&memory_total>1048576",
                        "interval": 600,
                        "callback": "https://yourSMSurl"
                },
                {
                        "name": "服务器宕机告警",
                        "rule": "online4=0&online6=0",
                        "interval": 600,
                        "callback": "https://yourSMSurl"
                },
		{
                        "name": "DDOS和CC攻击监控,限制甲骨文机器",
                        "rule": "tcp_count>600&type='Oracle'",
                        "interval": 300,
                        "callback": "https://yourSMSurl"
                },
		{
			"name": "服务器月出口流量999GB告警",
			"rule": "(network_out-last_network_out)/1024/1024/1024>999",
			"interval": 3600,
			"callback": "https://yourSMSurl"
		},
		{
			"name": "阿里云服务器流量18GB告警,限制username为乌兰察布",
			"rule": "(network_out-last_network_out)/1024/1024/1024>18&(username='wlcb1'|username='wlcb2'|username='wlcb3'|username='wlcb4')",
			"interval": 3600,
			"callback": "https://yourSMSurl"
		},
		{
			"name": "重要线路丢包率过高检查",
			"rule": "(ping_10010>10|ping_189>10|ping_10086>10)&(host='sgp'|host='qqhk'|host='hk-21-x'|host='hk-31-x')",
			"interval": 600,
			"callback": "https://yourSMSurl"
		},
		{
			"name": "你可以组合任何已知字段的表达式",
			"rule": "(hdd_used/hdd_total)*100>95",
			"interval": 1800,
			"callback": "https://yourSMSurl"
		}
	]
}

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

例如:

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.py Linux 版

# 1、修改 client-linux.py 中的 SERVER、username、password
python3 client-linux.py
# 2、以传参的方式启动
python3 client-linux.py SERVER=127.0.0.1 USER=s01

client-psutil.py 跨平台版

# 安装依赖
# Debian/Ubuntu
apt -y install python3-psutil
# Centos/Redhat
yum -y install python3-pip gcc python3-devel && pip3 install psutil
# Windows: 从 https://pypi.org/project/psutil/ 安装

后台运行与开机启动

# 后台运行
nohup python3 client-linux.py &

# 开机启动 (crontab -e)
@reboot /usr/bin/python3 /path/to/client-linux.py

集成新功能

https://github.com/lidalao/ServerStatus

介绍

项目基于 cppla 版本 ServerStatus, 增加如下功能:

更方便的节点管理, 支持增删改查 上下线通知(telegram) Agent 机器安装脚本改为 systemd, 支持开机自启 由于未改动 cppla 版的任何代码,所以,我愿意把这个项目称为 ServerStatus 的小插件, 理论上它可以为任何版本的 ServerStatus 服务

安装

在服务端复制以下命令,一键到底。请记得替换成你自己的 YOUR_TG_CHAT_ID,YOUR_TG_BOT_TOKEN

其中,Bot token 可以通过@BotFather 创建机器人获取, Chat id 可以通过@getuserID 获取。

wget --no-check-certificate -O sss.sh https://raw.githubusercontent.com/jumploop/ServerStatus/master/shell/sss.sh && chmod +x ./sss.sh && ./sss.sh YOUR_TG_CHAT_ID YOUR_TG_BOT_TOKEN

安装成功后,web 服务地址:http://ip:8081

Make Better

About

云探针、多服务器探针、云监控、多服务器云监控,演示: https://tz.cloudcpp.com/

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages

  • C++ 82.8%
  • C 5.6%
  • Shell 5.0%
  • Python 3.4%
  • JavaScript 1.8%
  • CSS 1.2%
  • Other 0.2%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.