diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 9d938181..aaa2ccc3 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -67,12 +67,6 @@ export default defineConfig({ function getGuideSidebarZhCN() { return [ - { - text: '哪吒监控', - children: [ - { text: '介绍', link: '/' } - ] - }, { text: '安装手册', children: [ @@ -93,10 +87,10 @@ function getGuideSidebarZhCN() { { text: '常见问题', children: [ - { text: '问题1', link: '/guide/q1' }, - { text: '问题2', link: '/guide/q2' }, - { text: '问题3', link: '/guide/q3' }, - { text: '问题4', link: '/guide/q4' }, + { text: '如何进行数据迁移、备份恢复?', link: '/guide/q1' }, + { text: 'Agent 启动/上线 问题自检流程', link: '/guide/q2' }, + { text: '如何反向代理 gRPC 端口', link: '/guide/q3' }, + { text: '实时通道断开/在线终端连接失败', link: '/guide/q4' }, { text: '问题5', link: '/guide/q5' } ] } @@ -122,12 +116,6 @@ function getDeveloperSidebarZhCN() { function getGuideSidebarEnUS() { return [ - { - text: 'Nezha Monitoring', - children: [ - { text: 'Introduction', link: '/en_US/' } - ] - }, { text: 'Installation Manual', children: [ @@ -148,10 +136,10 @@ function getGuideSidebarEnUS() { { text: 'FAQ', children: [ - { text: 'Q1', link: '/en_US/guide/q1' }, - { text: 'Q2', link: '/en_US/guide/q2' }, - { text: 'Q3', link: '/en_US/guide/q3' }, - { text: 'Q4', link: '/en_US/guide/q4' }, + { text: 'How do I migrate my data to the new server and restore my backups?', link: '/en_US/guide/q1' }, + { text: 'Let the Agent start/on-line, and the self-test process of the problem', link: '/en_US/guide/q2' }, + { text: 'Reverse Proxy gRPC Port (support Cloudflare CDN)', link: '/en_US/guide/q3' }, + { text: 'Real-time channel disconnection/online terminal connection failure', link: '/en_US/guide/q4' }, { text: 'Q5', link: '/en_US/guide/q5' } ] } diff --git a/docs/guide/agent.md b/docs/guide/agent.md index f9890166..e39f8b1b 100644 --- a/docs/guide/agent.md +++ b/docs/guide/agent.md @@ -24,12 +24,9 @@ * 等待安装完成后返回Dashboard主页查看服务器是否上线

-## 其他方式安装Agent - -
- +## 其他方式安装Agent ### Linux安装Agent ---- + * 首先在管理面板中添加一台服务器 * 在被控服务器中,运行脚本(位于中国大陆的服务器请使用镜像): ```bash @@ -38,7 +35,7 @@ curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh ``` * 选择“安装监控Agent” * 输入通信域名,如:”data.example.com“ -* 输入面板通信端口,默认为5555 +* 输入面板通信端口(RPC端口),默认为5555 * 输入Agent密钥,Agent密钥在管理面板中添加服务器时生成,可以在管理面板中的“主机”页中找到 * 等待安装完成后返回Dashboard主页查看服务器是否上线
@@ -89,7 +86,7 @@ restart() {

## 自定义Agent监控项目 ---- + #### 自定义监控的网卡和硬盘分区 * 执行 `/opt/nezha/agent/nezha-agent --edit-agent-config` 来选择自定义的网卡和分区,然后重启 Agent 即可生效 diff --git a/docs/guide/notifications.md b/docs/guide/notifications.md index 09a4b3c6..5f9642cb 100644 --- a/docs/guide/notifications.md +++ b/docs/guide/notifications.md @@ -1 +1,95 @@ -# 通知 \ No newline at end of file +哪吒监控支持对服务器的负载、CPU、内存、硬盘、带宽、流量、月流量、进程数、连接数进行监控,并在其中某项达到用户设定值时发送报警通知 +
+
+## 灵活的通知方式 +`#NEZHA#` 是面板消息占位符,面板触发通知时会自动用实际消息替换占位符 + +Body 内容是`JSON` 格式的:**当请求类型为 FORM 时**,值为 `key:value` 的形式,`value` 里面可放置占位符,通知时会自动替换。**当请求类型为 JSON 时** 只会简单进行字符串替换后直接提交到`URL`。 + +URL 里面也可放置占位符,请求时会进行简单的字符串替换。 + +你可以参考以下的通知方式示例,也可以根据自己的需求灵活设置推送方式 + + - server酱示例 + + - 名称:server 酱 + - URL:https://sc.ftqq.com/SCUrandomkeys.send?text=#NEZHA# + - 请求方式: GET + - 请求类型: 默认 + - Body: 空 + + - wxpusher 示例,需要关注你的应用 + + - 名称: wxpusher + - URL:http://wxpusher.zjiecode.com/api/send/message + - 请求方式: POST + - 请求类型: JSON + - Body: `{"appToken":"你的appToken","topicIds":[],"content":"#NEZHA#","contentType":"1","uids":["你的uid"]}` + + - Telegram 示例 [@haitau](https://github.com/haitau) 贡献 + + - 名称:telegram 机器人消息通知 + - URL:https://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&text=#NEZHA# + - 请求方式: GET + - 请求类型: 默认 + - Body: 空 + - 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 对话可获得。 + +
+
+ +## 报警规则说明 + +### 基本规则 + +- type:可选取一个或多个类型,如在一个规则中选择了多个类型,需要**同时满足**所有选择的类型才会触发通知(可参考后面的示例) + - `cpu`、`memory`、`swap`、`disk` + - `net_in_speed` 入站网速、`net_out_speed` 出站网速、`net_all_speed` 双向网速、`transfer_in` 入站流量、`transfer_out` 出站流量、`transfer_all` 双向流量 + - `offline` 离线监控 + - `load1`、`load5`、`load15` 负载 + - `process_count` 进程数 _目前取线程数占用资源太多,暂时不支持_ + - `tcp_conn_count`、`udp_conn_count` 连接数 +- duration:持续数秒,数秒内采样记录 30% 以上触发阈值才会报警(防数据插针) +- min 或 max: + - 流量、网速类数值 为字节(1KB=1024B,1MB = 1024\*1024B) + - 内存、硬盘、CPU 以占用百分比计数 + - 离线监控无需设置此项 +- cover: + - `0` 监控所有,通过 `ignore` 忽略特定服务器 + - `1` 忽略所有,通过 `ignore` 监控特定服务器 + 例如:`[{"type":"offline","duration":10, "cover":0, "ignore":{"5": true}}]` +- ignore: 选择忽略特定服务器,搭配 `cover` 使用,内容为服务器id和布尔值,例如:`{"1": true, "2":false}` + +**完整示例:** +:::tip +添加一个离线报警 + + - 名称:离线通知 + - 规则:`[{"Type":"offline","Duration":10}]` + - 启用:√ +::: + +:::tip +添加一个监控 CPU 持续 10s 超过 50% **且** 内存持续 20s 占用低于 20% 的报警 + + - 名称:CPU+内存 + - 规则:`[{"Type":"cpu","Min":0,"Max":50,"Duration":10},{"Type":"memory","Min":20,"Max":0,"Duration":20}]` + - 启用:√ +::: +
+ +### 特殊:任意周期流量报警 + +可以用作月流量报警 + +- type: + - `transfer_in_cycle` 周期内的入站流量 + - `transfer_out_cycle` 周期内的出站流量 + - `transfer_all_cycle` 周期内双向流量和 +- cycle_start: 统计周期开始日期(可以是你机器计费周期的开始日期),时间格式为RFC3339,例如北京时间为`2022-01-11T08:00:00.00+08:00` +- cycle_interval:每隔多少个周期单位(例如,周期单位为天,该值为 7,则代表每隔 7 天统计一次) +- cycle_unit 统计周期单位,默认`hour`,可选(`hour`, `day`, `week`, `month`, `year`) +- min/max、cover、ignore 参考基本规则配置 + +示例: ID 为 3 的服务器(ignore 里面定义),以每月 15 号为统计周期,周期内统计的出站月流量达到 1TB 时报警 `[{"type":"transfer_out_cycle","max":1000000000000,"cycle_start":"2022-01-11T08:00:00.00+08:00","cycle_interval":1,"cycle_unit":"month","cover":1,"ignore":{"3":true}}]` + ![7QKaUx.md.png](https://s4.ax1x.com/2022/01/13/7QKaUx.md.png) \ No newline at end of file diff --git a/docs/guide/q1.md b/docs/guide/q1.md index e8b12d9c..1f9eb116 100644 --- a/docs/guide/q1.md +++ b/docs/guide/q1.md @@ -1 +1,5 @@ -# 问题1 \ No newline at end of file +#### 如何进行数据迁移、备份恢复? + +1. 先运行一键脚本,选择 `停止面板` +2. 在旧服务器中打包 `/opt/nezha` 文件夹,复制到新环境相同位置解压 +3. 在新环境中运行一键脚本,选择 `启动面板` \ No newline at end of file diff --git a/docs/guide/q2.md b/docs/guide/q2.md index a5ef732c..827a197d 100644 --- a/docs/guide/q2.md +++ b/docs/guide/q2.md @@ -1 +1,4 @@ -# 问题2 \ No newline at end of file +#### Agent 启动/上线 问题自检流程 +1. 直接执行 `/opt/nezha/agent/nezha-agent -s 面板IP或非CDN域名:面板RPC端口 -p Agent密钥 -d` 查看日志是否是因为 DNS、网络不佳导致超时(timeout) +2. `nc -v 域名/IP 面板RPC端口` 或者 `telnet 域名/IP 面板RPC端口` 来检验是否是网络问题,检查本机与面板服务器的出入站防火墙,如果无法判断问题可借助 提供的端口检查工具进行检测。 +3. 如果上面步骤检测正常,Agent 正常上线,尝试关闭 SELinux,[如何关闭 SELinux?](https://www.google.com/search?q=%E5%85%B3%E9%97%ADSELINUX) \ No newline at end of file diff --git a/docs/guide/q3.md b/docs/guide/q3.md index 555d1765..00eafc2f 100644 --- a/docs/guide/q3.md +++ b/docs/guide/q3.md @@ -1 +1,52 @@ -# 问题3 \ No newline at end of file +#### 反向代理 gRPC 端口(支持 Cloudflare CDN) +使用 Nginx 或者 Caddy 反向代理 gRPC + +- Nginx 配置 + +```nginx +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + server_name data.example.com; # 你的 Agent 连接 Dashboard 的域名 + + ssl_certificate /data/letsencrypt/fullchain.pem; # 你的域名证书路径 + ssl_certificate_key /data/letsencrypt/key.pem; # 你的域名私钥路径 + + underscores_in_headers on; + + location / { + grpc_read_timeout 300s; + grpc_send_timeout 300s; + grpc_pass grpc://localhost:5555; + } +} +``` + +- Caddy 配置 + +``` +data.example.com:443 { # 你的 Agent 连接 Dashboard 的域名 + reverse_proxy { + to localhost:5555 + transport http { + versions h2c 2 + } + } +} +``` + +Dashboard 面板端配置 + +- 首先登录面板进入管理后台 打开设置页面,在 `未接入CDN的面板服务器域名/IP` 中填入上一步在 Nginx 或 Caddy 中配置的域名 比如 `data.example.com` ,并保存。 +- 然后在面板服务器中,打开 /opt/nezha/dashboard/data/config.yaml 文件,将 `proxygrpcport` 修改为 Nginx 或 Caddy 监听的端口,比如上一步设置的 `443` ;因为我们在 Nginx 或 Caddy 中开启了 SSL/TLS,所以需要将 `tls` 设置为 `true` ;修改完成后重启面板。 + +Agent 端配置 + +- 登录面板管理后台,复制一键安装命令,在对应的服务器上面执行一键安装命令重新安装 agent 端即可。 + +开启 Cloudflare CDN(可选) + +根据 Cloudflare gRPC 的要求:gRPC 服务必须侦听 443 端口 且必须支持 TLS 和 HTTP/2。 +所以如果需要开启 CDN,必须在配置 Nginx 或者 Caddy 反向代理 gRPC 时使用 443 端口,并配置证书(Caddy 会自动申请并配置证书)。 + +- 登录 Cloudflare,选择使用的域名。打开 `网络` 选项将 `gRPC` 开关打开,打开 `DNS` 选项,找到 Nginx 或 Caddy 反代 gRPC 配置的域名的解析记录,打开橙色云启用 CDN。 diff --git a/docs/guide/q4.md b/docs/guide/q4.md index 605deeff..56de175e 100644 --- a/docs/guide/q4.md +++ b/docs/guide/q4.md @@ -1 +1,3 @@ -# 问题4 \ No newline at end of file +#### 实时通道断开/在线终端连接失败 ++ 如果你使用了CDN,请确认CDN服务商提供WebSocket服务,并且已开启WebSocket ++ 确认你的反代规则中针对 /ws,/terminal 路径的 WebSocket 进行了特别配置,你可以 [点击这里](/guide/dashboard.html#配置反向代理) 查看反向代理配置 \ No newline at end of file diff --git a/docs/guide/services.md b/docs/guide/services.md index 0ad17041..c61a9a1d 100644 --- a/docs/guide/services.md +++ b/docs/guide/services.md @@ -1 +1,3 @@ -# 服务 \ No newline at end of file +服务监控:HTTP、SSL证书、ping、TCP 端口等 + +进入 `/服务` 页面点击新建监控即可,表单下面有相关说明。 \ No newline at end of file diff --git a/docs/guide/settings.md b/docs/guide/settings.md index ad5c73bd..04f7d1d4 100644 --- a/docs/guide/settings.md +++ b/docs/guide/settings.md @@ -1 +1,81 @@ -# 设置 \ No newline at end of file +## 多语言 +哪吒监控目前支持以下语言: + ++ 简体中文 ++ English ++ Español + +[![Crowdin](https://badges.crowdin.net/nezha/localized.svg)](https://crowdin.com/project/nezha) +我们欢迎您贡献更多语言 +
+ +## 自定义代码 +改LOGO、改色调、加统计代码等。 + +:::warning +自定义代码仅在游客首页生效。 +::: +
+ +#### 默认主题更改进度条颜色示例 + + ```html + + ``` + +#### DayNight 主题更改进度条颜色、修改页脚示例(来自 [@hyt-allen-xu](https://github.com/hyt-allen-xu)) + + ```html + + + ``` + +#### 默认主题修改 LOGO、修改页脚示例(来自 [@iLay1678](https://github.com/iLay1678)) + + ```html + + + ``` + +#### hotaru 主题更改背景图片示例 + + ```html + + ``` diff --git a/docs/guide/tasks.md b/docs/guide/tasks.md index fb191124..706a1b3a 100644 --- a/docs/guide/tasks.md +++ b/docs/guide/tasks.md @@ -1 +1,3 @@ -# 任务 \ No newline at end of file +计划任务:备份脚本、服务重启,等定期运维任务。 + +使用此功能可以定期结合 restic、rclone 给服务器备份,或者定期重启某项服务来重置网络连接。 \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 15a80f32..cce3cfc0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,7 +2,7 @@ home: true heroImage: https://raw.githubusercontent.com/naiba/nezha/master/resource/static/brand.svg heroText: 哪吒监控 -tagline: 一个开源的轻量服务器和网站监控、运维工具 +tagline: 一个开源、轻量的服务器和网站监控、运维工具 actionText: 开始使用 → actionLink: /guide/dashboard features: