更新:中英文报警、任务页,以符合上游更改。优化了一些小细节

This commit is contained in:
“hhhkkk520” 2022-09-15 17:55:47 +02:00
parent 518edebcb6
commit 37148a77ab
6 changed files with 68 additions and 42 deletions

View File

@ -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. >>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}}]` > `[{"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)
## 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

View File

@ -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 ## How to use
Go to the "Tasks" page of the admin panel and click "Add Scheduled Task" 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: To add a scheduled task you need to make the following settings:
+ `Name` - Customize a task name + `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` 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 `&&/&`** + `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 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 + `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 + `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

View File

@ -149,4 +149,12 @@ URL 里面也可放置占位符,请求时会进行简单的字符串替换。
>> ID 为 3 和 4 的服务器ignore 里面定义),以每月 1 号为统计周期,周期内统计的出站月流量达到 1TB 时报警 >> 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}}]` >`[{"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)
## 通知触发模式说明
- 始终触发:每一次监测到符合报警的规则时,都会触发一次通知
- 单次触发:仅状态改变时触发一次通知,如从正常状态改变为异常状态,或异常状态恢复为正常状态
## 设置报警时执行任务
如果你需要在发出报警消息的同时执行某项任务,可以设置此项目
+ `故障时触发任务` 当报警状态符合从“正常”变更为“故障”时,所要执行的任务,任务应提前在任务页设置
+ `恢复时触发任务` 当报警状态符合从“故障”恢复为“正常”时,所要执行的任务,任务应提前在任务页设置

View File

@ -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点` 如:`0 0 3 * * *` 对应为 `每天3点`
+ `命令` - 你可以在这里设置需要执行的命令,就像写 Shell/Bat 脚本一样,**但是不推荐换行,多个命令使用 `&&/&` 连接** + `命令` - 你可以在这里设置需要执行的命令,就像写 Shell/Bat 脚本一样,**但是不推荐换行,多个命令使用 `&&/&` 连接**
例如执行定期重启命令,可以在这里输入 `reboot` 例如执行定期重启命令,可以在这里输入 `reboot`
+ `覆盖范围``特定服务器` - 跟“服务”页中的设置类似,选择规则来确定哪些 Agent 执行计划任务 + `覆盖范围``特定服务器` - 跟“服务”页中的设置类似,选择规则来确定哪些 Agent 执行计划任务
使用触发任务类型时,可选择`由触发的服务器执行`
+ `通知方式组` - 选择你已经在 “报警” 页设置好的通知方式,[点击这里](/guide/notifications.html#灵活的通知方式)了解详情 + `通知方式组` - 选择你已经在 “报警” 页设置好的通知方式,[点击这里](/guide/notifications.html#灵活的通知方式)了解详情