Introduction
Actually, installing the Nezha agent only requires running some one-click code in SSH, but there is currently no one-click code for OpenWrt. The official documentation for installing OpenWrt is provided here: https://nezha.wiki/guide/agent.html, which also suggests several installation methods.
Installation
This section introduces the third method. The official documentation has already explained how to install it. Here, I mainly record the steps and provide a visual guide so that beginners can easily install the official binary agent client.
Step 1: First, add a new server in the Nezha management backend to obtain the communication key.
If you remember the server information, you can directly copy the key, or you can copy the one-click installation command to extract it yourself.
Step 2: Go to the official GitHub repository to download the latest releases: https://github.com/nezhahq/agent/releases
Step 3: Unzip and upload it to the root directory of OpenWrt.
You can also directly use wget in SSH: https://github.com/nezhahq/agent/releases/download/v0.20.3/nezha-agent_linux_amd64.zip to download, and then use unzip to extract.
Step 4: Log into the SSH backend and run chmod +x /root/nezha-agent
to grant execution permissions.
Step 5: Use vi to create /etc/init.d/nezha-service
, enter `i` to enter edit mode, and then copy the following code into it:
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
start_service() {
procd_open_instance
procd_set_param command /root/nezha-agent -s your.url.com:6666 -p KEYOkYDIGecf9rBvJP -d
procd_set_param respawn
procd_close_instance
}
stop_service() {
killall nezha-agent
}
restart() {
stop
sleep 2
start
}
Finally, press esc and type wq to exit.
Remember to modify the communication address, port, and key above.
Step 6: Run chmod +x /etc/init.d/nezha-service
to grant execution permissions.
Step 7: Add it to the system services and start the service: /etc/init.d/nezha-service enable && /etc/init.d/nezha-service start
Return to the probe panel to see that it is now online.
Conclusion
Actually, following the official documentation step by step will suffice; this is just to assist beginners. If you encounter any unclear points, feel free to leave a message for me.