nezhahq.github.io/guide/notifications.html

48 lines
31 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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.fc51b373.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>{&quot;title&quot;: &quot;#SERVER.NAME#&quot;,&quot;device_key&quot;:&quot;xxxxxxxxx&quot;,&quot;body&quot;:&quot;#NEZHA#&quot;,&quot;icon&quot;:&quot;https://xxxxxxxx/nz.png&quot;}</code></li></ul></li><li><p><strong>Server 酱示例</strong></p><ul><li>名称Server 酱</li><li>URL<a href="https://sc.ftqq.com/SCUrandomkeys.send?text=#NEZHA#" target="_blank" rel="noopener noreferrer">https://sc.ftqq.com/SCUrandomkeys.send?text=#NEZHA#</a></li><li>请求方式: GET</li><li>请求类型: 默认</li><li>Body: 空</li></ul></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>{&quot;appToken&quot;:&quot;你的appToken&quot;,&quot;topicIds&quot;:[],&quot;content&quot;:&quot;#NEZHA#&quot;,&quot;contentType&quot;:&quot;1&quot;,&quot;uids&quot;:[&quot;你的uid&quot;]}</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&amp;text=#NEZHA#" target="_blank" rel="noopener noreferrer">https://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&amp;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:后面一行)这里 &#39;bot&#39; 三个字母不可少。创建 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>&lt;替换APIUSER&gt;apiKey=&lt;替换APIKEY&gt;&amp;from=&lt;自定义发件邮箱&gt;&amp;fromName=Nezha&amp;to=&lt;自定义收件邮箱&gt;&amp;subject=Nezha-Notification&amp;html=#NEZHA#</li><li>请求方式: POST</li><li>请求类型: JSON</li><li>Header: 留空</li><li>Body: 留空</li></ul></li><li><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 中的 &lt;替换APIUSER&gt;&lt;替换APIKEY&gt; 为自己的 APIUSER 和 APIKEY替换 URL 中的 &lt;自定义发件邮箱&gt;&lt;自定义收件邮箱&gt; 为自己的发件邮箱和收件邮箱。</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">&quot;content&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#NEZHA#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;ServerName&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.NAME#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;ServerIP&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.IP#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;ServerIPV4&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.IPV4#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;ServerIPV6&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.IPV6#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;CPU&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.CPU#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;MEM&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.MEM#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;SWAP&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.SWAP#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;DISK&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.DISK#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;NetInSpeed&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.NETINSPEED#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;NetOutSpeed&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.NETOUTSPEED#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;TransferIn&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.TRANSFERIN#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;TranferOut&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.TRANSFEROUT#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;Load1&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.LOAD1#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;Load5&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.LOAD5#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;Load15&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.LOAD15#&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;TCP_CONN_COUNT&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.TCPCONNCOUNT&quot;</span><span class="token punctuation">,</span> # 无效
<span class="token property">&quot;UDP_CONN_COUNT&quot;</span><span class="token operator">:</span> <span class="token string">&quot;#SERVER.UDPCONNCOUNT&quot;</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">&quot;msgtype&quot;</span><span class="token operator">:</span> <span class="token string">&quot;markdown&quot;</span><span class="token punctuation">,</span>
<span class="token property">&quot;markdown&quot;</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">&quot;content&quot;</span><span class="token operator">:</span> <span class="token string">&quot;# 哪吒通知消息\n\n\&quot;#NEZHA#\&quot;\n\n&gt; 名称: \&quot;#SERVER.NAME#\&quot;\n&gt; IP: \&quot;#SERVER.IP#\&quot;\n&gt; IPv4: \&quot;#SERVER.IPV4#\&quot;\n&gt; IPv6: \&quot;#SERVER.IPV6#\&quot;\n&gt; CPU: \&quot;#SERVER.CPU#\&quot;\n&gt; 内存: \&quot;#SERVER.MEM#\&quot;\n&gt; 交换分区: \&quot;#SERVER.SWAP#\&quot;\n&gt; 存储: \&quot;#SERVER.DISK#\&quot;\n&gt; 实时上传速度: \&quot;#SERVER.NETINSPEED#\&quot;\n&gt; 实时下载速度: \&quot;#SERVER.NETOUTSPEED#\&quot;\n&gt; 总上传: \&quot;#SERVER.TRANSFERIN#\&quot;\n&gt; 总下载: \&quot;#SERVER.TRANSFEROUT#\&quot;\n&gt; 1分钟内负载: \&quot;#SERVER.LOAD1#\&quot;\n&gt; 5分钟内负载: \&quot;#SERVER.LOAD5#\&quot;\n&gt; 15分钟内负载: \&quot;#SERVER.LOAD15#\&quot;\n&gt; TCP连接数: \&quot;#SERVER.TCPCONNCOUNT\&quot;\n&gt; UDP连接数: \&quot;#SERVER.UDPCONNCOUNT\&quot;\n\n&quot;</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=1024B1MB = 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>[{&quot;type&quot;:&quot;offline&quot;,&quot;duration&quot;:10, &quot;cover&quot;:0, &quot;ignore&quot;:{&quot;5&quot;: true}}]</code></li></ul></li><li>ignore: 选择忽略特定服务器,搭配 <code>cover</code> 使用,内容为服务器 id 和布尔值,例如:<code>{&quot;1&quot;: true, &quot;2&quot;:false}</code></li></ul><p><strong>完整示例:</strong></p><blockquote><blockquote><p>添加一个离线报警</p></blockquote><ul><li>名称:离线通知</li><li>规则:<code>[{&quot;Type&quot;:&quot;offline&quot;,&quot;Duration&quot;: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>[{&quot;Type&quot;:&quot;cpu&quot;,&quot;Min&quot;:0,&quot;Max&quot;:50,&quot;Duration&quot;:10},{&quot;Type&quot;:&quot;memory&quot;,&quot;Min&quot;:20,&quot;Max&quot;:0,&quot;Duration&quot;: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>[{&quot;type&quot;:&quot;offline&quot;,&quot;duration&quot;:600,&quot;cover&quot;:1,&quot;ignore&quot;:{&quot;1&quot;:true,&quot;2&quot;:true}}]</code></li><li>通知方式组: A</li><li>启用:√</li></ul><p><strong>规则二:</strong></p><ul><li>名称3、4 离线,发送给通知组 B</li><li>规则:<code>[{&quot;type&quot;:&quot;offline&quot;,&quot;duration&quot;:600,&quot;cover&quot;:1,&quot;ignore&quot;:{&quot;3&quot;:true,&quot;4&quot;: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>[{&quot;type&quot;:&quot;transfer_out_cycle&quot;,&quot;max&quot;:1099511627776,&quot;cycle_start&quot;:&quot;2022-01-01T00:00:00+08:00&quot;,&quot;cycle_interval&quot;:1,&quot;cycle_unit&quot;:&quot;month&quot;,&quot;cover&quot;:1,&quot;ignore&quot;:{&quot;3&quot;:true,&quot;4&quot;: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\":\"016eed9d\",\"case_case2.md\":\"f67c1fe3\",\"case_case3.md\":\"bf638fdf\",\"case_case4.md\":\"3245ae29\",\"case_index.md\":\"ebb90ea0\",\"developer_index.md\":\"4d04d79c\",\"developer_l10n.md\":\"617b1a97\",\"developer_theme.md\":\"918b2e4e\",\"en_us_case_case1.md\":\"43e8a143\",\"en_us_case_case2.md\":\"a4b37606\",\"en_us_case_case3.md\":\"3b3d42a3\",\"en_us_case_case4.md\":\"38491e58\",\"en_us_case_index.md\":\"84f385b0\",\"en_us_developer_index.md\":\"f75e3f42\",\"en_us_developer_l10n.md\":\"3849e268\",\"en_us_developer_theme.md\":\"705c4cc6\",\"en_us_guide_agent.md\":\"a2a51d03\",\"en_us_guide_agentq.md\":\"2308e834\",\"en_us_guide_api.md\":\"c054bd2d\",\"en_us_guide_dashboard.md\":\"0806c57c\",\"en_us_guide_dashboardq.md\":\"e23f6f14\",\"en_us_guide_loginq.md\":\"d842b1d4\",\"en_us_guide_notifications.md\":\"fa81e634\",\"en_us_guide_q2.md\":\"702af635\",\"en_us_guide_q3.md\":\"4d3452c2\",\"en_us_guide_q4.md\":\"c42ec441\",\"en_us_guide_q5.md\":\"006e7c54\",\"en_us_guide_q6.md\":\"990dce4b\",\"en_us_guide_q7.md\":\"8e05e7f1\",\"en_us_guide_servers.md\":\"7a0c2f6a\",\"en_us_guide_services.md\":\"40302e30\",\"en_us_guide_settings.md\":\"99903d54\",\"en_us_guide_tasks.md\":\"160e34bf\",\"en_us_index.md\":\"e33f0352\",\"guide_agent.md\":\"229ecc9f\",\"guide_agentq.md\":\"1cea3a0f\",\"guide_api.md\":\"69992701\",\"guide_dashboard.md\":\"c0747146\",\"guide_dashboardq.md\":\"34553ae1\",\"guide_loginq.md\":\"4b8b521e\",\"guide_notifications.md\":\"fc51b373\",\"guide_q1.md\":\"8e74953b\",\"guide_q2.md\":\"c422d7f6\",\"guide_q3.md\":\"e35c5efe\",\"guide_q4.md\":\"d64613b1\",\"guide_q5.md\":\"367cf326\",\"guide_q6.md\":\"f0affa28\",\"guide_q7.md\":\"7173b6c9\",\"guide_servers.md\":\"e4abb554\",\"guide_services.md\":\"10023c9c\",\"guide_settings.md\":\"beb84c68\",\"guide_tasks.md\":\"f3e95746\",\"index.md\":\"f1c29ac9\"}")</script>
<script type="module" async src="/assets/app.3817bf4e.js"></script>
</body>
</html>