哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP、TCP、Ping 监控报警,命令批量执行和计划任务



   

:trollface: 哪吒监控 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,命令批量执行和计划任务。

>> QQ 交流群:872069346 加群要求:已搭建好哪吒监控 & 有 2+ 服务器

>> 我们的用户 (Google)

默认主题 DayNight @JackieSung hotaru
首页截图1

安装脚本

推荐配置: 安装前准备 两个域名,一个可以 接入 CDN 作为 公开访问,比如 (status.nai.ba);另外一个解析到面板服务器作为 Agent 连接 Dashboard 使用,不能接入 CDN 直接暴露面板主机 IP,比如(randomdashboard.nai.ba)。

curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh  -o nezha.sh && chmod +x nezha.sh
sudo ./nezha.sh

国内镜像加速:

curl -L https://cdn.jsdelivr.net/gh/naiba/nezha@master/script/install.sh -o nezha.sh && chmod +x nezha.sh
CN=true sudo ./nezha.sh

* 使用 WatchTower 可以自动更新面板,Windows 终端可以使用 nssm 配置自启动(见尾部教程)

功能说明

计划任务:备份脚本、服务重启,等定期运维任务。

使用此功能可以定期结合 restic、rclone 给服务器备份,或者定期某项重启服务来重置网络连接。

报警通知:CPU、内存、硬盘、带宽、流量实时监控。

灵活通知方式

#NEZHA# 是面板消息占位符,面板触发通知时会自动替换占位符到实际消息

Body 内容是JSON 格式的:当请求类型为 FORM 时,值为 key:value 的形式,value 里面可放置占位符,通知时会自动替换。当请求类型为 JSON 时 只会简进行字符串替换后直接提交到URL

URL 里面也可放置占位符,请求时会进行简单的字符串替换。

参考下方的示例,非常灵活。

  1. 添加通知方式

    • server 酱示例

    • wxpusher 示例,需要关注你的应用

    • telegram 示例 @haitau 贡献

      • 名称:telegram 机器人消息通知
      • URL:https://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&text=#NEZHA#
      • 请求方式: GET
      • 请求类型: 默认
      • Body: 空
      • URL 参数获取说明:botXXXXXX 中的 XXXXXX 是在 telegram 中关注官方 @Botfather ,输入/newbot ,创建新的机器人(bot)时,会提供的 token(在提示 Use this token to access the HTTP API:后面一行)这里 'bot' 三个字母不可少。创建 bot 后,需要先在 telegram 中与 BOT 进行对话(随便发个消息),然后才可用 API 发送消息。YYYYYY 是 telegram 用户的数字 ID。与机器人@userinfobot 对话可获得。
  2. 添加一个离线报警

    • 名称:离线通知
    • 规则:[{"Type":"offline","Duration":10}]
    • 启用:√
  3. 添加一个监控 CPU 持续 10s 超过 50% 内存持续 20s 占用低于 20% 的报警

    • 名称:CPU+内存
    • 规则:[{"Type":"cpu","Min":0,"Max":50,"Duration":10},{"Type":"memory","Min":20,"Max":0,"Duration":20}]
    • 启用:√

报警规则说明

  • Type
    • cpu、memory、swap、disk:Min/Max 数值为占用百分比
    • net_in_speed(入站网速)、net_out_speed(出站网速)、net_all_speed(双向网速)、transfer_in(入站流量)、transfer_out(出站流量)、transfer_all(双向流量):Min/Max 数值为字节(1kb=1024,1mb = 1024*1024)
    • offline:不支持 Min/Max 参数
  • Duration:持续秒数,监控比较简陋,取持续时间内的 70% 采样结果
  • Cover [{"Type":"offline","Duration":10, "Cover": 0, "Ignore":{"5": true}}]
    • 0 监控所有,通过 Ignore 忽略特定服务器
    • 1 忽略所有,通过 Ignore 监控特定服务器
  • Ignore: {"1": true, "2":false} 特定服务器,搭配 Cover 使用
服务监控:HTTP、SSL证书、ping、TCP 端口等。

进入 /monitor 页面点击新建监控即可,表单下面有相关说明。

自定义代码:改LOGO、改色调、加统计代码等。
  • 默认主题更改进度条颜色示例

    
    
  • DayNight 主题更改进度条颜色示例(来自 @hyt-allen-xu

    
    
  • 默认主题修改 LOGO、移除版权示例(来自 @iLay1678

    ">
    
    
    
  • DayNight 移除版权示例(来自 @hyt-allen-xu

    ">
    
    
  • hotaru 主题更改背景图片示例

    
    

常见问题

如何进行数据迁移、备份恢复?

数据储存在 /opt/nezha 文件夹中,迁移数据时打包这个文件夹,到新环境解压。然后执行一键脚本安装即可

如何使 OpenWrt/LEDE 自启动?来自 @艾斯德斯

首先在 release 下载对应的二进制解压 tar.gz 包后放置到 /root,然后 chmod +x /root/nezha-agent 赋予执行权限,然后创建 /etc/init.d/nezha-service

#!/bin/sh /etc/rc.common

START=99
USE_PROCD=1

start_service() {
	procd_open_instance
	procd_set_param command /root/nezha-agent -s 面板网址:接收端口 -p 唯一秘钥 -d
	procd_set_param respawn
	procd_close_instance
}

stop_service() {
    killall nezha-agent
}

restart() {
	stop
	sleep 2
	start
}

赋予执行权限 chmod +x /etc/init.d/nezha-service 然后启动服务 /etc/init.d/nezha-service enable && /etc/init.d/nezha-service start

首页服务器随机闪烁掉线?

执行 ntpdate 0.pool.ntp.org 同步一下面板部署所在的服务器的时间,ref: How do I use pool.ntp.org?

提示实时通道断开?

启用 HTTPS

使用宝塔反代或者上 CDN,建议 Agent 配置 跟 访问管理面板 使用不同的域名,这样管理面板使用的域名可以直接套 CDN,Agent 配置的域名是解析管理面板 IP 使用的,也方便后面管理面板迁移(如果你使用 IP,后面 IP 更换了,需要修改每个 agent,就麻烦了)

实时通道断开(WebSocket 反代)

使用反向代理时需要针对 /ws 路径的 WebSocket 进行特别配置以支持实时更新服务器状态。

  • Nginx(宝塔):在你的 nginx 配置文件中加入以下代码

    server{
    
        #原有的一些配置
        #server_name blablabla...
    
        location /ws {
            proxy_pass http://ip:站点访问端口;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header Host $host;
        }
    
        #其他的 location blablabla...
    }
  • CaddyServer v1(v2 无需特别配置)

    proxy /ws http://ip:8008 {
        websocket
    }
    

社区文章

Owner
𝕴 𝖌𝖆𝖎𝖓𝖊𝖉 𝖐𝖓𝖔𝖜𝖑𝖊𝖉𝖌𝖊 𝖊𝖛𝖊𝖗𝖞𝖜𝖍𝖊𝖗𝖊
null
Comments
  • feat: 添加更多的占位符以支持基于服务器状态指标构造自定义的HTTP请求

    feat: 添加更多的占位符以支持基于服务器状态指标构造自定义的HTTP请求

    为避免循环引用问题 额外构造一个NotificationServerBundle对象用于绑定当前通知对象与触发该通知的Server对象

    在调用SendNotification方法时 如果在字符串起始位置存在 $ServerID$标识符(如 $1$ 表示ID为1的Server) SendNotification方法将自动解析ServerID并构造NotificationServerBundle对象

    Send方法的replaceParamsInString函数现在会额外判断NotificationServerBundle对象中Server对象是否存在 并对各占位符进行Server对象状态指标的替换

    • [X] 基础功能
    • [x] 添加占位符
    • [x] 单元测试修改
  • 支持直接使用sc创建windows服务,不依赖nssm

    支持直接使用sc创建windows服务,不依赖nssm

    把提交清理干净。

    start新增recover stop的时候也没有哪个Goroutine能关闭的

    sc Create "nezha-agent" binPath= "D:\git\nezha\agent.exe -s 114.230.160.114:5555 -p e86903818636756455"
    
  • Actions推送到阿里云上海仓库 && 安装脚本修改

    Actions推送到阿里云上海仓库 && 安装脚本修改

    Actions推送到阿里云上海仓库 && 安装脚本修改 注意:

    • 最好是阿里云上海,Github的Action运行环境是美国Azure,走上海联通去阿里云上海推送很快,换区域需要修改,push上去大概10M
    • 命名空间和名称均已经写死
    • secrets.ALI_PAT和secrets.ALI_USER需要自行设置
    • jsdelivr的缓存刷新提交后大概需要15分钟才会在网宿的边缘节点生效
    • 缓存刷新那边处理了小写是因为我用户名是大写的 方便测试干脆一起处理下小写
    • 国内安装源会从阿里云上海拉取镜像
  • fix: 部分环境下启动时间锁定在1970年的问题

    fix: 部分环境下启动时间锁定在1970年的问题

    常规状态汇报时使用缓存的bootTime 但是如果这个缓存的bootTime不为0 (部分环境存在系统启动时间错误的问题,需要等待网络时间同步服务更新正确的时间) 那么每10分钟的系统信息更新不会更新这个缓存

    就导致虽然第10分钟那一次汇报会给面板上报正确的时间 但是下一次常规汇报又回回到错误的时间

    每10分钟进行一次的unix时间戳转换与boottime读取并不会占用过多资源。 因此本pr将不再判断bootTime不为0,总是向缓存写入最新的数据

  • 加强了中国大陆安装时候的稳定性和安装速度

    加强了中国大陆安装时候的稳定性和安装速度

    • 加强了中国大陆安装时候的稳定性和安装速度
    • 将raw.sevencdn.com替换为cdn.jsdelivr.net
    • 由于FastGit不支持对Release中非源码的加速下载,更换为DaoCloud提供的镜像
    • 将中国大陆的Docker安装脚本更换为DaoCloud提供的镜像安装脚本,同时指定阿里源为Docker源(对Centos无效)
    • 增加了对中国大陆安装IP的判断
    • 修改了README中对镜像安装脚本的介绍
  • 支持直接使用sc创建windows服务,不依赖nssm

    支持直接使用sc创建windows服务,不依赖nssm

    本来想搞win7,server2008R2安装脚本,但是wget不好解决。所以现在先这样简化win7,server2008R2的安装。 示例:

    #注意路径不能有空格,有空格的话需要转义
    sc Create "nezha-agent" binPath= "D:\git\nezha\agent.exe -s 114.230.160.114:5555 -p e86903818636756455"
    
  • feat: 通知方式分组 支持将不同的报警|监控|计划任务的通知 发送到指定的通知分组

    feat: 通知方式分组 支持将不同的报警|监控|计划任务的通知 发送到指定的通知分组

    增加为通知方式设置分组的功能 为各项 报警|监控|计划任务 设置不同的通知方式分组 事件发生时将通过其对应的通知方式分组发送消息

    为了兼容之前的版本 后端运行初始化过程中会将所有为指定通知组的相关对象指定至默认通知组default 在前端编辑相关对象时 会判断是否添加了通知组 未添加则默认指定为default

    • [x] 为通知方式提供分组功能
    • [x] 为报警增加通知分组
    • [x] 为计划任务增加通知分组
    • [x] 为服务监控增加通知分组
    • [x] 前端修改
    • [x] 检查前向兼容性
    • [x] 功能测试

    工作完成

  • feat: 通过传递客户端Cookie的方式使web终端功能兼容被Cloudflare Access保护的面板

    feat: 通过传递客户端Cookie的方式使web终端功能兼容被Cloudflare Access保护的面板

    由于Web终端功能需要Agent主动连接用户浏览器传递的Host 在当前域名被Cloudflare Access保护的情况下 Agent将无法正常连接到面板websocket 因此面板将主动从用户的浏览器request中提取 CF_Authorization Cookie 并传递给Agent Agent在连接时使用该Cookie绕过Cloudflare Access认证

    需要重新编译dashboard与agent使得该功能生效

  • 修复管理后台页面新添加CoverIgnoreAll类型服务需要重启docker镜像的问题.

    修复管理后台页面新添加CoverIgnoreAll类型服务需要重启docker镜像的问题.

    由于后台管理页面提交新的服务时,初始化Monitor没有给SkipServers赋值,而Monitor的AfterFind仅在数据库做查询动作时才更新,而该动作仅在整个程序初始化才会做查询动作,导致新增服务的SkipSevers一直为nil. https://github.com/naiba/nezha/blob/3144620a1599fc33a9b05f94c61b5c9e329ca696/cmd/dashboard/controller/member_api.go#L225-L259

    而到了执行任务时,由于task.SkipServers实际为nil,导致在MonitorCoverIgnoreAll时进入了条件语句,跳出循环,导致没有执行任务。 https://github.com/naiba/nezha/blob/3144620a1599fc33a9b05f94c61b5c9e329ca696/cmd/dashboard/rpc/rpc.go#L47-L51

  • 添加统计周期单位cycle_unit

    添加统计周期单位cycle_unit

    月流量报警

    • type
      • transfer_in_cycle 周期内的入站流量
      • transfer_out_cycle 周期内的出站流量
      • transfer_all_cycle 周期内双向流量和
    • cycle_start 统计周期开始日期(可以是你机器计费周期的开始日期),RFC3339时间格式,例如北京时间为2022-01-11T08:00:00.00+08:00
    • cycle_interval 每隔多少个周期单位(例如,周期单位为天,该值为7,则代表每隔7天统计一次)
    • cycle_unit 统计周期单位,默认hour,可选(hour, day, week, month, year)
    • min/max、cover、ignore 参考基本规则配置
    • 示例: ID 为 3 的机器(ignore 里面定义)的每月 15 号计费的出站月流量 1T 报警 [{"type":"transfer_out_cycle","max":1000000000000,"cycle_start":"2021-07-15T08:00:00+08:00","cycle_interval":1,"cycle_unit":"month","cover":1,"ignore":{"3":true}}]
    • 7QKaUx.md.png
  • :sparkles: 反向代理 gRPC 端口(支持 Cloudflare CDN)

    :sparkles: 反向代理 gRPC 端口(支持 Cloudflare CDN)

    您好,前些天我提供了反代 gRPC 的方法。但是后来发现因为 Nginx 或者 Cloudflare 的一些限制。如果面板和服务器的 ServerStream 连接长时间没有数据传输,Nginx 或者 Cloudflare 会断开连接,从而导致 Agent 监控端与面板服务器的 gRPC 连接频繁断开重连,导致面板内存占用一直增高。我做了一些修改,面板每隔一段时间(目前设置的60秒)会向所有服务器发送一次数据来保持连接不被断开,经过测试目前没有出现 Nginx 或者 Cloudflare 超时时间限制导致的重连问题了。我也对前端和脚本做了一些修改,以方便使用反代 gRPC 时生成一键安装命令安装 Agent 监控端。

Go net/http configurable handler to handle CORS requests

Go CORS handler CORS is a net/http handler implementing Cross Origin Resource Sharing W3 specification in Golang. Getting Started After installing Go

Jan 7, 2023
Go net/http handler to transparently manage posted JSON

Go JSON handler FormJSON is a net/http handler implementing content negotiation for posted data in order to transparently expose posted JSON as if it

Sep 27, 2022
Fault injection library in Go using standard http middleware

Fault The fault package provides go http middleware that makes it easy to inject faults into your service. Use the fault package to reject incoming re

Dec 25, 2022
Go (golang) library for creating and consuming HTTP Server-Timing headers
Go (golang) library for creating and consuming HTTP Server-Timing headers

HTTP Server-Timing for Go This is a library including middleware for using HTTP Server-Timing with Go. This header allows a server to send timing info

Dec 8, 2022
Simple middleware to rate-limit HTTP requests.

Tollbooth This is a generic middleware to rate-limit HTTP requests. NOTE 1: This library is considered finished. NOTE 2: Major version changes are bac

Jan 4, 2023
Restish is a CLI for interacting with REST-ish HTTP APIs with some nice features built-in
Restish is a CLI for interacting with REST-ish HTTP APIs with some nice features built-in

Restish is a CLI for interacting with REST-ish HTTP APIs with some nice features built-in, like always having the latest API resources, fields, and operations available when they go live on the API without needing to install or update anything.

Jan 5, 2023
Ping monitoring engine used in https://ping.gg

Disclaimer: If you are new to Go this is not a good place to learn best practices, the code is not very idiomatic and there's probably a few bad ideas

Dec 22, 2022
C-ping is a very simple and small ping tool that sends ICMP Echo datagram to a host.

C-ping is a very simple and small ping tool that sends ICMP Echo datagram to a host.

Aug 9, 2022
ping 和 http get 请求探测 适配 nightingale

n9e-probe 功能 ping 和 http get 请求探测 适配 nightingale 指标 ping metric 说明 ping.latency ping 请求的延迟,单位是毫秒。-1 表示 ping 不通 tag 说明 ip 探测的目标 ip region 如果配置了,则插入 reg

Sep 27, 2022
Basic repository with HTTP ping api and db setup

Simple API Simple REST API with database (postgres) integration HighLevel Agenda Integrating with postgres (few concepts) Live code walkthrough Detail

Jan 27, 2022
TcpRoute , TCP 层的路由器。对于 TCP 连接自动从多个线路(电信、联通、移动)、多个域名解析结果中选择最优线路。

TcpRoute2 TcpRoute , TCP 层的路由器。对于 TCP 连接自动从多个线路(允许任意嵌套)、多个域名解析结果中选择最优线路。 TcpRoute 使用激进的选路策略,对 DNS 解析获得的多个IP同时尝试连接,同时使用多个线路进行连接,最终使用最快建立的连接。支持 TcpRoute

Dec 27, 2022
Multiplexer over TCP. Useful if target server only allows you to create limited tcp connections concurrently.

tcp-multiplexer Use it in front of target server and let your client programs connect it, if target server only allows you to create limited tcp conne

May 27, 2021
TCP output for beats to send events over TCP socket.

beats-tcp-output How To Use Clone this project to elastic/beats/libbeat/output/ Modify elastic/beats/libbeat/publisher/includes/includes.go : // add i

Aug 25, 2022
Tcp chat go - Create tcp chat in golang

TCP chat in GO libs Go net package and goroutines and channels tcp tcp or transm

Feb 5, 2022
pong is not ping. pong is CLI game.
pong is not ping.   pong is CLI game.

pong-command Pong-command is a CLI game. POng is Not pinG. How to use. 1. Download Win/Mac OSX/Linux binary Download here. Windows,MacOSX,Linux,BSD bi

Dec 27, 2022
🚥 Yet another pinger: A high-performance ICMP ping implementation build on top of BPF technology.

yap Yet-Another-Pinger: A high-performance ICMP ping implementation build on top of BPF technology. yap uses the gopacket library to receive and handl

Nov 9, 2022
综合性网络质量(PING)检测工具,支持正/反向PING绘图、互PING拓扑绘图与报警、全国PING延迟地图与在线检测工具等功能
综合性网络质量(PING)检测工具,支持正/反向PING绘图、互PING拓扑绘图与报警、全国PING延迟地图与在线检测工具等功能

SmartPing | 开源、高效、便捷的网络质量监控神器 一个综合性网络质量(PING)检测工具,支持正/反向PING绘图、互PING拓扑绘图与报警、全国PING延迟地图与在线检测工具等功能 -- Browse website -- 功能 正向PING,反向Ping绘图 互PING间机器的状态拓扑

Jan 1, 2023
DNS Ping: to check packet loss and latency issues with DNS servers

DNSping DNS Ping checks packet loss and latency issues with DNS servers Installation If you have golang, easiest install is go get -u fortio.org/dnspi

Nov 18, 2022
[FORK] ICMP Ping library for Go

forked from go-ping/ping go get -u github.com/gandaldf/ping go-ping A simple but powerful ICMP echo (ping) library for Go, inspired by go-fastping. He

Oct 21, 2021