55 lines
33 KiB
HTML
55 lines
33 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||
<title>灵活的通知方式 | 哪吒监控</title>
|
||
<meta name="description" content="哪吒监控是一个轻量化的运维工具">
|
||
<link rel="stylesheet" href="/assets/style.0b9f658b.css">
|
||
<link rel="modulepreload" href="/assets/chunks/AlgoliaSearchBox.98396bc7.js">
|
||
<link rel="modulepreload" href="/assets/app.3817bf4e.js">
|
||
<link rel="modulepreload" href="/assets/guide_notifications.md.abde0a78.lean.js">
|
||
|
||
<meta name="twitter:title" content="灵活的通知方式 | 哪吒监控">
|
||
<meta property="og:title" content="灵活的通知方式 | 哪吒监控">
|
||
</head>
|
||
<body>
|
||
<div id="app"><!--[--><div class="theme"><header class="nav-bar" data-v-675d8756><div class="sidebar-button" data-v-675d8756><svg class="icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z" class></path></svg></div><a class="nav-bar-title" href="/" aria-label="哪吒监控, back to home" data-v-675d8756 data-v-cc01ef16><!----> 哪吒监控</a><div class="flex-grow" data-v-675d8756></div><div class="nav" data-v-675d8756><nav class="nav-links" data-v-675d8756 data-v-eab3edfe><!--[--><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item active" href="/" data-v-b8818f8c>使用指南 <!----></a></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item" href="/case/index" data-v-b8818f8c>社区项目 <!----></a></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item" href="/developer/index" data-v-b8818f8c>开发手册 <!----></a></div></div><!--]--><div class="item" data-v-eab3edfe><div class="nav-dropdown-link" data-v-eab3edfe data-v-56bf3a3f><button class="button" data-v-56bf3a3f><span class="button-text" data-v-56bf3a3f>Languages</span><span class="right button-arrow" data-v-56bf3a3f></span></button><ul class="dialog" data-v-56bf3a3f><!--[--><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item active" href="/guide/notifications.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>简体中文</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item" href="/en_US/guide/notifications.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>English</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><!--]--></ul></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item isExternal" href="https://github.com/nezhahq/nezhahq.github.io" target="_blank" rel="noopener noreferrer" data-v-b8818f8c>GitHub <svg class="icon outbound" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15" data-v-b8818f8c><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div></div></nav></div><!--[--><!--[--><div class="algolia-search-box" id="docsearch"></div><!--]--><!--]--></header><aside class="sidebar" data-v-83e92a68><nav class="nav-links nav" data-v-83e92a68 data-v-eab3edfe><!--[--><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item active" href="/" data-v-b8818f8c>使用指南 <!----></a></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item" href="/case/index" data-v-b8818f8c>社区项目 <!----></a></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item" href="/developer/index" data-v-b8818f8c>开发手册 <!----></a></div></div><!--]--><div class="item" data-v-eab3edfe><div class="nav-dropdown-link" data-v-eab3edfe data-v-56bf3a3f><button class="button" data-v-56bf3a3f><span class="button-text" data-v-56bf3a3f>Languages</span><span class="right button-arrow" data-v-56bf3a3f></span></button><ul class="dialog" data-v-56bf3a3f><!--[--><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item active" href="/guide/notifications.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>简体中文</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item" href="/en_US/guide/notifications.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>English</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><!--]--></ul></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item isExternal" href="https://github.com/nezhahq/nezhahq.github.io" target="_blank" rel="noopener noreferrer" data-v-b8818f8c>GitHub <svg class="icon outbound" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15" data-v-b8818f8c><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div></div></nav><!--[--><!--]--><ul class="sidebar-links" data-v-83e92a68><!--[--><li class="sidebar-link"><p class="sidebar-link-item">安装手册</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/dashboard">安装 Dashboard</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/agent">安装 Agent</a><!----></li></ul></li><li class="sidebar-link"><p class="sidebar-link-item">管理面板配置</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/servers">主机</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/services">服务</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/tasks">定时任务</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item active" href="/guide/notifications">报警通知</a><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="#灵活的通知方式">灵活的通知方式</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="#报警规则说明">报警规则说明</a><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="#基本规则">基本规则</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="#特殊:任意周期流量报警">特殊:任意周期流量报警</a><!----></li></ul></li><li class="sidebar-link"><a class="sidebar-link-item" href="#通知触发模式说明">通知触发模式说明</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="#设置报警时执行任务">设置报警时执行任务</a><!----></li></ul></li><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/settings">设置</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/api">API</a><!----></li></ul></li><li class="sidebar-link"><p class="sidebar-link-item">常见问题</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/q1">TG api 被墙</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/q2">Agent 无法启动/上线 查看日志并进行排错的步骤</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/q3">反向代理 gRPC 端口的步骤</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/q4">实时通道断开/在线终端连接失败</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/q5">进行数据迁移、备份和恢复的步骤</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/q6">设置每月重置流量统计的步骤</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/q7">自定义 Agent 监控项目的步骤</a><!----></li></ul></li><li class="sidebar-link"><p class="sidebar-link-item">排障指南</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/dashboardq">Dashboard 相关</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/agentq">Agent 相关</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/guide/loginq">登录相关</a><!----></li></ul></li><!--]--></ul><!--[--><!--]--></aside><div class="sidebar-mask"></div><main class="page" data-v-7eddb2c4><div class="container" data-v-7eddb2c4><!--[--><!--]--><div style="position:relative;" class="content" data-v-7eddb2c4><div><p>哪吒监控支持对服务器的负载、CPU、内存、硬盘、流量、月流量、进程数、连接数进行监控,并在其中某项达到用户设定值时发送报警通知 <br><br></p><h2 id="灵活的通知方式" tabindex="-1">灵活的通知方式 <a class="header-anchor" href="#灵活的通知方式" aria-hidden="true">#</a></h2><p><code>#NEZHA#</code> 是面板消息占位符,面板触发通知时会自动用实际消息替换占位符</p><p>Body 内容是<code>JSON</code> 格式的:<strong>当请求类型为 FORM 时</strong>,值为 <code>key:value</code> 的形式,<code>value</code> 里面可放置占位符,通知时会自动替换。<strong>当请求类型为 JSON 时</strong> 只会简单进行字符串替换后直接提交到<code>URL</code>。</p><p>URL 里面也可放置占位符,请求时会进行简单的字符串替换。</p><p>你可以参考以下的通知方式示例,也可以根据自己的需求灵活设置推送方式</p><ul><li><p><strong>Bark 示例</strong></p><ul><li>名称:Bark</li><li>URL 组成: 第一个部分是 key,之后有三个匹配 /:key/:body or /:key/:title/:body or /:key/:category/:title/:body</li><li>请求方式: GET</li><li>请求类型: 默认</li><li>Body: 空</li><li>名称:Bark</li><li>URL 组成: /push</li><li>请求方式: POST</li><li>请求类型: form</li><li>Body: <code>{"title": "#SERVER.NAME#","device_key":"xxxxxxxxx","body":"#NEZHA#","icon":"https://xxxxxxxx/nz.png"}</code></li></ul></li><li><p><strong>Server 酱示例</strong></p><ul><li>名称:Server 酱</li><li>URL:<a href="https://sc.ftqq.com/SCUrandomkeys.send?title=%E5%93%AA%E5%90%92%E6%8A%A5%E8%AD%A6%E4%BF%A1%E6%81%AF&desp=#NEZHA#" target="_blank" rel="noopener noreferrer">https://sc.ftqq.com/SCUrandomkeys.send?title=哪吒报警信息&desp=#NEZHA#</a></li><li>请求方式: GET</li><li>请求类型: 默认</li><li>Body: 空</li></ul></li><li><p><strong>Server 酱进阶</strong></p><ul><li>名称:Server 酱</li><li>URL:<a href="https://sc.ftqq.com/SCUrandomkeys.send" target="_blank" rel="noopener noreferrer">https://sc.ftqq.com/SCUrandomkeys.send</a></li><li>请求方式: POST</li><li>请求类型: FORM</li><li>Body:</li></ul><div class="language-json"><pre><code><span class="token punctuation">{</span>
|
||
<span class="token property">"title"</span><span class="token operator">:</span> <span class="token string">"#SERVER.NAME#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"desp"</span><span class="token operator">:</span>"**#NEZHA#\n\n
|
||
平均负载<span class="token operator">:</span> \"#SERVER.LOAD1#\"<span class="token punctuation">,</span>\"#SERVER.LOAD5#\"<span class="token punctuation">,</span>\"#SERVER.LOAD15#\"\n\n
|
||
## <span class="token punctuation">[</span>点击访问面板<span class="token punctuation">]</span>(https<span class="token operator">:</span><span class="token comment">//你的面板域名)\n\n</span>
|
||
!<span class="token punctuation">[</span>logo<span class="token punctuation">]</span>(https<span class="token operator">:</span><span class="token comment">//raw.githubusercontent.com/naiba/nezha/master/resource/static/brand.svg)"</span>
|
||
<span class="token punctuation">}</span>
|
||
</code></pre></div><p><img src="https://github.com/iilemon/nezhahq.github.io/blob/main/docs/images/photo_2023-03-16_00-22-47a.jpg?raw=true" alt=""></p></li><li><p><strong>wxpusher 示例,需要关注你的应用</strong></p><ul><li>名称: wxpusher</li><li>URL:<a href="http://wxpusher.zjiecode.com/api/send/message" target="_blank" rel="noopener noreferrer">http://wxpusher.zjiecode.com/api/send/message</a></li><li>请求方式: POST</li><li>请求类型: JSON</li><li>Body: <code>{"appToken":"你的appToken","topicIds":[],"content":"#NEZHA#","contentType":"1","uids":["你的uid"]}</code></li></ul></li><li><p><strong>Telegram 示例 贡献者:<a href="https://github.com/haitau" target="_blank" rel="noopener noreferrer">@haitau</a></strong></p><ul><li>名称:telegram 机器人消息通知</li><li>URL:<a href="https://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&text=#NEZHA#" target="_blank" rel="noopener noreferrer">https://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&text=#NEZHA#</a></li><li>请求方式: GET</li><li>请求类型: 默认</li><li>Body: 空</li><li>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 对话可获得。</li></ul></li><li><p><strong>邮件通知示例 - SendCloud 贡献者:<a href="https://github.com/cantoblanco" target="_blank" rel="noopener noreferrer">@白歌</a></strong><br><strong>注意:SendCloud 有每日免费发送邮件限额限制,这里仅作示例,你可以选择付费服务或其他类似的免费服务,使用方法类似。</strong></p><ul><li>名称:邮件告警</li><li>URL:<a href="https://api.sendcloud.net/apiv2/mail/send?apiUser=" target="_blank" rel="noopener noreferrer">https://api.sendcloud.net/apiv2/mail/send?apiUser=</a><替换APIUSER>apiKey=<替换APIKEY>&from=<自定义发件邮箱>&fromName=Nezha&to=<自定义收件邮箱>&subject=Nezha-Notification&html=#NEZHA#</li><li>请求方式: POST</li><li>请求类型: JSON</li><li>Header: 留空</li><li>Body: 留空</li></ul><p>URL 参数获取说明:此方式需提前在 <a href="https://www.sendcloud.net/" target="_blank" rel="noopener noreferrer">SendCloud</a> 注册账号,创建发件邮箱,然后在<a href="https://www.sendcloud.net/sendSetting/apiuser" target="_blank" rel="noopener noreferrer">这里</a>获取 APIUSER 和 APIKEY,替换 URL 中的 <替换APIUSER> 和 <替换APIKEY> 为自己的 APIUSER 和 APIKEY,替换 URL 中的 <自定义发件邮箱> 和 <自定义收件邮箱> 为自己的发件邮箱和收件邮箱。</p></li><li><p><strong>企业微信 群机器人 示例 贡献者:<a href="https://github.com/ChowRex" target="_blank" rel="noopener noreferrer">@ChowRex</a></strong></p><p>支持的占位符一览</p><div class="language-json"><pre><code><span class="token punctuation">{</span>
|
||
<span class="token property">"content"</span><span class="token operator">:</span> <span class="token string">"#NEZHA#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"ServerName"</span><span class="token operator">:</span> <span class="token string">"#SERVER.NAME#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"ServerIP"</span><span class="token operator">:</span> <span class="token string">"#SERVER.IP#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"ServerIPV4"</span><span class="token operator">:</span> <span class="token string">"#SERVER.IPV4#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"ServerIPV6"</span><span class="token operator">:</span> <span class="token string">"#SERVER.IPV6#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"CPU"</span><span class="token operator">:</span> <span class="token string">"#SERVER.CPU#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"MEM"</span><span class="token operator">:</span> <span class="token string">"#SERVER.MEM#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"SWAP"</span><span class="token operator">:</span> <span class="token string">"#SERVER.SWAP#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"DISK"</span><span class="token operator">:</span> <span class="token string">"#SERVER.DISK#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"NetInSpeed"</span><span class="token operator">:</span> <span class="token string">"#SERVER.NETINSPEED#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"NetOutSpeed"</span><span class="token operator">:</span> <span class="token string">"#SERVER.NETOUTSPEED#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"TransferIn"</span><span class="token operator">:</span> <span class="token string">"#SERVER.TRANSFERIN#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"TranferOut"</span><span class="token operator">:</span> <span class="token string">"#SERVER.TRANSFEROUT#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"Load1"</span><span class="token operator">:</span> <span class="token string">"#SERVER.LOAD1#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"Load5"</span><span class="token operator">:</span> <span class="token string">"#SERVER.LOAD5#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"Load15"</span><span class="token operator">:</span> <span class="token string">"#SERVER.LOAD15#"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"TCP_CONN_COUNT"</span><span class="token operator">:</span> <span class="token string">"#SERVER.TCPCONNCOUNT"</span><span class="token punctuation">,</span> # 无效
|
||
<span class="token property">"UDP_CONN_COUNT"</span><span class="token operator">:</span> <span class="token string">"#SERVER.UDPCONNCOUNT"</span><span class="token punctuation">,</span> # 无效
|
||
<span class="token punctuation">}</span>
|
||
</code></pre></div><blockquote><p><a href="https://developer.work.weixin.qq.com/document/path/91770#markdown%E7%B1%BB%E5%9E%8B" target="_blank" rel="noopener noreferrer">群机器人配置说明 - 文档 - 企业微信开发者中心</a></p></blockquote><ul><li><p>名称:企业微信群机器人</p></li><li><p>URL:<a href="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_BOT_KEY" target="_blank" rel="noopener noreferrer">https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_BOT_KEY</a></p></li><li><p>请求方式: POST</p></li><li><p>请求类型: JSON</p></li><li><p>Body:</p><div class="language-json"><pre><code><span class="token punctuation">{</span>
|
||
<span class="token property">"msgtype"</span><span class="token operator">:</span> <span class="token string">"markdown"</span><span class="token punctuation">,</span>
|
||
<span class="token property">"markdown"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
|
||
<span class="token property">"content"</span><span class="token operator">:</span> <span class="token string">"# 哪吒通知消息\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"</span>
|
||
<span class="token punctuation">}</span>
|
||
<span class="token punctuation">}</span>
|
||
</code></pre></div><p>根据需求删减相关内容信息即可</p></li></ul><p><img src="https://user-images.githubusercontent.com/30169860/223605620-eac53ee6-09f9-4583-94fa-9b0cdedba81c.png" alt=""></p></li></ul><br><br><h2 id="报警规则说明" tabindex="-1">报警规则说明 <a class="header-anchor" href="#报警规则说明" aria-hidden="true">#</a></h2><h3 id="基本规则" tabindex="-1">基本规则 <a class="header-anchor" href="#基本规则" aria-hidden="true">#</a></h3><ul><li>type:可选取一个或多个类型,如在一个规则中选择了多个类型,需要<strong>同时满足</strong>所有选择的类型才会触发通知(可参考后面的示例) <ul><li><code>cpu</code>、<code>memory</code>、<code>swap</code>、<code>disk</code></li><li><code>net_in_speed</code> 入站网速、<code>net_out_speed</code> 出站网速、<code>net_all_speed</code> 双向网速、<code>transfer_in</code> 入站流量、<code>transfer_out</code> 出站流量、<code>transfer_all</code> 双向流量</li><li><code>offline</code> 离线监控</li><li><code>load1</code>、<code>load5</code>、<code>load15</code> 负载</li><li><code>process_count</code> 进程数 <em>目前取线程数占用资源太多,暂时不支持</em></li><li><code>tcp_conn_count</code>、<code>udp_conn_count</code> 连接数</li></ul></li><li>duration:持续数秒,数秒内采样记录 30% 以上触发阈值才会报警(防数据插针)</li><li>min 或 max: <ul><li>流量、网速类数值 为字节(1KB=1024B,1MB = 1024*1024B)</li><li>内存、硬盘、CPU 以占用百分比计数</li><li>离线监控无需设置此项</li></ul></li><li>cover: <ul><li><code>0</code> 监控所有,通过 <code>ignore</code> 忽略特定服务器</li><li><code>1</code> 忽略所有,通过 <code>ignore</code> 监控特定服务器<br> 例如:<code>[{"type":"offline","duration":10, "cover":0, "ignore":{"5": true}}]</code></li></ul></li><li>ignore: 选择忽略特定服务器,搭配 <code>cover</code> 使用,内容为服务器 id 和布尔值,例如:<code>{"1": true, "2":false}</code></li></ul><p><strong>完整示例:</strong></p><blockquote><blockquote><p>添加一个离线报警</p></blockquote><ul><li>名称:离线通知</li><li>规则:<code>[{"Type":"offline","Duration":10}]</code></li><li>启用:√</li></ul></blockquote><blockquote><blockquote><p>添加一个监控 CPU 持续 10s 超过 50% <strong>且</strong> 内存持续 20s 占用低于 20% 的报警</p></blockquote><ul><li>名称:CPU+内存</li><li>规则:<code>[{"Type":"cpu","Min":0,"Max":50,"Duration":10},{"Type":"memory","Min":20,"Max":0,"Duration":20}]</code></li><li>启用:√</li></ul></blockquote><blockquote><blockquote><p>将特定的服务器通知发送到特定的通知分组</p></blockquote><p>示例场景:<br> 你有 1、2、3、4 四台服务器和 A、B 两个不同的通知组<br> 1、2 这两台服务器掉线十分钟后给通知组 A 发送通知<br> 3、4 这两台服务器掉线十分钟后给通知组 B 发送通知</p><p>首先你需要先设置好 A、B 两个通知组,然后添加两条报警规则:</p><p><strong>规则一:</strong></p><ul><li>名称:1、2 离线,发送给通知组 A</li><li>规则:<code>[{"type":"offline","duration":600,"cover":1,"ignore":{"1":true,"2":true}}]</code></li><li>通知方式组: A</li><li>启用:√</li></ul><p><strong>规则二:</strong></p><ul><li>名称:3、4 离线,发送给通知组 B</li><li>规则:<code>[{"type":"offline","duration":600,"cover":1,"ignore":{"3":true,"4":true}}]</code></li><li>通知方式组: B</li><li>启用:√</li></ul></blockquote><p><strong>灵活使用参数可以让你的通知功能被充分使用</strong></p><br><h3 id="特殊:任意周期流量报警" tabindex="-1">特殊:任意周期流量报警 <a class="header-anchor" href="#特殊:任意周期流量报警" aria-hidden="true">#</a></h3><p>可以用作月流量报警</p><ul><li>type: <ul><li><code>transfer_in_cycle</code> 周期内的入站流量</li><li><code>transfer_out_cycle</code> 周期内的出站流量</li><li><code>transfer_all_cycle</code> 周期内双向流量和</li></ul></li><li>cycle_start: 统计周期开始日期(可以是你机器计费周期的开始日期),时间格式为RFC3339,例如北京时间为<code>2022-01-11T08:00:00.00+08:00</code></li><li>cycle_interval:每隔多少个周期单位(例如,周期单位为天,该值为 7,则代表每隔 7 天统计一次)</li><li>cycle_unit 统计周期单位,默认<code>hour</code>,可选(<code>hour</code>, <code>day</code>, <code>week</code>, <code>month</code>, <code>year</code>)</li><li>min/max、cover、ignore 参考基本规则配置</li></ul><blockquote><p>示例:</p><blockquote><p>ID 为 3 和 4 的服务器(ignore 里面定义),以每月 1 号为统计周期,周期内统计的出站月流量达到 1TB 时报警</p></blockquote><p><code>[{"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}}]</code></p></blockquote><h2 id="通知触发模式说明" tabindex="-1">通知触发模式说明 <a class="header-anchor" href="#通知触发模式说明" aria-hidden="true">#</a></h2><ul><li>始终触发:每当 Agent 上报的状态符合报警的规则时,都会触发一次通知</li><li>单次触发:仅状态改变时触发一次通知,如从正常状态改变为异常状态,或异常状态恢复为正常状态</li></ul><h2 id="设置报警时执行任务" tabindex="-1">设置报警时执行任务 <a class="header-anchor" href="#设置报警时执行任务" aria-hidden="true">#</a></h2><p>如果你需要在发出报警消息的同时执行某项任务,可以设置此项目</p><ul><li><code>故障时触发任务</code> 当报警状态符合从“正常”变更为“故障”时,所要执行的任务,任务应提前在任务页设置</li><li><code>恢复时触发任务</code> 当报警状态符合从“故障”恢复为“正常”时,所要执行的任务,任务应提前在任务页设置</li></ul></div></div><footer class="page-footer" data-v-7eddb2c4 data-v-07c132fc><div class="edit" data-v-07c132fc><div class="edit-link" data-v-07c132fc data-v-1ed99556><a class="link" href="https://github.com/nezhahq/nezhahq.github.io/edit/main/docs/guide/notifications.md" target="_blank" rel="noopener noreferrer" data-v-1ed99556>在GitHub中编辑 <svg class="icon outbound icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15" data-v-1ed99556><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div></div><div class="updated" data-v-07c132fc><p class="last-updated" data-v-07c132fc data-v-abce3432><span class="prefix" data-v-abce3432>上次更新:</span><span class="datetime" data-v-abce3432></span></p></div></footer><div class="next-and-prev-link" data-v-7eddb2c4 data-v-38ede35f><div class="container" data-v-38ede35f><div class="prev" data-v-38ede35f><a class="link" href="/guide/tasks" data-v-38ede35f><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon icon-prev" data-v-38ede35f><path d="M19,11H7.4l5.3-5.3c0.4-0.4,0.4-1,0-1.4s-1-0.4-1.4,0l-7,7c-0.1,0.1-0.2,0.2-0.2,0.3c-0.1,0.2-0.1,0.5,0,0.8c0.1,0.1,0.1,0.2,0.2,0.3l7,7c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3c0.4-0.4,0.4-1,0-1.4L7.4,13H19c0.6,0,1-0.4,1-1S19.6,11,19,11z"></path></svg><span class="text" data-v-38ede35f>定时任务</span></a></div><div class="next" data-v-38ede35f><a class="link" href="/guide/settings" data-v-38ede35f><span class="text" data-v-38ede35f>设置</span><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon icon-next" data-v-38ede35f><path d="M19.9,12.4c0.1-0.2,0.1-0.5,0-0.8c-0.1-0.1-0.1-0.2-0.2-0.3l-7-7c-0.4-0.4-1-0.4-1.4,0s-0.4,1,0,1.4l5.3,5.3H5c-0.6,0-1,0.4-1,1s0.4,1,1,1h11.6l-5.3,5.3c-0.4,0.4-0.4,1,0,1.4c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3l7-7C19.8,12.6,19.9,12.5,19.9,12.4z"></path></svg></a></div></div></div><!--[--><!--]--></div></main></div><!----><!--]--></div>
|
||
<script>__VP_HASH_MAP__ = JSON.parse("{\"case_case1.md\":\"c57845bb\",\"case_case2.md\":\"4e2f3d59\",\"case_case3.md\":\"9ffcf258\",\"case_case4.md\":\"5f197345\",\"case_index.md\":\"25117d67\",\"developer_index.md\":\"09847710\",\"developer_l10n.md\":\"0fdea9dc\",\"developer_theme.md\":\"3043d0d6\",\"en_us_case_case1.md\":\"f6af273d\",\"en_us_case_case2.md\":\"45d8419d\",\"en_us_case_case3.md\":\"576acd4f\",\"en_us_case_case4.md\":\"c13e3d57\",\"en_us_case_index.md\":\"e85c2b5e\",\"en_us_developer_index.md\":\"d73c8d72\",\"en_us_developer_l10n.md\":\"16739d39\",\"en_us_developer_theme.md\":\"b6e991af\",\"en_us_guide_agent.md\":\"04858606\",\"en_us_guide_agentq.md\":\"6f4fa583\",\"en_us_guide_api.md\":\"afd899f0\",\"en_us_guide_dashboard.md\":\"9baceaf6\",\"en_us_guide_dashboardq.md\":\"09a5d0a0\",\"en_us_guide_loginq.md\":\"1af6198f\",\"en_us_guide_notifications.md\":\"b869c13b\",\"en_us_guide_q2.md\":\"d84fe347\",\"en_us_guide_q3.md\":\"e0d1552a\",\"en_us_guide_q4.md\":\"935580a1\",\"en_us_guide_q5.md\":\"6916b56e\",\"en_us_guide_q6.md\":\"94c05cf7\",\"en_us_guide_q7.md\":\"75c857c2\",\"en_us_guide_servers.md\":\"f96f0a0e\",\"en_us_guide_services.md\":\"c5de2f6c\",\"en_us_guide_settings.md\":\"7e3ca56b\",\"en_us_guide_tasks.md\":\"926aff97\",\"en_us_index.md\":\"4c740f8b\",\"guide_agent.md\":\"678c7d07\",\"guide_agentq.md\":\"f457cf03\",\"guide_api.md\":\"468772b9\",\"guide_dashboard.md\":\"7e22b040\",\"guide_dashboardq.md\":\"65bb3c89\",\"guide_loginq.md\":\"1b0fcf93\",\"guide_notifications.md\":\"abde0a78\",\"guide_q1.md\":\"412e5eaf\",\"guide_q2.md\":\"702e38ec\",\"guide_q3.md\":\"3e19f217\",\"guide_q4.md\":\"76788fc4\",\"guide_q5.md\":\"24113023\",\"guide_q6.md\":\"6cb72e9e\",\"guide_q7.md\":\"478c2075\",\"guide_servers.md\":\"bd64e498\",\"guide_services.md\":\"3b743422\",\"guide_settings.md\":\"5a73023e\",\"guide_tasks.md\":\"939c3ef4\",\"index.md\":\"3ef954bc\"}")</script>
|
||
<script type="module" async src="/assets/app.3817bf4e.js"></script>
|
||
|
||
</body>
|
||
</html> |