mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
更新README、删除旧文档、更新英文文档链接
This commit is contained in:
parent
1db4aeb65a
commit
9e744fdf3f
15
README.md
15
README.md
@ -7,14 +7,18 @@
|
||||
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.13.19&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.10.2-brightgreen?style=for-the-badge&logo=linux">
|
||||
<br>
|
||||
<br>
|
||||
<p>:trollface: <b>Nezha Monitoring</b> self-hosted lightweight monitoring and operation system. Supports system status, HTTP (SSL certificate change, upcoming expiration, expiration), TCP, Ping <b>monitoring</b> and <b>alerting</b>, execute scheduled tasks and <b>web terminal</b>.</p>
|
||||
<p>:trollface: <b>Nezha Monitoring:</b> A self-hosted, lightweight monitoring and O&M tool. Supports <b>monitoring</b> system status, HTTP (SSL certificate change, upcoming expiration, expired), TCP, Ping and supports <b>notification alarms</b>, execute scheduled tasks and <b>web terminal</b>.</p>
|
||||
</div>
|
||||
|
||||
\>> Telegram Group: [Nezha Monitoring Global (English Only)](https://t.me/nezhamonitoring_global), [哪吒监控(中文群组)](https://t.me/nezhamonitoring)
|
||||
|
||||
\>> QQ 交流群:872069346 **加群要求:已搭建好哪吒监控 & 有 2+ 服务器, 机器人自动审核**
|
||||
|
||||
\>> [Use Cases | 我们的用户](https://www.google.com/search?q=%22powered+by+Nezha+Monitoring%22+OR+%22powered+by+%E5%93%AA%E5%90%92%E7%9B%91%E6%8E%A7%22) (Google)
|
||||
\>> [Use Cases | 我们的用户](https://www.google.com/search?q=%22powered+by+Nezha+Monitoring%22+OR+%22powered+by+%E5%93%AA%E5%90%92%E7%9B%91%E6%8E%A7%22) (Google)
|
||||
## User Guide
|
||||
|
||||
- [English](https://nezhahq.github.io/en_US/index.html)
|
||||
- [中文文档](https://nezhahq.github.io/index.html)
|
||||
|
||||
| Default Theme | DayNight [@JackieSung](https://github.com/JackieSung4ev) | hotaru |
|
||||
| ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------- |
|
||||
@ -30,12 +34,7 @@ Help us improve translation [![Crowdin](https://badges.crowdin.net/nezha/localiz
|
||||
- 简体中文
|
||||
- Español
|
||||
|
||||
You can change the system language in the settings page (`/setting`) after the admin panel is installed.
|
||||
|
||||
## User Guide
|
||||
|
||||
- [English](docs/UserGuide_en.md)
|
||||
- [中文文档](https://nezhahq.github.io/)
|
||||
You can change the dashboard language in the settings page (`/setting`) after the dashboard is installed.
|
||||
|
||||
## Special Thanks
|
||||
|
||||
|
@ -1,359 +0,0 @@
|
||||
# User Guide
|
||||
|
||||
## Script for installation
|
||||
|
||||
**Recommended configuration:** Prepare _two domains_ before installation,a domain can **connect to CDN** for _Public Access_,for example (status.nai.ba). Another domain name resolves to the panel server allows the Agent can connect to the Dashboard,This domain **cannot connect to CDN** You need to make it expose the ip of the panel server directly.
|
||||
|
||||
```shell
|
||||
curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install_en.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh
|
||||
```
|
||||
|
||||
_\* Use WatchTower to automatically update the panel, and in Windows you can use nssm to configure self-start_
|
||||
|
||||
**Windows One-Click Installation Agent (please use Powershell administrator privileges)**
|
||||
|
||||
```powershell
|
||||
set-ExecutionPolicy RemoteSigned;Invoke-WebRequest https://raw.githubusercontent.com/naiba/nezha/master/script/install.ps1 -OutFile C:\install.ps1;powershell.exe C:\install.ps1 dashboard_host:grpc_port secret
|
||||
```
|
||||
|
||||
_If you encounter the prompt "Implement Policy Change" please select Y_
|
||||
|
||||
### Customize Agent
|
||||
|
||||
#### Customize the NIC and hard drive partitions to be monitored
|
||||
|
||||
Execute `/opt/nezha/agent/nezha-agent --edit-agent-config` to select a custom NIC and partition, and then restart Agent
|
||||
|
||||
#### Operating parameters
|
||||
|
||||
Execute `./nezha-agent --help` to view supported parameters,if you are already using the one-click script, you can edit `/etc/systemd/system/nezha-agent.service`,at the end of this line `ExecStart=` add:
|
||||
|
||||
- `--report-delay` System information reporting interval, default is 1 second, can be set to 3 to reduce the system resource usage on the agent side (configuration range 1-4)
|
||||
- `--skip-conn` Not monitoring the number of connections, if it is a server with a large number of connections, the CPU usage will be high. It is recommended to set this to reduce CPU usage
|
||||
- `--skip-procs` Disable monitoring the number of processes can also reduce CPU and memory usage
|
||||
- `--disable-auto-update` Disable **Automatic Update** Agent (security feature)
|
||||
- `--disable-force-update` Disable **Forced Update** Agent (security feature)
|
||||
- `--disable-command-execute` Disable execution of scheduled tasks, disallow open online terminals on the Agent side (security feature)
|
||||
- `--tls` Enable SSL/TLS encryption (If you are using nginx to reverse proxy Agent´s grpc connections, and if nginx has SSL/TLS enabled, you need to enable this configuration)
|
||||
|
||||
## Description of the functions
|
||||
|
||||
<details>
|
||||
<summary>Scheduled tasks: backup scripts, service restarts, and other scheduled tasks</summary>
|
||||
|
||||
Use this feature to periodically back up the server in combination with restic or rclone, or to periodically restart a service to reset the network connection.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Notification: Real-time monitoring of load, CPU, memory, hard disk, bandwidth, transfer, monthly transfer, number of processes, number of connections</summary>
|
||||
|
||||
#### Flexible notification methods
|
||||
|
||||
`#NEZHA#` is a panel message placeholder, and the panel will automatically replace the placeholder with the actual message when it triggers a notification
|
||||
|
||||
The content of Body is in `JSON` format:**When the request type is FORM**,the value is in the form of `key:value`,`value` can contain placeholders that will be automatically replaced when notified. **When the request type is JSON** It will only do string substitution and submit to the `URL` directly.
|
||||
|
||||
Placeholders can also be placed inside the URL, and it will perform a simple string substitution when requested.
|
||||
|
||||
Refer to the example below, it is very flexible.
|
||||
|
||||
1. Add notification method
|
||||
|
||||
- Telegram Example, contributed by [@haitau](https://github.com/haitau)
|
||||
|
||||
- Name:Telegram Robot message notification
|
||||
- URL:<https://api.telegram.org/botXXXXXX/sendMessage?chat_id=YYYYYY&text=#NEZHA>#
|
||||
- Request method: GET
|
||||
- Request type: default
|
||||
- Body: null
|
||||
- URL Parameter acquisition instructions:The XXXXXX in botXXXXXX is the token provided when you follow the official @Botfather in Telegram and enter /newbot to create a new bot. (In the line after _Use this token to access the HTTP API_). The 'bot' are essential. After creating a bot, you need to talk to the BOT in Telegram (send a random message) before you can send a message by using API. YYYYYY is Telegram user's ID, you can get it by talking to the bot @userinfobot.
|
||||
|
||||
2. Add an offline notification
|
||||
|
||||
- Name: Offline notifications
|
||||
- Rule: `[{"Type":"offline","Duration":10}]`
|
||||
- Enable: √
|
||||
|
||||
3. Add an notification when the CPU exceeds 50% for 10s **but** the memory usage is below 20% for 20s
|
||||
|
||||
- Name: CPU+RAM
|
||||
- Rule: `[{"Type":"cpu","Min":0,"Max":50,"Duration":10},{"Type":"memory","Min":20,"Max":0,"Duration":20}]`
|
||||
- Enable: √
|
||||
|
||||
#### Description of notification rules
|
||||
|
||||
##### Basic Rules
|
||||
|
||||
- Type
|
||||
- `cpu`、`memory`、`swap`、`disk`
|
||||
- `net_in_speed` Inbound speed, `net_out_speed` Outbound speed, `net_all_speed` Inbound + Outbound speed, `transfer_in` Inbound Transfer, `transfer_out` Outbound Transfer, `transfer_all` Total Transfer
|
||||
- `offline` Offline monitoring
|
||||
- `load1`、`load5`、`load15` load
|
||||
- `process_count` Number of processes _Currently, counting the number of processes takes up too many resources and is not supported at the moment_
|
||||
- `tcp_conn_count`、`udp_conn_count` Number of connections
|
||||
- duration:Lasting for a few seconds, the notification will only be triggered when the sampling record reaches 30% or more within a few seconds
|
||||
- min/max
|
||||
- Transfer, network speed, and other values of the same type. Unit is byte (1KB=1024B,1MB = 1024\*1024B)
|
||||
- Memory, hard disk, CPU. units are usage percentages
|
||||
- No setup required for offline monitoring
|
||||
- cover `[{"type":"offline","duration":10, "cover":0, "ignore":{"5": true}}]`
|
||||
- `0` Cover all, use `ignore` to ignore specific servers
|
||||
- `1` Ignore all, use `ignore` to monitoring specific servers
|
||||
- ignore: `{"1": true, "2":false}` to ignore specific servers, use with `cover`
|
||||
|
||||
##### Special: Any-cycle transfer notification
|
||||
|
||||
Can be used as monthly transfer notificatin
|
||||
|
||||
- type
|
||||
- transfer_in_cycle Inbound transfer during the cycle
|
||||
- transfer_out_cycle Outbound transfer during the cycle
|
||||
- transfer_all_cycle The sum of inbound and outbound transfer during the cycle
|
||||
- cycle_start Start date of the statistical cycle (can be the start date of your server's billing cycle), the time format is RFC3339, for example, the format in Beijing time zone is`2022-01-11T08:00:00.00+08:00`
|
||||
- cycle_interval Interval time cycle (For example, if the cycle is in days and the value is 7, it means that the statistics are counted every 7 days)
|
||||
- cycle_unit Statistics cycle unit, default `hour`, optional(`hour`, `day`, `week`, `month`, `year`)
|
||||
- min/max、cover、ignore Please refer to the basic rules to configure
|
||||
- Example: The server with ID 3 (defined in the `ignore`) is counted on the 15th of each month, and a notification is triggered when the monthly outbound traffic reaches 1TB during the cycle. `[{"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)
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Service monitoring: HTTP, SSL certificate, ping, TCP port, etc.</summary>
|
||||
|
||||
Just go to the `/service` page and click on Add Service Monitor, there are instructions on the form.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Custom code: change logo, change color tone, add statistics code, etc.</summary>
|
||||
|
||||
**Effective only on the visitor's home page.**
|
||||
|
||||
- Example of changing the default theme progress bar color
|
||||
|
||||
```html
|
||||
<style>
|
||||
.ui.fine.progress> .bar {
|
||||
background-color: pink !important;
|
||||
}
|
||||
</style>
|
||||
```
|
||||
|
||||
- Example of modifying DayNight theme progress bar color and footer (by [@hyt-allen-xu](https://github.com/hyt-allen-xu))
|
||||
|
||||
```html
|
||||
<style>
|
||||
.ui.fine.progress> .progress-bar {
|
||||
background-color: #00a7d0 !important;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
window.onload = function(){
|
||||
var footer=document.querySelector("div.footer-container")
|
||||
footer.innerHTML="©2021 "your name" & Powered by "your name"
|
||||
footer.style.visibility="visible"
|
||||
}
|
||||
</script>
|
||||
```
|
||||
|
||||
- Example of modifying the logo of the default theme, modifying the footer (by [@iLay1678](https://github.com/iLay1678))
|
||||
|
||||
```html
|
||||
<style>
|
||||
.right.menu>a{
|
||||
visibility: hidden;
|
||||
}
|
||||
.footer .is-size-7{
|
||||
visibility: hidden;
|
||||
}
|
||||
.item img{
|
||||
visibility: hidden;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
window.onload = function(){
|
||||
var avatar=document.querySelector(".item img")
|
||||
var footer=document.querySelector("div.is-size-7")
|
||||
footer.innerHTML="Powered by YOUR NAME"
|
||||
footer.style.visibility="visible"
|
||||
avatar.src="Your square logo link"
|
||||
avatar.style.visibility="visible"
|
||||
}
|
||||
</script>
|
||||
```
|
||||
|
||||
- Example of modifying the background image of hotaru theme
|
||||
|
||||
```html
|
||||
<style>
|
||||
.hotaru-cover {
|
||||
background: url(https://s3.ax1x.com/2020/12/08/DzHv6A.jpg) center;
|
||||
}
|
||||
</style>
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## FAQ
|
||||
|
||||
<details>
|
||||
<summary>How do I migrate my data to the new server and restore my backups?</summary>
|
||||
|
||||
1. First use the one-click script and select `Stop Panel`
|
||||
2. Compress the `/opt/nezha` folder to the same path as the new server
|
||||
3. Using the one-click script, select `Launch Panel`
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Let the Agent start/on-line, and the self-test process of the problem</summary>
|
||||
|
||||
1. Execute `/opt/nezha/agent/nezha-agent -s IP/Domin(Panel IP or Domain not connected to CDN):port(Panel RPC port) -p secret(Agent Secret) -d` Check the logs to see if the timeout is due to a DNS problem or poor network
|
||||
2. `nc -v domain/IP port(Panel RPC port)` or `telnet domain/IP port(Panel RPC port)` to check if it' s a network problem, check the inbound and outbound firewall between the local machine and the panel server, if you can' t determine the problem you can check it with the port checking tool provided by <https://port.ping.pe/>.
|
||||
3. If the above steps work and the Agent is online, please try to turn off SELinux on the panel server. [How to close SELinux?](https://www.google.com/search?q=How+to+close+SELinux)
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>How to make the old version of OpenWRT/LEDE self-boot?</summary>
|
||||
|
||||
Refer to this project: <https://github.com/Erope/openwrt_nezha>
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>How to make the new version of OpenWRT self-boot? By @艾斯德斯</summary>
|
||||
|
||||
First download the corresponding binary from the release, unzip the zip package and place it in `/root`, then execute `chmod +x /root/nezha-agent` to give it execute access, create file `/etc/init.d/nezha-service`:
|
||||
|
||||
```shell
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
start_service() {
|
||||
procd_open_instance
|
||||
procd_set_param command /root/nezha-agent -s Domin/IP:port -p screat -d
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
killall nezha-agent
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
sleep 2
|
||||
start
|
||||
}
|
||||
```
|
||||
|
||||
Give it permission to execute `chmod +x /etc/init.d/nezha-service` then start the service `/etc/init.d/nezha-service enable && /etc/init.d/nezha-service start`
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Real-time channel disconnection/online terminal connection failure</summary>
|
||||
|
||||
Using a reverse proxy requires special configuration of the WebSocket for the `/ws` and `/terminal` paths to support real-time server status updates and **WebSSH**
|
||||
|
||||
- Nginx(Aapanel):Add the following code to your nginx configuration file
|
||||
|
||||
```nginx
|
||||
server{
|
||||
|
||||
#Some original configurations
|
||||
#server_name blablabla...
|
||||
|
||||
location ~ ^/(ws|terminal/.+)$ {
|
||||
proxy_pass http://ip:site access port;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
#Others, such as location blablabla...
|
||||
}
|
||||
```
|
||||
|
||||
If you're not using Aapanel, add this code to the `server{}`:
|
||||
|
||||
```nginx
|
||||
location / {
|
||||
proxy_pass http://ip:port(Access port);
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
```
|
||||
|
||||
- CaddyServer v1(v2 no special configuration required)
|
||||
|
||||
```Caddyfile
|
||||
proxy /ws http://ip:8008 {
|
||||
websocket
|
||||
}
|
||||
proxy /terminal/* http://ip:8008 {
|
||||
websocket
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Reverse Proxy gRPC Port (support Cloudflare CDN)</summary>
|
||||
Use Nginx or Caddy to reverse proxy gRPC
|
||||
|
||||
- Nginx configuration files
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name ip-to-dashboard.nai.ba; # The domain name where the Agent connects to Dashboard
|
||||
|
||||
ssl_certificate /data/letsencrypt/fullchain.pem; # Your domain certificate path
|
||||
ssl_certificate_key /data/letsencrypt/key.pem; # Your domain's private key path
|
||||
|
||||
underscores_in_headers on;
|
||||
|
||||
location / {
|
||||
grpc_read_timeout 300s;
|
||||
grpc_send_timeout 300s;
|
||||
grpc_pass grpc://localhost:5555;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- Caddy configuration files
|
||||
|
||||
```Caddyfile
|
||||
ip-to-dashboard.nai.ba:443 { # The domain name where the Agent connects to Dashboard
|
||||
reverse_proxy {
|
||||
to localhost:5555
|
||||
transport http {
|
||||
versions h2c 2
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Dashboard Panel Configuration
|
||||
|
||||
- First login to the panel and enter the admin panel, go to the settings page, fill in the `CDN Bypassed Domain/IP` with the domain name you configured in Nginx or Caddy, for example `ip-to-dashboard.nai.ba`, and save it.
|
||||
- Then open the /opt/nezha/dashboard/data/config.yaml file in the panel server and change `proxygrpcport` to the port that Nginx or Caddy is listening on, such as `443` as set in the previous step. Since we have SSL/TLS enabled in Nginx or Caddy, we need to set `tls` to `true`, restart the panel when you are done.
|
||||
|
||||
Agent Configuration
|
||||
|
||||
- Log in to the admin panel, copy the one-click install command, and execute the one-click install command on the corresponding server to reinstall the agent.
|
||||
|
||||
Enable Cloudflare CDN (optional)
|
||||
|
||||
According to Cloudflare gRPC requirements: gRPC services must listen on port 443 and must support TLS and HTTP/2.
|
||||
So if you need to enable CDN, you must use port 443 when configuring Nginx or Caddy reverse proxy gRPC and configure the certificate (Caddy will automatically apply and configure the certificate).
|
||||
|
||||
- Log in to Cloudflare and select the domain you are using. Go to the `Network` page and turn on the `gRPC` switch, then go to the `DNS` page, find the resolution record of the domain with gRPC configuration, and turn on the orange cloud icon to enable CDN.
|
||||
|
||||
</details>
|
@ -1,398 +0,0 @@
|
||||
<div align="center">
|
||||
<br>
|
||||
<img width="250" style="max-width:80%" src="../resource/static/brand.svg" title="哪吒监控 Nezha Monitoring">
|
||||
<br>
|
||||
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
||||
<br>
|
||||
<br>
|
||||
<p>:trollface: <b>哪吒监控</b> 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,计划任务和在线终端。</p>
|
||||
</div>
|
||||
|
||||
## 安装脚本
|
||||
|
||||
**推荐配置:** 安装前准备 _两个域名_,一个可以 **接入 CDN** 作为 _公开访问_,比如 (status.nai.ba);另外一个解析到面板服务器作为 Agent 连接 Dashboard 使用,**不能接入 CDN** 直接暴露面板主机 IP,比如(ip-to-dashboard.nai.ba)。
|
||||
|
||||
```shell
|
||||
curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh
|
||||
```
|
||||
|
||||
国内镜像加速:
|
||||
|
||||
```shell
|
||||
curl -L https://fastly.jsdelivr.net/gh/naiba/nezha@master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo CN=true ./nezha.sh
|
||||
```
|
||||
|
||||
_\* 使用 WatchTower 可以自动更新面板,Windows 终端可以使用 nssm 配置自启动_
|
||||
|
||||
**Windows 一键安装 Agent (请使用 Powershell 管理员权限)**
|
||||
|
||||
```powershell
|
||||
set-ExecutionPolicy RemoteSigned;Invoke-WebRequest https://raw.githubusercontent.com/naiba/nezha/master/script/install.ps1 -OutFile C:\install.ps1;powershell.exe C:\install.ps1 dashboard_host:grpc_port secret
|
||||
```
|
||||
|
||||
_如遇到确认「执行策略变更」请选择 Y_
|
||||
|
||||
### Agent 自定义
|
||||
|
||||
#### 自定义监控的网卡和硬盘分区
|
||||
|
||||
执行 `/opt/nezha/agent/nezha-agent --edit-agent-config` 来选择自定义的网卡和分区,然后重启 Agent 即可
|
||||
|
||||
#### 运行参数
|
||||
|
||||
通过执行 `./nezha-agent --help` 查看支持的参数,如果你使用一键脚本,可以编辑 `/etc/systemd/system/nezha-agent.service`,在 `ExecStart=` 这一行的末尾加上
|
||||
|
||||
- `--report-delay` 系统信息上报的间隔,默认为 1 秒,可以设置为 3 来进一步降低 agent 端系统资源占用(配置区间 1-4)
|
||||
- `--skip-conn` 不监控连接数,如果 机场/连接密集型机器 CPU占用较高,推荐设置
|
||||
- `--skip-procs` 不监控进程数,也可以降低 agent 占用
|
||||
- `--disable-auto-update` 禁止 **自动更新** Agent(安全特性)
|
||||
- `--disable-force-update` 禁止 **强制更新** Agent(安全特性)
|
||||
- `--disable-command-execute` 禁止在 Agent 机器上执行定时任务、打开在线终端(安全特性)
|
||||
- `--tls` 启用 SSL/TLS 加密(使用 nginx 反向代理 Agent 的 grpc 连接,并且 nginx 开启 SSL/TLS 时,需要启用该项配置)
|
||||
|
||||
## 功能说明
|
||||
|
||||
<details>
|
||||
<summary>计划任务:备份脚本、服务重启,等定期运维任务。</summary>
|
||||
|
||||
使用此功能可以定期结合 restic、rclone 给服务器备份,或者定期重启某项服务来重置网络连接。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>报警通知:负载、CPU、内存、硬盘、带宽、流量、月流量、进程数、连接数实时监控。</summary>
|
||||
|
||||
#### 灵活的通知方式
|
||||
|
||||
`#NEZHA#` 是面板消息占位符,面板触发通知时会自动替换占位符到实际消息
|
||||
|
||||
Body 内容是`JSON` 格式的:**当请求类型为 FORM 时**,值为 `key:value` 的形式,`value` 里面可放置占位符,通知时会自动替换。**当请求类型为 JSON 时** 只会简单进行字符串替换后直接提交到`URL`。
|
||||
|
||||
URL 里面也可放置占位符,请求时会进行简单的字符串替换。
|
||||
|
||||
参考下方的示例,非常灵活。
|
||||
|
||||
1. 添加通知方式
|
||||
|
||||
- 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 对话可获得。
|
||||
|
||||
2. 添加一个离线报警
|
||||
|
||||
- 名称:离线通知
|
||||
- 规则:`[{"Type":"offline","Duration":10}]`
|
||||
- 启用:√
|
||||
|
||||
3. 添加一个监控 CPU 持续 10s 超过 50% **且** 内存持续 20s 占用低于 20% 的报警
|
||||
|
||||
- 名称:CPU+内存
|
||||
- 规则:`[{"Type":"cpu","Min":0,"Max":50,"Duration":10},{"Type":"memory","Min":20,"Max":0,"Duration":20}]`
|
||||
- 启用:√
|
||||
|
||||
#### 报警规则说明
|
||||
|
||||
##### 基本规则
|
||||
|
||||
- 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 `[{"type":"offline","duration":10, "cover":0, "ignore":{"5": true}}]`
|
||||
- `0` 监控所有,通过 `ignore` 忽略特定服务器
|
||||
- `1` 忽略所有,通过 `ignore` 监控特定服务器
|
||||
- ignore: `{"1": true, "2":false}` 选择忽略特定服务器,搭配 `cover` 使用
|
||||
|
||||
##### 特殊:任意周期流量报警
|
||||
|
||||
可以用作月流量报警
|
||||
|
||||
- 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)
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>服务监控:HTTP、SSL证书、ping、TCP 端口等。</summary>
|
||||
|
||||
进入 `/服务` 页面点击新建监控即可,表单下面有相关说明。
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>自定义代码:改LOGO、改色调、加统计代码等。</summary>
|
||||
|
||||
**仅在游客首页生效。**
|
||||
|
||||
- 默认主题更改进度条颜色示例
|
||||
|
||||
```html
|
||||
<style>
|
||||
.ui.fine.progress> .bar {
|
||||
background-color: pink !important;
|
||||
}
|
||||
</style>
|
||||
```
|
||||
|
||||
- DayNight 主题更改进度条颜色、修改页脚示例(来自 [@hyt-allen-xu](https://github.com/hyt-allen-xu))
|
||||
|
||||
```html
|
||||
<style>
|
||||
.ui.fine.progress> .progress-bar {
|
||||
background-color: #00a7d0 !important;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
window.onload = function(){
|
||||
var footer=document.querySelector("div.footer-container")
|
||||
footer.innerHTML="©2021 你的名字 & Powered by 你的名字"
|
||||
footer.style.visibility="visible"
|
||||
}
|
||||
</script>
|
||||
```
|
||||
|
||||
- 默认主题修改 LOGO、修改页脚示例(来自 [@iLay1678](https://github.com/iLay1678))
|
||||
|
||||
```html
|
||||
<style>
|
||||
.right.menu>a{
|
||||
visibility: hidden;
|
||||
}
|
||||
.footer .is-size-7{
|
||||
visibility: hidden;
|
||||
}
|
||||
.item img{
|
||||
visibility: hidden;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
window.onload = function(){
|
||||
var avatar=document.querySelector(".item img")
|
||||
var footer=document.querySelector("div.is-size-7")
|
||||
footer.innerHTML="Powered by 你的名字"
|
||||
footer.style.visibility="visible"
|
||||
avatar.src="你的方形logo地址"
|
||||
avatar.style.visibility="visible"
|
||||
}
|
||||
</script>
|
||||
```
|
||||
|
||||
- hotaru 主题更改背景图片示例
|
||||
|
||||
```html
|
||||
<style>
|
||||
.hotaru-cover {
|
||||
background: url(https://s3.ax1x.com/2020/12/08/DzHv6A.jpg) center;
|
||||
}
|
||||
</style>
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## 常见问题
|
||||
|
||||
<details>
|
||||
<summary>如何进行数据迁移、备份恢复?</summary>
|
||||
|
||||
1. 先使用一键脚本 `停止面板`
|
||||
2. 打包 `/opt/nezha` 文件夹,到新环境相同位置
|
||||
3. 使用一键脚本 `启动面板`
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Agent 启动/上线 问题自检流程</summary>
|
||||
|
||||
1. 直接执行 `/opt/nezha/agent/nezha-agent -s 面板IP或非CDN域名:面板RPC端口 -p Agent密钥 -d` 查看日志是否是因为 DNS、网络不佳导致超时(timeout)
|
||||
2. `nc -v 域名/IP 面板RPC端口` 或者 `telnet 域名/IP 面板RPC端口` 来检验是否是网络问题,检查本机与面板服务器的出入站防火墙,如果无法判断问题可借助 <https://port.ping.pe/> 提供的端口检查工具进行检测。
|
||||
3. 如果上面步骤检测正常,Agent 正常上线,尝试关闭 SELinux,[如何关闭 SELinux?](https://www.google.com/search?q=%E5%85%B3%E9%97%ADSELINUX)
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>如何使 旧版OpenWRT/LEDE 自启动?</summary>
|
||||
|
||||
参考此项目: <https://github.com/Erope/openwrt_nezha>
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>如何使 新版OpenWRT 自启动?来自 @艾斯德斯</summary>
|
||||
|
||||
首先在 release 下载对应的二进制解压 zip 包后放置到 `/root`,然后 `chmod +x /root/nezha-agent` 赋予执行权限,然后创建 `/etc/init.d/nezha-service`:
|
||||
|
||||
```shell
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
start_service() {
|
||||
procd_open_instance
|
||||
procd_set_param command /root/nezha-agent -s 面板网址:接收端口 -p 唯一秘钥 -d
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
killall nezha-agent
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
sleep 2
|
||||
start
|
||||
}
|
||||
```
|
||||
|
||||
赋予执行权限 `chmod +x /etc/init.d/nezha-service` 然后启动服务 `/etc/init.d/nezha-service enable && /etc/init.d/nezha-service start`
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>实时通道断开/在线终端连接失败</summary>
|
||||
|
||||
使用反向代理时需要针对 `/ws`,`/terminal` 路径的 WebSocket 进行特别配置以支持实时更新服务器状态和 **WebSSH**。
|
||||
|
||||
- Nginx(宝塔):在你的 nginx 配置文件中加入以下代码
|
||||
|
||||
```nginx
|
||||
server{
|
||||
|
||||
#原有的一些配置
|
||||
#server_name blablabla...
|
||||
|
||||
location ~ ^/(ws|terminal/.+)$ {
|
||||
proxy_pass http://ip:站点访问端口;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
#其他的 location blablabla...
|
||||
}
|
||||
```
|
||||
|
||||
如果非宝塔,还要在 `server{}` 中添加上这一段
|
||||
|
||||
```nginx
|
||||
location / {
|
||||
proxy_pass http://ip:站点访问端口;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
```
|
||||
|
||||
- CaddyServer v1(v2 无需特别配置)
|
||||
|
||||
```Caddyfile
|
||||
proxy /ws http://ip:8008 {
|
||||
websocket
|
||||
}
|
||||
proxy /terminal/* http://ip:8008 {
|
||||
websocket
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>反向代理 gRPC 端口(支持 Cloudflare CDN)</summary>
|
||||
使用 Nginx 或者 Caddy 反向代理 gRPC
|
||||
|
||||
- Nginx 配置
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
server_name ip-to-dashboard.nai.ba; # 你的 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 配置
|
||||
|
||||
```Caddyfile
|
||||
ip-to-dashboard.nai.ba:443 { # 你的 Agent 连接 Dashboard 的域名
|
||||
reverse_proxy {
|
||||
to localhost:5555
|
||||
transport http {
|
||||
versions h2c 2
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Dashboard 面板端配置
|
||||
|
||||
- 首先登录面板进入管理后台 打开设置页面,在 `未接入CDN的面板服务器域名/IP` 中填入上一步在 Nginx 或 Caddy 中配置的域名 比如 `ip-to-dashboard.nai.ba` ,并保存。
|
||||
- 然后在面板服务器中,打开 /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。
|
||||
|
||||
</details>
|
||||
|
||||
## 社区文章
|
||||
|
||||
- [哪吒探针 - Windows 客户端安装](https://nyko.me/2020/12/13/nezha-windows-client.html)
|
||||
- [哪吒监控,一个便携服务器状态监控面板搭建教程,不想拥有一个自己的探针吗?](https://haoduck.com/644.html)
|
||||
- [哪吒监控:小鸡们的最佳探针](https://www.zhujizixun.com/2843.html) _(已过时)_
|
||||
- [>>更多教程](https://www.google.com/search?q="哪吒监控"+"教程") (Google)
|
||||
|
||||
SEO **云探针 多服务器探针 云监控 多服务器云监控**
|
Loading…
Reference in New Issue
Block a user