This commit is contained in:
naiba committed 2023-03-08 03:07:20 +00:00
1 parent 97781ba1a6
commit fbd8edd613
162 files changed
+335 -231

No files matched your search

+29 -3
View File
@@ -8,7 +8,7 @@
<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/en_US_guide_notifications.md.e63b1fa0.lean.js">
<link rel="modulepreload" href="/assets/en_US_guide_notifications.md.fa81e634.lean.js">
<meta name="twitter:title" content="Flexible notification methods | Nezha Monitoring">
<meta property="og:title" content="Flexible notification methods | Nezha Monitoring">
@@ -30,8 +30,34 @@
]
}
}
</code></pre></div><ul><li>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 <code>Mail.Send</code> permission and get the Token, or you can go <a href="https://developer.microsoft.com/en-us/graph/graph-explorer" target="_blank" rel="noopener noreferrer">Microsoft Graph Explorer</a> directly to give permission and get the Token, just replace the Token in the Header with the actual Token.</li></ul><br><br><h2 id="description-of-notification-rules" tabindex="-1">Description of notification rules <a class="header-anchor" href="#description-of-notification-rules" aria-hidden="true">#</a></h2><h3 id="basic-rules" tabindex="-1">Basic Rules <a class="header-anchor" href="#basic-rules" aria-hidden="true">#</a></h3><ul><li>Type: one or more types can be selected, such as in a rule to select more than one type, you need to <strong>meet all the selected types at the same time</strong> to trigger the notification (see the example later) <ul><li><code>cpu</code>、<code>memory</code>、<code>swap</code>、<code>disk</code></li><li><code>net_in_speed</code> Inbound speed, <code>net_out_speed</code> Outbound speed, <code>net_all_speed</code> Inbound + Outbound speed, <code>transfer_in</code> Inbound Transfer, <code>transfer_out</code> Outbound Transfer, <code>transfer_all</code> Total Transfer</li><li><code>offline</code> Offline monitoring</li><li><code>load1</code>、<code>load5</code>、<code>load15</code> Load</li><li><code>process_count</code> Number of processes <em>Currently, counting the number of processes takes up too many resources and is not supported at the moment</em></li><li><code>tcp_conn_count</code>、<code>udp_conn_count</code> Number of connections</li></ul></li><li>duration:Lasting for a few seconds, the notification will only be triggered when the sampling record reaches 30% or more within a few seconds</li><li>min/max <ul><li>Transfer, network speed, and other values of the same type. Unit is byte (1KB=1024B,1MB = 1024*1024B)</li><li>Memory, hard disk, CPU. units are usage percentages</li><li>No setup required for offline monitoring</li></ul></li><li>cover <code>[{&quot;type&quot;:&quot;offline&quot;,&quot;duration&quot;:10, &quot;cover&quot;:0, &quot;ignore&quot;:{&quot;5&quot;: true}}]</code><ul><li><code>0</code> Cover all, use <code>ignore</code> to ignore specific servers</li><li><code>1</code> Ignore all, use <code>ignore</code> to monitoring specific servers<br> For example: <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: Select to ignore specific servers, use with <code>cover</code> with server id and boolean, e.g.: <code>{&quot;1&quot;: true, &quot;2&quot;:false}</code></li></ul><p><strong>Complete examples:</strong></p><blockquote><blockquote><p>Add an offline notification</p></blockquote><ul><li>Name: Offline notification</li><li>Rules: <code>[{&quot;Type&quot;:&quot;offline&quot;,&quot;Duration&quot;:10}]</code></li><li>Enable: √</li></ul></blockquote><blockquote><blockquote><p>Add an notification when the CPU exceeds 50% for 10s <strong>but</strong> the memory usage is below 20% for 20s</p></blockquote><ul><li>Name: CPU and RAM</li><li>Rules: <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>Enable: √</li></ul></blockquote><blockquote><blockquote><p>Send specific server notifications to specific notification groups</p></blockquote><p>Case:<br> You have four servers, 1, 2, 3, 4, and two different notification groups, A and B<br> 1, 2 The two servers are down for 10 minutes and send a notification to Notification Group A<br> 3, 4 These two servers are down for ten minutes and then send a notification to Notification Group B</p><p>First you need to set up two notification groups, A and B, and then add two alarm rules:</p><p><strong>Rule I:</strong></p><ul><li>Name: 1, 2 Off-line, send notification to group A</li><li>Rules:<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>Notification group: A</li><li>Enable: √</li></ul><p><strong>Rule II:</strong></p><ul><li>Name: 3, 4 Off-line, send notification to group B</li><li>Rules:<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>Notification group: B</li><li>Enable: √</li></ul></blockquote><p><strong>Using these rules flexibly will help you to make full use of the notification function</strong></p><br><h3 id="special-any-cycle-transfer-notification" tabindex="-1">Special: Any-cycle transfer notification <a class="header-anchor" hrefLine truncated
<script>__VP_HASH_MAP__ = JSON.parse("{\"case_case1.md\":\"199f944f\",\"case_case2.md\":\"216f0ae3\",\"case_case3.md\":\"65b6f8e7\",\"case_case4.md\":\"057b1fc0\",\"case_index.md\":\"f4837590\",\"developer_index.md\":\"4933c0c5\",\"developer_l10n.md\":\"e795d133\",\"developer_theme.md\":\"51aaddc6\",\"en_us_case_case1.md\":\"47eb9b94\",\"en_us_case_case2.md\":\"ae558f56\",\"en_us_case_case3.md\":\"b45ed8d3\",\"en_us_case_case4.md\":\"81ef69ce\",\"en_us_case_index.md\":\"7a64a4bf\",\"en_us_developer_index.md\":\"90f95702\",\"en_us_developer_l10n.md\":\"318ae7a9\",\"en_us_developer_theme.md\":\"1c69eee9\",\"en_us_guide_agent.md\":\"7cfd486a\",\"en_us_guide_agentq.md\":\"700db820\",\"en_us_guide_api.md\":\"02a0ffbf\",\"en_us_guide_dashboard.md\":\"09eb0d24\",\"en_us_guide_dashboardq.md\":\"ff522059\",\"en_us_guide_loginq.md\":\"dbb9e7d6\",\"en_us_guide_notifications.md\":\"e63b1fa0\",\"en_us_guide_q2.md\":\"816d77cd\",\"en_us_guide_q3.md\":\"e4065d2a\",\"en_us_guide_q4.md\":\"83ed8430\",\"en_us_guide_q5.md\":\"809a668f\",\"en_us_guide_q6.md\":\"06901512\",\"en_us_guide_q7.md\":\"3a3ecc2c\",\"en_us_guide_servers.md\":\"91698ca9\",\"en_us_guide_services.md\":\"9146fdee\",\"en_us_guide_settings.md\":\"54888083\",\"en_us_guide_tasks.md\":\"df9a3b24\",\"en_us_index.md\":\"55ebc7f2\",\"guide_agent.md\":\"4007e3a3\",\"guide_agentq.md\":\"3d19759a\",\"guide_api.md\":\"82a1ace5\",\"guide_dashboard.md\":\"a2e1c9da\",\"guide_dashboardq.md\":\"df657586\",\"guide_loginq.md\":\"d229ec31\",\"guide_notifications.md\":\"9a5b8663\",\"guide_q1.md\":\"1fe0cdc7\",\"guide_q2.md\":\"b2dbea48\",\"guide_q3.md\":\"5b42517f\",\"guide_q4.md\":\"306b9b9e\",\"guide_q5.md\":\"505e3bab\",\"guide_q6.md\":\"8b300242\",\"guide_q7.md\":\"9628abfa\",\"guide_servers.md\":\"3badefad\",\"guide_services.md\":\"f3fb5f93\",\"guide_settings.md\":\"521b0eef\",\"guide_tasks.md\":\"9c5a85cc\",\"index.md\":\"1737ea60\"}")</script>
</code></pre></div><ul><li><p>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 <code>Mail.Send</code> permission and get the Token, or you can go <a href="https://developer.microsoft.com/en-us/graph/graph-explorer" target="_blank" rel="noopener noreferrer">Microsoft Graph Explorer</a> directly to give permission and get the Token, just replace the Token in the Header with the actual Token.</p></li><li><p><strong>Wechat Work Group bot Example, contributed by <a href="https://github.com/ChowRex" target="_blank" rel="noopener noreferrer">@ChowRex</a></strong></p><p>Support placeholders:</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> # Invalid
<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> # Invalid
<span class="token punctuation">}</span>
</code></pre></div><blockquote><p>Sorry, this document is <strong>NOT</strong> available in English.</p><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>Name:WechatWork Group bot notification</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>Request method: POST</p></li><li><p>Request type: 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;# Nezha Notification\n\n\&quot;#NEZHA#\&quot;\n\n&gt; ServerName: \&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; Memory: \&quot;#SERVER.MEM#\&quot;\n&gt; SWAP: \&quot;#SERVER.SWAP#\&quot;\n&gt; Storage: \&quot;#SERVER.DISK#\&quot;\n&gt; Real-time Upload: \&quot;#SERVER.NETINSPEED#\&quot;\n&gt; Real-time Download: \&quot;#SERVER.NETOUTSPEED#\&quot;\n&gt; Total Upload: \&quot;#SERVER.TRANSFERIN#\&quot;\n&gt; Total Download: \&quot;#SERVER.TRANSFEROUT#\&quot;\n&gt; 1m Load: \&quot;#SERVER.LOAD1#\&quot;\n&gt; 5m Load: \&quot;#SERVER.LOAD5#\&quot;\n&gt; 15m Load: \&quot;#SERVER.LOAD15#\&quot;\n&gt; TCP Connections: \&quot;#SERVER.TCPCONNCOUNT\&quot;\n&gt; UDP Connections: \&quot;#SERVER.UDPCONNCOUNT\&quot;\n\n&quot;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre></div><p>Delete relevant content information as needed</p><p><img src="https://user-images.githubusercontent.com/30169860/223605886-b7736825-24b8-4b6c-8bc9-96ac388599ef.png" alt=""></p></li></ul></li></ul><br><br><h2 id="description-of-notification-rules" tabindex="-1">Description of notification rules <a class="header-anchor" href="#description-of-notification-rules" aria-hidden="true">#</a></h2><h3 id="basic-rules" tabindex="-1">Basic Rules <a class="header-anchor" href="#basic-rules" aria-hidden="true">#</a></h3><ul><li>Type: one or more types can be selected, such as in a rule to select more than one type, you need to <strong>meet all the selected types at the same time</strong> to trigger the notification (see the example later) <ul><li><code>cpu</code>、<code>memory</code>、<code>swap</code>、<code>disk</code></li><li><code>net_in_speed</code> Inbound speed, <code>net_out_speed</code> Outbound speed, <code>net_all_speed</code> Inbound + Outbound speed, <code>transfer_in</code> Inbound Transfer, <code>transfer_out</code> Outbound Transfer, <code>transfer_all</code> Total Transfer</li><li><code>offline</code> Offline monitoring</li><li><code>load1</code>、<code>load5</code>、<code>load15</code> Load</li><li><code>process_count</code> Number of processes <em>Currently, counting the number of processes takes up too many resources and is not supported at the moment</em></li><li><code>tcp_conn_count</code>、<code>udp_conn_count</code> Number of connections</li></ul></li><li>duration:Lasting for a few seconds, the notification will only be triggered when the sampling record reaches 30% or more within a few seconds</li><li>min/max <ul><li>Transfer, network speed, and other values of the same type. Unit is byte (1KB=1024B,1MB = 1024*1024B)</li><li>Memory, hard disk, CPU. units are usage percentages</li><li>No setup required for offline monitoring</li></ul></li><li>cover <code>[{&quot;type&quot;:&quot;offline&quot;,&quot;duration&quot;:10, &quot;cover&quot;:0, &quot;ignore&quot;:{&quot;5&quot;: true}}]</code><ul><li><code>0</code> Cover all, use <code>ignore</code> to ignore specific servers</li><li><code>1</code> Ignore all, use <code>ignore</code> to monitoring specific servers<br> For example: <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: Select to ignore specific servers, use with <code>cover</code> with server id and boolean, e.g.: <code>{&quot;1&quot;: true, &quot;2&quot;:false}</code></li></ul><p><strong>Complete examples:</strong></p><blockquote><blockquote><p>Add an offline notification</p></blockquote><ul><li>Name: Offline notification</li><li>Rules: <code>[{&quot;Type&quot;:&quot;offline&quot;,&quot;Duration&quot;:10}]</code></li><li>Enable: √</li></ul></blockquote><blockquote><blockquote><p>Add an notification when the CPU exceeds 50% for 10s <strong>but</strong> the memory usage is below 20% for 20s</p></blockquote><ul><li>Name: CPU and RAM</li><li>Rules: <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>Enable: √</li></ul></blockquote><blockquote><blockquote><p>Send specific server notifications to specific notification groups</p></blockquote><p>Case:<br> You have four servers, 1, 2, 3, 4, and two different notification groups, A and B<br> 1, 2 The two servers are down for 10 minutes and send a notification to Notification Group A<br> 3, 4 These two servers are down for ten minutes and then send a notification to Notification Group B</p><p>First you need to set up two notification groups, A and B, and then add two alarm rules:</p><p><strong>Rule I:</strong></p><ul><li>Name: 1, 2 Off-line, send notification to group A</li><li>Rules:<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>Notification group: A</li><li>Enable: √</li></ul><p><strong>Rule II:</strong></p><ul><li>Name: 3, 4 Off-line, send notification to group B</li><li>Rules:<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>Notification group: B</li><li>Enable: √</li></ul></blockquote><p><strong>Using these rules flexibly will help you to make full use of the notification function</strong></p><br><h3 id="special-any-cycle-transfer-notification" tabindex="-1">Special: Any-cycle transfer notification <a class="header-anchor" href="#special-any-cycle-transfer-notification" aria-hidden="true">#</a></h3><p>Can be used as monthly transfer notificatin</p><ul><li><p>type</p><ul><li><code>transfer_in_cycle</code> Inbound transfer during the cycle</li><li><code>transfer_out_cycle</code> Outbound transfer durinLine truncated
<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>