From 3387dddd1b6e37ce4bdfea57edf059a72d085dcd Mon Sep 17 00:00:00 2001 From: zhouruixi Date: Wed, 8 Mar 2023 10:34:44 +0800 Subject: [PATCH 1/3] =?UTF-8?q?Add=20Wechat=20Work=20Group=20bot=20notific?= =?UTF-8?q?ation=20Add=20the=20example=20of=20Wechat=20Wrok=20Group=20bot?= =?UTF-8?q?=20notification=20=E5=A2=9E=E5=8A=A0=E4=BC=81=E5=BE=AE=E7=BE=A4?= =?UTF-8?q?=E8=81=8A=E6=9C=BA=E5=99=A8=E4=BA=BA=E9=80=9A=E7=9F=A5=E6=A0=B7?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en_US/guide/notifications.md | 68 +++++++++++++++++++++++++++---- docs/guide/notifications.md | 65 +++++++++++++++++++++++++---- 2 files changed, 117 insertions(+), 16 deletions(-) diff --git a/docs/en_US/guide/notifications.md b/docs/en_US/guide/notifications.md index b43f04da..fcc7e18b 100644 --- a/docs/en_US/guide/notifications.md +++ b/docs/en_US/guide/notifications.md @@ -17,7 +17,7 @@ Refer to the example below, it is very flexible. - Request method: GET - Request Type: Default - Body: null - + - Name: Bark - URL:/push - Request method: POST @@ -34,7 +34,6 @@ Refer to the example below, it is very flexible. - Notes for this method:The XXXXXX in botXXXXXX is the token provided when you follow the official @Botfather in Telegram and enter /newbot to create a new bot. (In the line after _Use this token to access the HTTP API_). The 'bot' are essential. After creating a bot, you need to talk to the BOT in Telegram (send a random message) before you can send a message by using API. YYYYYY is Telegram user's ID, you can get it by talking to the bot @userinfobot. - **Email notification example - Outlook, contributed by [@Cantoblanco](https://github.com/cantoblanco)** - - Name: MS Mail Notification - URL:https://graph.microsoft.com/v1.0/me/microsoft.graph.sendMail - Request method: POST @@ -62,7 +61,58 @@ Refer to the example below, it is very flexible. ``` - Notes for this method: This method requires calling Microsoft Graph V1.0, you need to go to Microsoft Graph and create your own application, give `Mail.Send` permission and get the Token, or you can go [Microsoft Graph Explorer](https://developer.microsoft.com/en-us/graph/graph-explorer) directly to give permission and get the Token, just replace the Token in the Header with the actual Token. - + + - **Wechat Work Group bot Example, contributed by [@ChowRex](https://github.com/ChowRex)** + + Support placeholders: + + ```json + { + "content": "#NEZHA#", + "ServerName": "#SERVER.NAME#", + "ServerIP": "#SERVER.IP#", + "ServerIPV4": "#SERVER.IPV4#", + "ServerIPV6": "#SERVER.IPV6#", + "CPU": "#SERVER.CPU#", + "MEM": "#SERVER.MEM#", + "SWAP": "#SERVER.SWAP#", + "DISK": "#SERVER.DISK#", + "NetInSpeed": "#SERVER.NETINSPEED#", + "NetOutSpeed": "#SERVER.NETOUTSPEED#", + "TransferIn": "#SERVER.TRANSFERIN#", + "TranferOut": "#SERVER.TRANSFEROUT#", + "Load1": "#SERVER.LOAD1#", + "Load5": "#SERVER.LOAD5#", + "Load15": "#SERVER.LOAD15#", + "TCP_CONN_COUNT": "#SERVER.TCPCONNCOUNT", # Invalid + "UDP_CONN_COUNT": "#SERVER.UDPCONNCOUNT", # Invalid + } + ``` + + > Sorry, this document is **NOT** available in English. + > + > [群机器人配置说明 - 文档 - 企业微信开发者中心](https://developer.work.weixin.qq.com/document/path/91770#markdown%E7%B1%BB%E5%9E%8B) + + - Name:WechatWork Group bot notification + + - URL:https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_BOT_KEY + + - Request method: POST + + - Request type: JSON + + - Body: + + ```json + { + "msgtype": "markdown", + "markdown": { + "content": "# Nezha Notification\n\n\"#NEZHA#\"\n\n> ServerName: \"#SERVER.NAME#\"\n> IP: \"#SERVER.IP#\"\n> IPv4: \"#SERVER.IPV4#\"\n> IPv6: \"#SERVER.IPV6#\"\n> CPU: \"#SERVER.CPU#\"\n> Memory: \"#SERVER.MEM#\"\n> SWAP: \"#SERVER.SWAP#\"\n> Storage: \"#SERVER.DISK#\"\n> Real-time Upload: \"#SERVER.NETINSPEED#\"\n> Real-time Download: \"#SERVER.NETOUTSPEED#\"\n> Total Upload: \"#SERVER.TRANSFERIN#\"\n> Total Download: \"#SERVER.TRANSFEROUT#\"\n> 1m Load: \"#SERVER.LOAD1#\"\n> 5m Load: \"#SERVER.LOAD5#\"\n> 15m Load: \"#SERVER.LOAD15#\"\n> TCP Connections: \"#SERVER.TCPCONNCOUNT\"\n> UDP Connections: \"#SERVER.UDPCONNCOUNT\"\n\n" + } + } + ``` + + Delete relevant content information as needed

@@ -90,21 +140,21 @@ Refer to the example below, it is very flexible. - ignore: Select to ignore specific servers, use with `cover` with server id and boolean, e.g.: `{"1": true, "2":false}` **Complete examples:** - + >>Add an offline notification > > - Name: Offline notification > - Rules: `[{"Type":"offline","Duration":10}]` > - Enable: √ - - + + >>Add an notification when the CPU exceeds 50% for 10s **but** the memory usage is below 20% for 20s > > - Name: CPU and RAM > - Rules: `[{"Type":"cpu","Min":0,"Max":50,"Duration":10},{"Type":"memory","Min":20,"Max":0,"Duration":20}]` > - Enable: √ - + >>Send specific server notifications to specific notification groups > >Case: @@ -127,7 +177,7 @@ Refer to the example below, it is very flexible. > - Enable: √ **Using these rules flexibly will help you to make full use of the notification function** - +
### Special: Any-cycle transfer notification @@ -148,7 +198,7 @@ Can be used as monthly transfer notificatin >>The servers with ID 3 and 4 (defined in the `ignore`) are counted on the 1st of each month, and a notification is triggered when the monthly outbound transfer reaches 1TB during the cycle. > > `[{"type":"transfer_out_cycle","max":1099511627776,"cycle_start":"2022-01-01T00:00:00+08:00","cycle_interval":1,"cycle_unit":"month","cover":1,"ignore":{"3":true,"4":true}}]` - + ## Description of mode of triggering notification - Always triggered: A notification is triggered each time the status reported by the Agent matches the rules of the notification - Triggered only once: only one notification is triggered when the state changes, such as changing from normal state to abnormal state or abnormal state back to normal state diff --git a/docs/guide/notifications.md b/docs/guide/notifications.md index eb51d5da..ab118a2d 100644 --- a/docs/guide/notifications.md +++ b/docs/guide/notifications.md @@ -49,7 +49,7 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。 - 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 对话可获得。 - **邮件通知示例 - SendCloud 贡献者:[@白歌](https://github.com/cantoblanco)** - **注意:SendCloud 有每日免费发送邮件限额限制,这里仅作示例,你可以选择付费服务或其他类似的免费服务,使用方法类似。** + **注意:SendCloud 有每日免费发送邮件限额限制,这里仅作示例,你可以选择付费服务或其他类似的免费服务,使用方法类似。** - 名称:邮件告警 - URL:https://api.sendcloud.net/apiv2/mail/send?apiUser=<替换APIUSER>apiKey=<替换APIKEY>&from=<自定义发件邮箱>&fromName=Nezha&to=<自定义收件邮箱>&subject=Nezha-Notification&html=#NEZHA# @@ -57,8 +57,59 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。 - 请求类型: JSON - Header: 留空 - Body: 留空 - - URL 参数获取说明:此方式需提前在 [SendCloud](https://www.sendcloud.net/) 注册账号,创建发件邮箱,然后在[这里](https://www.sendcloud.net/sendSetting/apiuser)获取 APIUSER 和 APIKEY,替换 URL 中的 <替换APIUSER> 和 <替换APIKEY> 为自己的 APIUSER 和 APIKEY,替换 URL 中的 <自定义发件邮箱> 和 <自定义收件邮箱> 为自己的发件邮箱和收件邮箱。 + - URL 参数获取说明:此方式需提前在 [SendCloud](https://www.sendcloud.net/) 注册账号,创建发件邮箱,然后在[这里](https://www.sendcloud.net/sendSetting/apiuser)获取 APIUSER 和 APIKEY,替换 URL 中的 <替换APIUSER> 和 <替换APIKEY> 为自己的 APIUSER 和 APIKEY,替换 URL 中的 <自定义发件邮箱> 和 <自定义收件邮箱> 为自己的发件邮箱和收件邮箱。 + + - **企业微信 群机器人 示例 贡献者:[@ChowRex](https://github.com/ChowRex)** + + 支持的占位符一览 + + ```json + { + "content": "#NEZHA#", + "ServerName": "#SERVER.NAME#", + "ServerIP": "#SERVER.IP#", + "ServerIPV4": "#SERVER.IPV4#", + "ServerIPV6": "#SERVER.IPV6#", + "CPU": "#SERVER.CPU#", + "MEM": "#SERVER.MEM#", + "SWAP": "#SERVER.SWAP#", + "DISK": "#SERVER.DISK#", + "NetInSpeed": "#SERVER.NETINSPEED#", + "NetOutSpeed": "#SERVER.NETOUTSPEED#", + "TransferIn": "#SERVER.TRANSFERIN#", + "TranferOut": "#SERVER.TRANSFEROUT#", + "Load1": "#SERVER.LOAD1#", + "Load5": "#SERVER.LOAD5#", + "Load15": "#SERVER.LOAD15#", + "TCP_CONN_COUNT": "#SERVER.TCPCONNCOUNT", # 无效 + "UDP_CONN_COUNT": "#SERVER.UDPCONNCOUNT", # 无效 + } + ``` + + > [群机器人配置说明 - 文档 - 企业微信开发者中心](https://developer.work.weixin.qq.com/document/path/91770#markdown%E7%B1%BB%E5%9E%8B) + + - 名称:企业微信群机器人 + + - URL:https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_BOT_KEY + + - 请求方式: POST + + - 请求类型: JSON + + - Body: + + ```json + { + "msgtype": "markdown", + "markdown": { + "content": "# 哪吒通知消息\n\n\"#NEZHA#\"\n\n> 名称: \"#SERVER.NAME#\"\n> IP: \"#SERVER.IP#\"\n> IPv4: \"#SERVER.IPV4#\"\n> IPv6: \"#SERVER.IPV6#\"\n> CPU: \"#SERVER.CPU#\"\n> 内存: \"#SERVER.MEM#\"\n> 交换分区: \"#SERVER.SWAP#\"\n> 存储: \"#SERVER.DISK#\"\n> 实时上传速度: \"#SERVER.NETINSPEED#\"\n> 实时下载速度: \"#SERVER.NETOUTSPEED#\"\n> 总上传: \"#SERVER.TRANSFERIN#\"\n> 总下载: \"#SERVER.TRANSFEROUT#\"\n> 1分钟内负载: \"#SERVER.LOAD1#\"\n> 5分钟内负载: \"#SERVER.LOAD5#\"\n> 15分钟内负载: \"#SERVER.LOAD15#\"\n> TCP连接数: \"#SERVER.TCPCONNCOUNT\"\n> UDP连接数: \"#SERVER.UDPCONNCOUNT\"\n\n" + } + } + ``` + + 根据需求删减相关内容信息即可 +

@@ -86,21 +137,21 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。 - ignore: 选择忽略特定服务器,搭配 `cover` 使用,内容为服务器 id 和布尔值,例如:`{"1": true, "2":false}` **完整示例:** - + >>添加一个离线报警 > > - 名称:离线通知 > - 规则:`[{"Type":"offline","Duration":10}]` > - 启用:√ - - + + >>添加一个监控 CPU 持续 10s 超过 50% **且** 内存持续 20s 占用低于 20% 的报警 > > - 名称:CPU+内存 > - 规则:`[{"Type":"cpu","Min":0,"Max":50,"Duration":10},{"Type":"memory","Min":20,"Max":0,"Duration":20}]` > - 启用:√ - + >>将特定的服务器通知发送到特定的通知分组 > @@ -124,7 +175,7 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。 > - 启用:√ **灵活使用参数可以让你的通知功能被充分使用** - +
### 特殊:任意周期流量报警 From 6d206b7e03af2637de928c27dbf382546d871281 Mon Sep 17 00:00:00 2001 From: ChowRex Date: Wed, 8 Mar 2023 10:40:23 +0800 Subject: [PATCH 2/3] Add Wechat Work Group bot picture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加微信群机器人通知效果 --- docs/guide/notifications.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/guide/notifications.md b/docs/guide/notifications.md index ab118a2d..9040837b 100644 --- a/docs/guide/notifications.md +++ b/docs/guide/notifications.md @@ -109,6 +109,8 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。 ``` 根据需求删减相关内容信息即可 + + ![通知效果](https://user-images.githubusercontent.com/30169860/223605620-eac53ee6-09f9-4583-94fa-9b0cdedba81c.png)
From c23649d848a4934d3247f57186a47c3216c3fcdc Mon Sep 17 00:00:00 2001 From: ChowRex Date: Wed, 8 Mar 2023 10:41:24 +0800 Subject: [PATCH 3/3] Add Wechat Work Group bot picture Add for English version --- docs/en_US/guide/notifications.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/en_US/guide/notifications.md b/docs/en_US/guide/notifications.md index fcc7e18b..f0c14c9d 100644 --- a/docs/en_US/guide/notifications.md +++ b/docs/en_US/guide/notifications.md @@ -113,6 +113,9 @@ Refer to the example below, it is very flexible. ``` Delete relevant content information as needed + + ![Notice Picture](https://user-images.githubusercontent.com/30169860/223605886-b7736825-24b8-4b6c-8bc9-96ac388599ef.png) +