add: install agent guide on openrc
This commit is contained in:
parent
b71ea0091e
commit
82ac30370b
@ -29,13 +29,104 @@ Enter the administration panel, go to the "Settings" page, in the item "CDN Bypa
|
|||||||
* In the monitored server, run the script:
|
* In the monitored server, run the script:
|
||||||
```bash
|
```bash
|
||||||
curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install_en.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh
|
curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install_en.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh
|
||||||
```
|
```
|
||||||
* Select “Install_agent”
|
* Select “Install_agent”
|
||||||
|
|
||||||
* Input the communication domain name, e.g. "data.example.com"
|
* Input the communication domain name, e.g. "data.example.com"
|
||||||
|
|
||||||
* Input RPC port, default is 5555
|
* Input RPC port, default is 5555
|
||||||
|
|
||||||
* Input the Agent Secret, which is generated when adding a server in the administration panel and can be found in the " Servers " page of the administration panel
|
* Input the Agent Secret, which is generated when adding a server in the administration panel and can be found in the " Servers " page of the administration panel
|
||||||
|
|
||||||
* Wait for the installation to complete and return to the Dashboard home page to see if the server is online
|
* Wait for the installation to complete and return to the Dashboard home page to see if the server is online
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
### Installing Agent on other Linux (such as alpine use oprec not systemd)
|
||||||
|
|
||||||
|
* edit SERVER,SECRET,TLS then run in shell
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cat >/etc/init.d/nezha-agent<< EOF
|
||||||
|
#!/sbin/openrc-run
|
||||||
|
SERVER="" #dashboard address ip:port
|
||||||
|
SECRET="" #SECRET
|
||||||
|
TLS="" # enable tls? yes:"--tls" no:""
|
||||||
|
NZ_BASE_PATH="/opt/nezha"
|
||||||
|
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
|
||||||
|
pidfile="/run/${RC_SVCNAME}.pid"
|
||||||
|
command="/opt/nezha/agent/nezha-agent"
|
||||||
|
command_args="-s ${SERVER} -p ${SECRET} ${TLS}"
|
||||||
|
command_background=true
|
||||||
|
depend() {
|
||||||
|
need net
|
||||||
|
}
|
||||||
|
checkconfig() {
|
||||||
|
GITHUB_URL="github.com"
|
||||||
|
if [ ! -f "${NZ_AGENT_PATH}/nezha-agent" ]; then
|
||||||
|
if [[ $(uname -m | grep 'x86_64') != "" ]]; then
|
||||||
|
os_arch="amd64"
|
||||||
|
elif [[ $(uname -m | grep 'i386\|i686') != "" ]]; then
|
||||||
|
os_arch="386"
|
||||||
|
elif [[ $(uname -m | grep 'aarch64\|armv8b\|armv8l') != "" ]]; then
|
||||||
|
os_arch="arm64"
|
||||||
|
elif [[ $(uname -m | grep 'arm') != "" ]]; then
|
||||||
|
os_arch="arm"
|
||||||
|
elif [[ $(uname -m | grep 's390x') != "" ]]; then
|
||||||
|
os_arch="s390x"
|
||||||
|
elif [[ $(uname -m | grep 'riscv64') != "" ]]; then
|
||||||
|
os_arch="riscv64"
|
||||||
|
fi
|
||||||
|
local version=$(curl -m 10 -sL "https://api.github.com/repos/naiba/nezha/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||||
|
if [ ! -n "$version" ]; then
|
||||||
|
version=$(curl -m 10 -sL "https://fastly.jsdelivr.net/gh/naiba/nezha/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/naiba\/nezha@/v/g')
|
||||||
|
fi
|
||||||
|
if [ ! -n "$version" ]; then
|
||||||
|
version=$(curl -m 10 -sL "https://gcore.jsdelivr.net/gh/naiba/nezha/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/naiba\/nezha@/v/g')
|
||||||
|
fi
|
||||||
|
if [ ! -n "$version" ]; then
|
||||||
|
echo -e "version get to failed, please check if the network can link https://api.github.com/repos/naiba/nezha/releases/latest"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo -e "The current latest version is: ${version}"
|
||||||
|
fi
|
||||||
|
wget -t 2 -T 10 -O nezha-agent_linux_${os_arch}.zip https://${GITHUB_URL}/naiba/nezha/releases/download/${version}/nezha-agent_linux_${os_arch}.zip >/dev/null 2>&1
|
||||||
|
if [[ $? != 0 ]]; then
|
||||||
|
echo -e "Release download failed, please check if the network can link ${GITHUB_URL}${plain}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
mkdir -p $NZ_AGENT_PATH
|
||||||
|
chmod 755 -R $NZ_AGENT_PATH
|
||||||
|
unzip -qo nezha-agent_linux_${os_arch}.zip && mv nezha-agent $NZ_AGENT_PATH && rm -rf nezha-agent_linux_${os_arch}.zip README.md
|
||||||
|
fi
|
||||||
|
if [ ! -x "${NZ_AGENT_PATH}/nezha-agent" ]; then
|
||||||
|
chmod +x ${NZ_AGENT_PATH}/nezha-agent
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
start_pre() {
|
||||||
|
if [ "${RC_CMD}" != "restart" ]; then
|
||||||
|
checkconfig || return $?
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
|
||||||
|
* add execute permission
|
||||||
|
|
||||||
|
```shell
|
||||||
|
chmod +x /etc/init.d/nezha-agent
|
||||||
|
```
|
||||||
|
|
||||||
|
* run nezha-agent
|
||||||
|
|
||||||
|
```shell
|
||||||
|
rc-service nezha-agent-hy start
|
||||||
|
```
|
||||||
|
|
||||||
|
* auto start on boot
|
||||||
|
|
||||||
|
```shell
|
||||||
|
rc-update add nezha-agent
|
||||||
|
```
|
||||||
|
|
||||||
### Installing Agent on Windows
|
### Installing Agent on Windows
|
||||||
- Please refer to the community article:
|
- Please refer to the community article:
|
||||||
@ -48,7 +139,7 @@ curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install_en.s
|
|||||||
::: warning
|
::: warning
|
||||||
If you are prompted with "macOS cannot verify this app" during installation, please go to system settings to allow the app to run.
|
If you are prompted with "macOS cannot verify this app" during installation, please go to system settings to allow the app to run.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
+ First add a server in the admin panel
|
+ First add a server in the admin panel
|
||||||
+ Go to the [Release](https://github.com/naiba/nezha/releases) page to download the Agent binary and choose whether to download the darwin amd64 or arm64 Agent depending on the CPU architecture
|
+ Go to the [Release](https://github.com/naiba/nezha/releases) page to download the Agent binary and choose whether to download the darwin amd64 or arm64 Agent depending on the CPU architecture
|
||||||
For example, download the amd64 version for Intel CPU and the arm64 version for Apple Silicon. After downloading, extract the Agent binary file, e.g. to the Download folder
|
For example, download the amd64 version for Intel CPU and the arm64 version for Apple Silicon. After downloading, extract the Agent binary file, e.g. to the Download folder
|
||||||
@ -76,27 +167,27 @@ For example, download the amd64 version for Intel CPU and the arm64 version for
|
|||||||
<true/>
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
```
|
```
|
||||||
+ Use the following command in Terminal to load the plist file into launchd
|
+ Use the following command in Terminal to load the plist file into launchd
|
||||||
**Be sure to change the file path**
|
**Be sure to change the file path**
|
||||||
```shell
|
```shell
|
||||||
launchctl load /Users/123/Desktop/nezha_agent.plist
|
launchctl load /Users/123/Desktop/nezha_agent.plist
|
||||||
```
|
```
|
||||||
+ Start Service
|
+ Start Service
|
||||||
```shell
|
```shell
|
||||||
launchctl start nezha_agent
|
launchctl start nezha_agent
|
||||||
```
|
```
|
||||||
+ Check if the service is running
|
+ Check if the service is running
|
||||||
```shell
|
```shell
|
||||||
launchctl list | grep nezha_agent
|
launchctl list | grep nezha_agent
|
||||||
```
|
```
|
||||||
+ Stop service and remove
|
+ Stop service and remove
|
||||||
```shell
|
```shell
|
||||||
launchctl stop nezha_agent
|
launchctl stop nezha_agent
|
||||||
```
|
```
|
||||||
```shell
|
```shell
|
||||||
launchctl remove nezha_agent
|
launchctl remove nezha_agent
|
||||||
```
|
```
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
### Installing Agent on OpenWRT
|
### Installing Agent on OpenWRT
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
* 在被控服务器中,运行脚本(位于中国大陆的服务器请使用镜像):
|
* 在被控服务器中,运行脚本(位于中国大陆的服务器请使用镜像):
|
||||||
```bash
|
```bash
|
||||||
curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh
|
curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh
|
||||||
```
|
```
|
||||||
如果你的被控服务器位于中国大陆,可以使用镜像:
|
如果你的被控服务器位于中国大陆,可以使用镜像:
|
||||||
````bash
|
````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
|
curl -L https://jihulab.com/nezha/nezha/-/raw/master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo CN=true ./nezha.sh
|
||||||
@ -45,6 +45,95 @@ curl -L https://jihulab.com/nezha/nezha/-/raw/master/script/install.sh -o nezha.
|
|||||||
* 等待安装完成后返回Dashboard主页查看服务器是否上线
|
* 等待安装完成后返回Dashboard主页查看服务器是否上线
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
### 在 其他Linux 如 alpine 使用 openrc 的发行版 安装 Agent
|
||||||
|
|
||||||
|
* 修改 SERVER、SECRET、TLS 然后在 shell 中 执行
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cat >/etc/init.d/nezha-agent<< EOF
|
||||||
|
#!/sbin/openrc-run
|
||||||
|
SERVER="" #dashboard 地址 ip:port
|
||||||
|
SECRET="" #SECRET
|
||||||
|
TLS="" # 是否启用 tls 是 "--tls" 否留空
|
||||||
|
NZ_BASE_PATH="/opt/nezha"
|
||||||
|
NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
|
||||||
|
pidfile="/run/${RC_SVCNAME}.pid"
|
||||||
|
command="/opt/nezha/agent/nezha-agent"
|
||||||
|
command_args="-s ${SERVER} -p ${SECRET} ${TLS}"
|
||||||
|
command_background=true
|
||||||
|
depend() {
|
||||||
|
need net
|
||||||
|
}
|
||||||
|
checkconfig() {
|
||||||
|
GITHUB_URL="github.com"
|
||||||
|
if [ ! -f "${NZ_AGENT_PATH}/nezha-agent" ]; then
|
||||||
|
if [[ $(uname -m | grep 'x86_64') != "" ]]; then
|
||||||
|
os_arch="amd64"
|
||||||
|
elif [[ $(uname -m | grep 'i386\|i686') != "" ]]; then
|
||||||
|
os_arch="386"
|
||||||
|
elif [[ $(uname -m | grep 'aarch64\|armv8b\|armv8l') != "" ]]; then
|
||||||
|
os_arch="arm64"
|
||||||
|
elif [[ $(uname -m | grep 'arm') != "" ]]; then
|
||||||
|
os_arch="arm"
|
||||||
|
elif [[ $(uname -m | grep 's390x') != "" ]]; then
|
||||||
|
os_arch="s390x"
|
||||||
|
elif [[ $(uname -m | grep 'riscv64') != "" ]]; then
|
||||||
|
os_arch="riscv64"
|
||||||
|
fi
|
||||||
|
local version=$(curl -m 10 -sL "https://api.github.com/repos/naiba/nezha/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||||
|
if [ ! -n "$version" ]; then
|
||||||
|
version=$(curl -m 10 -sL "https://fastly.jsdelivr.net/gh/naiba/nezha/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/naiba\/nezha@/v/g')
|
||||||
|
fi
|
||||||
|
if [ ! -n "$version" ]; then
|
||||||
|
version=$(curl -m 10 -sL "https://gcore.jsdelivr.net/gh/naiba/nezha/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/naiba\/nezha@/v/g')
|
||||||
|
fi
|
||||||
|
if [ ! -n "$version" ]; then
|
||||||
|
echo -e "获取版本号失败,请检查本机能否链接 https://api.github.com/repos/naiba/nezha/releases/latest"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo -e "当前最新版本为: ${version}"
|
||||||
|
fi
|
||||||
|
wget -t 2 -T 10 -O nezha-agent_linux_${os_arch}.zip https://${GITHUB_URL}/naiba/nezha/releases/download/${version}/nezha-agent_linux_${os_arch}.zip >/dev/null 2>&1
|
||||||
|
if [[ $? != 0 ]]; then
|
||||||
|
echo -e "Release 下载失败,请检查本机能否连接 ${GITHUB_URL}${plain}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
mkdir -p $NZ_AGENT_PATH
|
||||||
|
chmod 755 -R $NZ_AGENT_PATH
|
||||||
|
unzip -qo nezha-agent_linux_${os_arch}.zip && mv nezha-agent $NZ_AGENT_PATH && rm -rf nezha-agent_linux_${os_arch}.zip README.md
|
||||||
|
fi
|
||||||
|
if [ ! -x "${NZ_AGENT_PATH}/nezha-agent" ]; then
|
||||||
|
chmod +x ${NZ_AGENT_PATH}/nezha-agent
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
start_pre() {
|
||||||
|
if [ "${RC_CMD}" != "restart" ]; then
|
||||||
|
checkconfig || return $?
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
```
|
||||||
|
|
||||||
|
* 增加运行权限
|
||||||
|
|
||||||
|
```shell
|
||||||
|
chmod +x /etc/init.d/nezha-agent
|
||||||
|
```
|
||||||
|
|
||||||
|
* 运行 nezha-agent
|
||||||
|
|
||||||
|
```shell
|
||||||
|
rc-service nezha-agent-hy start
|
||||||
|
```
|
||||||
|
|
||||||
|
* 添加开机自启动
|
||||||
|
|
||||||
|
```shell
|
||||||
|
rc-update add nezha-agent
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 在 Windows 中安装Agent
|
### 在 Windows 中安装Agent
|
||||||
|
|
||||||
- 请参考社区文章:
|
- 请参考社区文章:
|
||||||
@ -85,26 +174,26 @@ curl -L https://jihulab.com/nezha/nezha/-/raw/master/script/install.sh -o nezha.
|
|||||||
<true/>
|
<true/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
```
|
```
|
||||||
+ 在 Terminal 中使用下面的命令加载 plist 文件到 launchd 里,**注意替换文件路径**
|
+ 在 Terminal 中使用下面的命令加载 plist 文件到 launchd 里,**注意替换文件路径**
|
||||||
```shell
|
```shell
|
||||||
launchctl load /Users/123/Desktop/nezha_agent.plist
|
launchctl load /Users/123/Desktop/nezha_agent.plist
|
||||||
```
|
```
|
||||||
+ 启动进程
|
+ 启动进程
|
||||||
```shell
|
```shell
|
||||||
launchctl start nezha_agent
|
launchctl start nezha_agent
|
||||||
```
|
```
|
||||||
+ 检查进程是否运行
|
+ 检查进程是否运行
|
||||||
```shell
|
```shell
|
||||||
launchctl list | grep nezha_agent
|
launchctl list | grep nezha_agent
|
||||||
```
|
```
|
||||||
+ 停止进程并移除
|
+ 停止进程并移除
|
||||||
```shell
|
```shell
|
||||||
launchctl stop nezha_agent
|
launchctl stop nezha_agent
|
||||||
```
|
```
|
||||||
```shell
|
```shell
|
||||||
launchctl remove nezha_agent
|
launchctl remove nezha_agent
|
||||||
```
|
```
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
### 在 OpenWRT 中安装Agent
|
### 在 OpenWRT 中安装Agent
|
||||||
|
Loading…
x
Reference in New Issue
Block a user