服务器安装探针服务

教程8个月前更新 lost4
276 0

ServerStatus中文版是一个酷炫高逼格的云探针、云监控、服务器云监控、多服务器探针~。

在线演示:https://tz.cloudcpp.com

部署(docker

先在服务器docker的常用目录下新建文件夹
mkdir -p /aa/bb/cc #创建文件夹
cd /aa/bb/cc #进入文件夹
wget --no-check-certificate -qO ~/serverstatus-config.json https://raw.githubusercontent.com/cppla/ServerStatus/master/server/config.json && mkdir ./serverstatus-monthtraffic #下载配置文件到当前目录

vim docker-compose.yml #创建docker配置

version: '3.3'
services:
  serverstatus:
    image: cppla/serverstatus:latest
    container_name: serverstatus
    ports:
      - '8081:80'
      - '35601:35601'
    volumes:
      - './serverstatus-config.json:/ServerStatus/server/config.json'
      - './serverstatus-monthtraffic:/usr/share/nginx/html/json'
    restart: always

创建完运行命令docker compose up -d安装

修改配置文件

{
        "servers":
	[
		{
			"username": "s01",
			"name": "vps-1",
			"type": "kvm",
			"host": "chengdu",
			"location": "🇨🇳",
			"password": "USER_DEFAULT_PASSWORD",
			"monthstart": 1
		},
	],
	"watchdog":
	[
	        {
			"name": "服务器负载高监控,排除内存大于32G物理机,同时排除俄勒冈机器",
			"rule": "cpu>90&load_1>4&memory_total<33554432&name!='俄勒冈'",
			"interval": 600,
			"callback": "https://yourSMSurl"
		},
		{
                        "name": "服务器内存使用率过高监控",
                        "rule": "(memory_used/memory_total)*100>90",
                        "interval": 600,
                        "callback": "https://yourSMSurl"
                },
                {
                        "name": "服务器宕机告警,排出俄勒冈,排除s02",
                        "rule": "online4=0&online6=0&name!='俄勒冈'&username!='s02'",
                        "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"
		}
	]
}
! watchdog rule 可以为任何已知字段的表达式
! 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=

客户端部署

原来的项目客户端布置命令如下

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 &
不推荐,因为在客户端上布置的python没有开机自动运行,并且卸载不方便。

以下是推荐的另一种命令,稍微修改了下

curl -L https://github.com/lostiv/ServerStatus/raw/master/sss-agent.sh -o sss-agent.sh && chmod +x sss-agent.sh && sudo ./sss-agent.sh 服务端的ip地址 设定的账号 设定的密码

这个命令在你的目录下下载并创建sss-agent.sh这个命令,让py加入开机运行例。如果要卸载就运行bash sss-agent.sh选择卸载即可。

服务器安装探针服务

最后感谢这2个开源项目:
cppla/ServerStatuslidalao/ServerStatus

© 版权声明

相关文章