From 37148a77ab467df567bfe4ebed194a5106acd122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chhhkkk520=E2=80=9D?= Date: Thu, 15 Sep 2022 17:55:47 +0200 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=EF=BC=9A=E4=B8=AD=E8=8B=B1?= =?UTF-8?q?=E6=96=87=E6=8A=A5=E8=AD=A6=E3=80=81=E4=BB=BB=E5=8A=A1=E9=A1=B5?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E7=AC=A6=E5=90=88=E4=B8=8A=E6=B8=B8=E6=9B=B4?= =?UTF-8?q?=E6=94=B9=E3=80=82=E4=BC=98=E5=8C=96=E4=BA=86=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=B0=8F=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en_US/guide/notifications.md | 10 ++++++- docs/en_US/guide/tasks.md | 11 ++++++-- docs/guide/agent.md | 16 +++++------ docs/guide/dashboard.md | 46 +++++++++++++++---------------- docs/guide/notifications.md | 14 ++++++++-- docs/guide/tasks.md | 13 ++++++--- 6 files changed, 68 insertions(+), 42 deletions(-) diff --git a/docs/en_US/guide/notifications.md b/docs/en_US/guide/notifications.md index d699fc99..7c2de5f1 100644 --- a/docs/en_US/guide/notifications.md +++ b/docs/en_US/guide/notifications.md @@ -136,4 +136,12 @@ 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}}]` - ![7QKaUx.md.png](https://s4.ax1x.com/2022/01/13/7QKaUx.md.png) \ No newline at end of file + + ## 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 + +## Set the task to be executed when notification +If you need to perform a task while sending a notification message, you can set those items ++ `Tasks to be triggered in case of failure` The task to be executed when the notification status matches the change from "normal" to "failure", the task should be set in advance in the tasks page ++ `Tasks to be triggered after fault recovery` The task to be executed when the notification status matches the change from " failure " to " normal ", the task should be set in advance in the tasks page \ No newline at end of file diff --git a/docs/en_US/guide/tasks.md b/docs/en_US/guide/tasks.md index bc5379aa..a427a4ec 100644 --- a/docs/en_US/guide/tasks.md +++ b/docs/en_US/guide/tasks.md @@ -1,19 +1,24 @@ -**In the task area, you can set up scheduled tasks, periodic tasks, and multi-server batch execution tasks** +**In the task area, you can set up scheduled tasks, Trigger tasks, and multi-server batch execution tasks** -Nezha monitoring supports pushing commands to the Agent for execution, so this feature is very flexible and can be used to periodically back up the server in conjunction with restic, rclone, or periodically restart a service to reset the network connection. +Nezha monitoring supports pushing commands to the Agent for execution, so this feature is very flexible and can be used to periodically back up the server in conjunction with restic, rclone. Periodically restart a service to reset the network connection. It can also be used with notifications to perform a task when a notification is triggered, such as running a script when the CPU is at high occupancy for a long period of time. ## How to use Go to the "Tasks" page of the admin panel and click "Add Scheduled Task" To add a scheduled task you need to make the following settings: + `Name` - Customize a task name -+ `Cron Expression` - Set schedule time, the Cron Expression is like:: `* * * * * *` `sec min hour day month week`, see details in [CRON Expression Format](https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format) ++ `Task Type` - select the type of task +Scheduled Tasks - Tasks are executed periodically at the scheduled time set below +Trigger Tasks - Tasks that are triggered only by API or notification rules and are executed once per trigger + ++ `Cron Expression` - (Not valid when using the trigger task type) Set schedule time, the Cron Expression is like:: `* * * * * *` `sec min hour day month week`, see details in [CRON Expression Format](https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format) For example: `0 0 3 * * *` is `Every day at 3 o'clock` + `Command` - Just like writing shell/bat scripts, **but line wrap is not recommended**, **Multiple Commands should be connected with `&&/&`** For example, to execute a periodic reboot command, you can type `reboot` here + `Coverage` and `Specific Servers` - Similar to the settings on the Services page, select rules to determine which Agents need to execute scheduled tasks +When using the trigger task type, you can select `Only servers that are included in the notification rule` + `Notification Group` - Select the notification method you have set up on the "Notification" page. [Click here](/en_US/guide/notifications.html#flexible-notification-methods) for more information diff --git a/docs/guide/agent.md b/docs/guide/agent.md index c1aab5ef..a0d06440 100644 --- a/docs/guide/agent.md +++ b/docs/guide/agent.md @@ -2,12 +2,12 @@
## 一键安装 Agent -目前哪吒监控已支持在Windows和Linux上一键安装Agent,遵循本文档的步骤,你可以很轻松的在服务器上部署它 +目前哪吒监控已支持在 Windows 和 Linux上一键安装 Agent,遵循本文档的步骤,你可以很轻松的在服务器上部署它
### 准备工作 你需要提前在管理面板中设置好通信域名,此域名不可以接入CDN,这里以前面提到过的示例通信域名 “data.example.com” 来做演示 -进入后台管理面板,转到“设置”页,在“未接入CDN的面板服务器域名/IP”项中填入通信域名,然后点击"保存" +进入后台管理面板,转到“设置”页,在“未接入 CDN 的面板服务器域名/IP”项中填入通信域名,然后点击"保存"
### 在 Linux 中一键安装 (Ubuntu、Debian、CentOS) @@ -38,9 +38,9 @@ curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh ````bash curl -L https://jihulab.com/nezha/nezha/-/raw/master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo CN=true ./nezha.sh ```` -* 选择“安装监控Agent” +* 选择“安装监控 Agent” * 输入通信域名,如:”data.example.com“ -* 输入面板通信端口(RPC端口),默认为5555 +* 输入面板通信端口(RPC端口),默认为 5555 * 输入 Agent 密钥,Agent 密钥在管理面板中添加服务器时生成,可以在管理面板中的“主机”页中找到 * 等待安装完成后返回 Dashboard 主页查看服务器是否上线
@@ -145,7 +145,7 @@ EOF ***本节内容改编自[Mitsea Blog](https://blog.mitsea.com/e796f93db38d49e4b18df234c6ee75f5),改编已获得原作者授权***
::: warning -安装过程中如提示“macOS无法验证此app“,请前往系统设置手动允许程序运行 +安装过程中如提示“macOS 无法验证此 app“,请前往系统设置手动允许程序运行 ::: + 首先在管理面板中添加一台服务器 @@ -197,14 +197,14 @@ launchctl remove nezha_agent ```
-### 在 OpenWRT 中安装Agent +### 在 OpenWRT 中安装 Agent -**如何使 旧版OpenWRT/LEDE 自启动** +**如何使 旧版 OpenWRT/LEDE 自启动** - 请参考项目: [哪吒监控 For OpenWRT](https://github.com/Erope/openwrt_nezha)
-**如何使 新版OpenWRT 自启动?来自 @艾斯德斯** +**如何使 新版 OpenWRT 自启动?来自 @艾斯德斯** * 首先在 release 下载对应的二进制解压 zip 包后放置到 `/root` * 运行 `chmod +x /root/nezha-agent` 赋予执行权限,然后创建 `/etc/init.d/nezha-service`: diff --git a/docs/guide/dashboard.md b/docs/guide/dashboard.md index 3cffda79..c9cb3060 100644 --- a/docs/guide/dashboard.md +++ b/docs/guide/dashboard.md @@ -1,15 +1,15 @@ ## 准备工作 搭建一个哪吒监控,你需要: -1. 一台可以连接公网的VPS,防火墙和安全策略需要放行 8008 和 5555 端口,否则会无法访问和无法接收数据。单核512MB内存的服务器配置就足以满足大多数使用场景 -2. 一个已经设置好A记录,指向Dashboard服务器ip的域名 +1. 一台可以连接公网的 VPS,防火墙和安全策略需要放行 8008 和 5555 端口,否则会无法访问和无法接收数据。单核 512MB 内存的服务器配置就足以满足大多数使用场景 +2. 一个已经设置好 A 记录,指向 Dashboard 服务器 ip 的域名 ::: tip -如果你想使用CDN,请准备两个域名,一个配置好CDN用作公开访问,CDN需要支持WebSocket协议;另一个域名不要使用CDN,用作Agent端与Dashboard的通信 +如果你想使用 CDN,请准备两个域名,一个配置好 CDN 用作公开访问,CDN 需要支持WebSocket 协议;另一个域名不要使用 CDN,用作 Agent 端与 Dashboard 的通信 本文档分别以 "cdn.example.com" 和 "data.example.com" 两个域名来演示 ::: -3. 一个Github账号(或:Gitlab、Jihulab、Gitee) +3. 一个 Github 账号(或:Gitlab、Jihulab、Gitee) ::: tip -如果您位于中国大陆,访问 Github 有困难,我们建议您选择 Jihulab 作为OAuth提供商 +如果您位于中国大陆,访问 Github 有困难,我们建议您选择 Jihulab 作为 OAuth 提供商 ::: **本文档将以宝塔面板反代面板的过程作为范例,随着未来版本的变化,部分功能的入口可能会发生改变,本文档仅供参考** @@ -20,23 +20,23 @@

-## 获取Github/Jihulab的Client ID和密钥 +## 获取 Github/Jihulab 的 Client ID 和密钥 -哪吒监控接入Github、Gitlab、Jihulab、Gitee作为后台管理员账号 -+ 首先我们需要新建一个验证应用,以Github为例,登录Github后,打开 https://github.com/settings/developers ,依次选择“OAuth Apps” - “New OAuth App” +哪吒监控接入 Github、Gitlab、Jihulab、Gitee 作为后台管理员账号 ++ 首先我们需要新建一个验证应用,以 Github 为例,登录 Github 后,打开 https://github.com/settings/developers ,依次选择“OAuth Apps” - “New OAuth App” `Application name` - 随意填写 `Homepage URL` - 填写面板的访问域名,如:"http://cdn.example.com" `Authorization callback URL` - 填写回调地址,如:"http://cdn.example.com/oauth2/callback" -+ 点击“Register application” -+ 保存页面中的Client ID,然后点击 “Generate a new client secret“,创建一个新的Client Secret,新建的密钥仅会显示一次,请妥善保存 ++ 点击 “Register application” ++ 保存页面中的 Client ID,然后点击 “Generate a new client secret“,创建一个新的 Client Secret,新建的密钥仅会显示一次,请妥善保存

-+ JihuLab的应用创建入口为:https://jihulab.com/-/profile/applications ++ JihuLab 的应用创建入口为:https://jihulab.com/-/profile/applications + `Redirect URL` 中应填入回调地址 + 在下方`范围`中勾选 `read_user` 和 `read_api` -+ 创建完成后,保存好应用程序ID和密码 ++ 创建完成后,保存好应用程序 ID 和密码 -## 在服务器中安装Dashboard +## 在服务器中安装 Dashboard * 在面板服务器中,运行安装脚本: ```bash @@ -48,13 +48,13 @@ curl -L https://jihulab.com/nezha/nezha/-/raw/master/script/install.sh -o nezha. ```` * 等待Docker安装完毕后,分别输入以下值: -`OAuth提供商` - Github,Gitlab,Jihulab,Gitee中选择一个 -`Client ID` - 之前保存的Client ID +`OAuth提供商` - Github,Gitlab,Jihulab,Gitee 中选择一个 +`Client ID` - 之前保存的 Client ID `Client Secret` - 之前保存的密钥 -`用户名` - OAuth提供商中的用户名 +`用户名` - OAuth 提供商中的用户名 `站点标题` - 自定义站点标题 -`访问端口` - 公开访问端口,可自定义,默认8008 -`Agent的通信端口` - Agent与Dashboard的通信端口,默认5555 +`访问端口` - 公开访问端口,可自定义,默认 8008 +`Agent的通信端口` - Agent与Dashboard的通信端口,默认 5555 * 输入完成后,等待拉取镜像 安装结束后,如果一切正常,此时你可以访问域名+端口号,如 “http://cdn.example.com:8008” 来查看面板 @@ -71,7 +71,7 @@ curl -L https://jihulab.com/nezha/nezha/-/raw/master/script/install.sh -o nezha. * 在宝塔面板中新建一个站点,域名填写公开访问域名,如 “http://cdn.example.com“ ,然后点击“设置”进入站点设置选项,选择“反向代理” - “新建反向代理” -* 自定义一个代理名称,在下方“目标URL”中填入 `http://127.0.0.1` 然后点击“保存” +* 自定义一个代理名称,在下方“目标 URL”中填入 `http://127.0.0.1` 然后点击“保存” * 打开刚刚新建的反向代理右边的“配置文件”,将配置文件替换为以下内容: ````nginx @@ -112,16 +112,16 @@ location ~ ^/(ws|terminal/.+)$ {

-## 在宝塔面板中配置SSL +## 在宝塔面板中配置 SSL 首先,先暂时关闭反向代理 -正如在其他网站中配置SSL证书一样,进入站点设置中的“SSL”,你可以选择自动申请 Let´s Encrypt 证书或手动配置已有的证书 -完成SSL的设置后,你需要回到 https://github.com/settings/developers ,编辑之前创建的验证应用程序,将之前我们填入的"Homepage URL"和"Authorization callback URL"中的域名全部从`http`改为`https`,如:"https://cdn.example.com" 和 "https://cdn.example.com/oauth2/callback" ,**不更改此项可能会导致你无法登录面板后台** +正如在其他网站中配置 SSL 证书一样,进入站点设置中的 “SSL”,你可以选择自动申请 Let´s Encrypt 证书或手动配置已有的证书 +完成 SSL 的设置后,你需要回到 https://github.com/settings/developers ,编辑之前创建的验证应用程序,将之前我们填入的 "Homepage URL" 和 "Authorization callback URL" 中的域名全部从`http`改为`https`,如:"https://cdn.example.com" 和 "https://cdn.example.com/oauth2/callback" ,**不更改此项可能会导致你无法登录面板后台** ## FAQ ### 我对面板提供的数据修改/增加功能不满意,我想要自己修改/增加数据怎么办? 常见于批量插入 Agent 等需求中,可以直接修改数据库。 -请注意,数据库中并非什么都可以修改,错误的修改会导致数据混乱无法启动Dashboard,**请勿随意修改数据库!** +请注意,数据库中并非什么都可以修改,错误的修改会导致数据混乱无法启动 Dashboard,**请勿随意修改数据库!** ::: danger 再重复一遍,**请勿随意修改数据库!** ::: diff --git a/docs/guide/notifications.md b/docs/guide/notifications.md index 66d93d02..79ecdbd5 100644 --- a/docs/guide/notifications.md +++ b/docs/guide/notifications.md @@ -10,7 +10,7 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。 你可以参考以下的通知方式示例,也可以根据自己的需求灵活设置推送方式 - - server酱示例 + - server 酱示例 - 名称:server 酱 - URL:https://sc.ftqq.com/SCUrandomkeys.send?text=#NEZHA# @@ -148,5 +148,13 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。 >示例: >> ID 为 3 和 4 的服务器(ignore 里面定义),以每月 1 号为统计周期,周期内统计的出站月流量达到 1TB 时报警 > ->`[{"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}}]` - ![7QKaUx.md.png](https://s4.ax1x.com/2022/01/13/7QKaUx.md.png) +>`[{"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}}]` + +## 通知触发模式说明 +- 始终触发:每一次监测到符合报警的规则时,都会触发一次通知 +- 单次触发:仅状态改变时触发一次通知,如从正常状态改变为异常状态,或异常状态恢复为正常状态 + +## 设置报警时执行任务 +如果你需要在发出报警消息的同时执行某项任务,可以设置此项目 ++ `故障时触发任务` 当报警状态符合从“正常”变更为“故障”时,所要执行的任务,任务应提前在任务页设置 ++ `恢复时触发任务` 当报警状态符合从“故障”恢复为“正常”时,所要执行的任务,任务应提前在任务页设置 \ No newline at end of file diff --git a/docs/guide/tasks.md b/docs/guide/tasks.md index 9724396d..bb6e4983 100644 --- a/docs/guide/tasks.md +++ b/docs/guide/tasks.md @@ -1,19 +1,24 @@ -**在任务区域中,可以设置计划任务,定期任务,多服务器批量执行任务** +**在任务区域中,可以设置计划任务,触发任务,多服务器批量执行任务** -哪吒监控支持推送命令到 Agent 执行,因此此功能非常灵活,使用此功能可以定期结合 restic、rclone 给服务器备份,或者定期重启某项服务来重置网络连接 +哪吒监控支持推送命令到 Agent 执行,因此此功能非常灵活,使用此功能可以定期结合 restic、rclone 给服务器备份,定期重启某项服务来重置网络连接。也可以配合报警通知,在触发报警时执行某项任务,如 CPU 在长时期处于高占用的情况下运行某个脚本。 ## 使用方法 进入管理面板的 “任务” 页,点击 “添加计划任务” 添加计划任务你需要填入以下参数: + `名称` - 自定义一个任务名称 -+ `计划` - 设置计划时间,时间的格式为: `* * * * * *` 分别对应 `秒 分 时 天 月 星期`,详情见[计划表达式格式](https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format) ++ `任务类型` - 选择任务的类型 +计划任务 - 按下方设置的计划时间,周期性执行任务 +触发任务 - 仅被 API 或报警规则触发的任务,每次触发执行一次 + ++ `计划` - (使用触发任务类型时不生效)设置计划时间,时间的格式为: `* * * * * *` 分别对应 `秒 分 时 天 月 星期`,详情见[计划表达式格式](https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format) 如:`0 0 3 * * *` 对应为 `每天3点` + `命令` - 你可以在这里设置需要执行的命令,就像写 Shell/Bat 脚本一样,**但是不推荐换行,多个命令使用 `&&/&` 连接** 例如执行定期重启命令,可以在这里输入 `reboot` -+ `覆盖范围` 和 `特定服务器` - 跟“服务”页中的设置类似,选择规则来确定哪些 Agent 执行计划任务 ++ `覆盖范围` 和 `特定服务器` - 跟“服务”页中的设置类似,选择规则来确定哪些 Agent 执行计划任务 +使用触发任务类型时,可选择`由触发的服务器执行` + `通知方式组` - 选择你已经在 “报警” 页设置好的通知方式,[点击这里](/guide/notifications.html#灵活的通知方式)了解详情