136 lines
38 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Install Agent using one-click script | Nezha Monitoring</title>
<meta name="description" content="Nezha Monitoring is a lightweight O&M tool">
<link rel="stylesheet" href="/assets/style.0b9f658b.css">
<link rel="modulepreload" href="/assets/chunks/AlgoliaSearchBox.e3095d59.js">
<link rel="modulepreload" href="/assets/app.31af427a.js">
<link rel="modulepreload" href="/assets/en_US_guide_agent.md.e8bc4117.lean.js">
<meta name="twitter:title" content="Install Agent using one-click script | Nezha Monitoring">
<meta property="og:title" content="Install Agent using one-click script | Nezha Monitoring">
</head>
<body>
<div id="app"><!--[--><div class="theme"><header class="nav-bar" data-v-675d8756><div class="sidebar-button" data-v-675d8756><svg class="icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z" class></path></svg></div><a class="nav-bar-title" href="/en_US/" aria-label="Nezha Monitoring, back to home" data-v-675d8756 data-v-cc01ef16><!----> Nezha Monitoring</a><div class="flex-grow" data-v-675d8756></div><div class="nav" data-v-675d8756><nav class="nav-links" data-v-675d8756 data-v-eab3edfe><!--[--><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item active" href="/en_US/" data-v-b8818f8c>User Guide <!----></a></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item" href="/en_US/case/index" data-v-b8818f8c>Community Projects <!----></a></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item" href="/en_US/developer/index" data-v-b8818f8c>Development Manual <!----></a></div></div><!--]--><div class="item" data-v-eab3edfe><div class="nav-dropdown-link" data-v-eab3edfe data-v-56bf3a3f><button class="button" data-v-56bf3a3f><span class="button-text" data-v-56bf3a3f>Languages</span><span class="right button-arrow" data-v-56bf3a3f></span></button><ul class="dialog" data-v-56bf3a3f><!--[--><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item" href="/guide/agent.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>简体中文</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item active" href="/en_US/guide/agent.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>English</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><!--]--></ul></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item isExternal" href="https://github.com/nezhahq/nezhahq.github.io" target="_blank" rel="noopener noreferrer" data-v-b8818f8c>GitHub <svg class="icon outbound" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15" data-v-b8818f8c><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div></div></nav></div><!--[--><!--[--><div class="algolia-search-box" id="docsearch"></div><!--]--><!--]--></header><aside class="sidebar" data-v-83e92a68><nav class="nav-links nav" data-v-83e92a68 data-v-eab3edfe><!--[--><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item active" href="/en_US/" data-v-b8818f8c>User Guide <!----></a></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item" href="/en_US/case/index" data-v-b8818f8c>Community Projects <!----></a></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item" href="/en_US/developer/index" data-v-b8818f8c>Development Manual <!----></a></div></div><!--]--><div class="item" data-v-eab3edfe><div class="nav-dropdown-link" data-v-eab3edfe data-v-56bf3a3f><button class="button" data-v-56bf3a3f><span class="button-text" data-v-56bf3a3f>Languages</span><span class="right button-arrow" data-v-56bf3a3f></span></button><ul class="dialog" data-v-56bf3a3f><!--[--><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item" href="/guide/agent.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>简体中文</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><li class="dialog-item" data-v-56bf3a3f><div class="nav-dropdown-link-item" data-v-56bf3a3f data-v-bbc27490><a class="item active" href="/en_US/guide/agent.html" data-v-bbc27490><span class="arrow" data-v-bbc27490></span><span class="text" data-v-bbc27490>English</span><span class="icon" data-v-bbc27490><!----></span></a></div></li><!--]--></ul></div></div><div class="item" data-v-eab3edfe><div class="nav-link" data-v-eab3edfe data-v-b8818f8c><a class="item isExternal" href="https://github.com/nezhahq/nezhahq.github.io" target="_blank" rel="noopener noreferrer" data-v-b8818f8c>GitHub <svg class="icon outbound" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15" data-v-b8818f8c><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div></div></nav><!--[--><!--]--><ul class="sidebar-links" data-v-83e92a68><!--[--><li class="sidebar-link"><p class="sidebar-link-item">Installation Manual</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/dashboard">Install Dashboard</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item active" href="/en_US/guide/agent">Install Agent</a><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="#install-agent-using-one-click-script">Install Agent using one-click script</a><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="#preparation">Preparation</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="#one-click-installation-on-linux-ubuntu-debian-centos">One-click installation on Linux (Ubuntu, Debian, CentOS)</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="#one-click-installation-on-windows">One-click installation on Windows</a><!----></li></ul></li><li class="sidebar-link"><a class="sidebar-link-item" href="#other-ways-to-install-agent">Other ways to install Agent</a><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="#installing-agent-on-linux-ubuntu-debian-centos">Installing Agent on Linux (Ubuntu, Debian, CentOS)</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="#installing-agent-on-other-linux-such-as-alpine-use-oprec-not-systemd">Installing Agent on other Linux (such as alpine use oprec not systemd)</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="#installing-agent-on-windows">Installing Agent on Windows</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="#installing-agent-on-macos">Installing Agent on MacOS</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="#installing-agent-on-openwrt">Installing Agent on OpenWRT</a><!----></li></ul></li><li class="sidebar-link"><a class="sidebar-link-item" href="#faq">FAQ</a><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="#is-there-a-docker-image-for-agent">Is there a Docker image for Agent?</a><!----></li></ul></li></ul></li></ul></li><li class="sidebar-link"><p class="sidebar-link-item">Admin Panel</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/servers">Servers</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/services">Services</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/tasks">Tasks</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/notifications">Notifications</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/settings">Settings</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/api">API</a><!----></li></ul></li><li class="sidebar-link"><p class="sidebar-link-item">FAQ</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q2">Agent cannot start/on-line. Steps to review logs and troubleshoot</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q3">Steps for Reverse Proxy gRPC Ports (support Cloudflare CDN)</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q4">Real-time channel disconnection/online terminal connection failure</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q5">Steps to perform data migration, backup and recovery</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q6">Steps to set up monthly reset data statistics</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/q7">Steps to customize Agent monitoring items</a><!----></li></ul></li><li class="sidebar-link"><p class="sidebar-link-item">Troubleshooting Guide</p><ul class="sidebar-links"><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/dashboardq">Dashboard</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/agentq">Agent</a><!----></li><li class="sidebar-link"><a class="sidebar-link-item" href="/en_US/guide/loginq">Login</a><!----></li></ul></li><!--]--></ul><!--[--><!--]--></aside><div class="sidebar-mask"></div><main class="page" data-v-7eddb2c4><div class="container" data-v-7eddb2c4><!--[--><!--]--><div style="position:relative;" class="content" data-v-7eddb2c4><div><p><strong>The service in the monitored server is called Agent. This document will describe how to install the Agent on the monitored server and connect it with Dashboard</strong><br><br></p><h2 id="install-agent-using-one-click-script" tabindex="-1">Install Agent using one-click script <a class="header-anchor" href="#install-agent-using-one-click-script" aria-hidden="true">#</a></h2><p>Nezha Monitoring now supports one-click installation of the Agent on Windows and Linux. Follow the steps in this document and you can easily deploy it on your server<br><br></p><h3 id="preparation" tabindex="-1">Preparation <a class="header-anchor" href="#preparation" aria-hidden="true">#</a></h3><p>First of all, you need to set up the communication domain name in the settings page of the admin panel, this domain name can not connect to the CDN, here is the sample communication domain name &quot;<a href="http://data.example.com" target="_blank" rel="noopener noreferrer">data.example.com</a>&quot; mentioned earlier for demonstration<br> Enter the administration panel, go to the &quot;Settings&quot; page, in the item &quot;CDN Bypassed Domain/IP &quot;, fill in the communication domain name, and then click &quot;Save&quot;<br><br></p><h3 id="one-click-installation-on-linux-ubuntu-debian-centos" tabindex="-1">One-click installation on Linux (Ubuntu, Debian, CentOS) <a class="header-anchor" href="#one-click-installation-on-linux-ubuntu-debian-centos" aria-hidden="true">#</a></h3><ul><li>First add a server in the admin panel</li><li>Click on the green Linux icon button next to the newly added server and copy the one-click installation command</li><li>Run the copied one-click installation command on the monitored server, wait for the installation to complete, and then return to the Dashboard home page to see if the server is online.<br><br></li></ul><h3 id="one-click-installation-on-windows" tabindex="-1">One-click installation on Windows <a class="header-anchor" href="#one-click-installation-on-windows" aria-hidden="true">#</a></h3><ul><li>First add a server in the admin panel</li><li>Click on the green Linux icon button next to the newly added server and copy the one-click installation command</li><li>Login to Windows Server, open PowerShell, and run the copied installation command in PowerShell</li><li>If you encounter the prompt &quot;Implement Policy Change&quot; please select Y</li><li>Wait for the installation to complete and return to the Dashboard home page to see if the server is online<br><br><br><br></li></ul><h2 id="other-ways-to-install-agent" tabindex="-1">Other ways to install Agent <a class="header-anchor" href="#other-ways-to-install-agent" aria-hidden="true">#</a></h2><br><h3 id="installing-agent-on-linux-ubuntu-debian-centos" tabindex="-1">Installing Agent on Linux (Ubuntu, Debian, CentOS) <a class="header-anchor" href="#installing-agent-on-linux-ubuntu-debian-centos" aria-hidden="true">#</a></h3><ul><li>First add a server in the admin panel</li><li>In the monitored server, run the script:</li></ul><div class="language-bash"><pre><code><span class="token function">curl</span> -L https://raw.githubusercontent.com/naiba/nezha/master/script/install_en.sh -o nezha.sh <span class="token operator">&amp;&amp;</span> <span class="token function">chmod</span> +x nezha.sh <span class="token operator">&amp;&amp;</span> <span class="token function">sudo</span> ./nezha.sh
</code></pre></div><ul><li><p>Select “Install_agent”</p></li><li><p>Input the communication domain name, e.g. &quot;<a href="http://data.example.com" target="_blank" rel="noopener noreferrer">data.example.com</a>&quot;</p></li><li><p>Input RPC port, default is 5555</p></li><li><p>Input the Agent Secret, which is generated when adding a server in the administration panel and can be found in the &quot; Servers &quot; page of the administration panel</p></li><li><p>Wait for the installation to complete and return to the Dashboard home page to see if the server is online<br><br></p></li></ul><h3 id="installing-agent-on-other-linux-such-as-alpine-use-oprec-not-systemd" tabindex="-1">Installing Agent on other Linux (such as alpine use oprec not systemd) <a class="header-anchor" href="#installing-agent-on-other-linux-such-as-alpine-use-oprec-not-systemd" aria-hidden="true">#</a></h3><p>Contributed by <a href="https://github.com/unknwon0054" target="_blank" rel="noopener noreferrer">unknown0054</a></p><ul><li>Edit SERVER,SECRET,TLS then run it in Shell</li></ul><div class="language-shell"><pre><code><span class="token function">cat</span> <span class="token operator">&gt;</span>/etc/init.d/nezha-agent<span class="token operator">&lt;&lt;</span> <span class="token string">EOF
#!/sbin/openrc-run
SERVER=&quot;&quot; #Dashboard address ip:port
SECRET=&quot;&quot; #SECRET
TLS=&quot;&quot; # Enable tls? yes:&quot;--tls&quot; no:&quot;&quot;
NZ_BASE_PATH=&quot;/opt/nezha&quot;
NZ_AGENT_PATH=&quot;<span class="token variable">${NZ_BASE_PATH}</span>/agent&quot;
pidfile=&quot;/run/<span class="token variable">${RC_SVCNAME}</span>.pid&quot;
command=&quot;/opt/nezha/agent/nezha-agent&quot;
command_args=&quot;-s <span class="token variable">${SERVER}</span> -p <span class="token variable">${SECRET}</span> <span class="token variable">${TLS}</span>&quot;
command_background=true
depend() {
need net
}
checkconfig() {
GITHUB_URL=&quot;github.com&quot;
if [ ! -f &quot;<span class="token variable">${NZ_AGENT_PATH}</span>/nezha-agent&quot; ]; then
if [[ <span class="token variable"><span class="token variable">$(</span><span class="token function">uname</span> -m <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">&#39;x86_64&#39;</span><span class="token variable">)</span></span> != &quot;&quot; ]]; then
os_arch=&quot;amd64&quot;
elif [[ <span class="token variable"><span class="token variable">$(</span><span class="token function">uname</span> -m <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">&#39;i386\|i686&#39;</span><span class="token variable">)</span></span> != &quot;&quot; ]]; then
os_arch=&quot;386&quot;
elif [[ <span class="token variable"><span class="token variable">$(</span><span class="token function">uname</span> -m <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">&#39;aarch64\|armv8b\|armv8l&#39;</span><span class="token variable">)</span></span> != &quot;&quot; ]]; then
os_arch=&quot;arm64&quot;
elif [[ <span class="token variable"><span class="token variable">$(</span><span class="token function">uname</span> -m <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">&#39;arm&#39;</span><span class="token variable">)</span></span> != &quot;&quot; ]]; then
os_arch=&quot;arm&quot;
elif [[ <span class="token variable"><span class="token variable">$(</span><span class="token function">uname</span> -m <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">&#39;s390x&#39;</span><span class="token variable">)</span></span> != &quot;&quot; ]]; then
os_arch=&quot;s390x&quot;
elif [[ <span class="token variable"><span class="token variable">$(</span><span class="token function">uname</span> -m <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">&#39;riscv64&#39;</span><span class="token variable">)</span></span> != &quot;&quot; ]]; then
os_arch=&quot;riscv64&quot;
fi
local version=<span class="token variable"><span class="token variable">$(</span><span class="token function">curl</span> -m <span class="token number">10</span> -sL <span class="token string">&quot;https://api.github.com/repos/naiba/nezha/releases/latest&quot;</span> <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">&quot;tag_name&quot;</span> <span class="token operator">|</span> <span class="token function">head</span> -n <span class="token number">1</span> <span class="token operator">|</span> <span class="token function">awk</span> -F <span class="token string">&quot;:&quot;</span> <span class="token string">&#39;{print $2}&#39;</span> <span class="token operator">|</span> <span class="token function">sed</span> <span class="token string">&#39;s/\&quot;//g;s/,//g;s/ //g&#39;</span><span class="token variable">)</span></span>
if [ ! -n &quot;<span class="token variable">$version</span>&quot; ]; then
version=<span class="token variable"><span class="token variable">$(</span><span class="token function">curl</span> -m <span class="token number">10</span> -sL <span class="token string">&quot;https://fastly.jsdelivr.net/gh/naiba/nezha/&quot;</span> <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">&quot;option\.value&quot;</span> <span class="token operator">|</span> <span class="token function">awk</span> -F <span class="token string">&quot;&#39;&quot;</span> <span class="token string">&#39;{print $2}&#39;</span> <span class="token operator">|</span> <span class="token function">sed</span> <span class="token string">&#39;s/naiba\/nezha@/v/g&#39;</span><span class="token variable">)</span></span>
fi
if [ ! -n &quot;<span class="token variable">$version</span>&quot; ]; then
version=<span class="token variable"><span class="token variable">$(</span><span class="token function">curl</span> -m <span class="token number">10</span> -sL <span class="token string">&quot;https://gcore.jsdelivr.net/gh/naiba/nezha/&quot;</span> <span class="token operator">|</span> <span class="token function">grep</span> <span class="token string">&quot;option\.value&quot;</span> <span class="token operator">|</span> <span class="token function">awk</span> -F <span class="token string">&quot;&#39;&quot;</span> <span class="token string">&#39;{print $2}&#39;</span> <span class="token operator">|</span> <span class="token function">sed</span> <span class="token string">&#39;s/naiba\/nezha@/v/g&#39;</span><span class="token variable">)</span></span>
fi
if [ ! -n &quot;<span class="token variable">$version</span>&quot; ]; then
echo -e &quot;Failed to get the version number, please check if the network can connect to https://api.github.com/repos/naiba/nezha/releases/latest&quot;
return 0
else
echo -e &quot;The current latest version is: <span class="token variable">${version}</span>&quot;
fi
wget -t 2 -T 10 -O nezha-agent_linux_<span class="token variable">${os_arch}</span>.zip https://<span class="token variable">${GITHUB_URL}</span>/naiba/nezha/releases/download/<span class="token variable">${version}</span>/nezha-agent_linux_<span class="token variable">${os_arch}</span>.zip &gt;/dev/null 2&gt;&amp;1
if [[ <span class="token variable">$?</span> != 0 ]]; then
echo -e &quot;Release download failed, please check if the network can connect to <span class="token variable">${GITHUB_URL}</span><span class="token variable">${plain}</span>&quot;
return 0
fi
mkdir -p <span class="token variable">$NZ_AGENT_PATH</span>
chmod 755 -R <span class="token variable">$NZ_AGENT_PATH</span>
unzip -qo nezha-agent_linux_<span class="token variable">${os_arch}</span>.zip &amp;&amp; mv nezha-agent <span class="token variable">$NZ_AGENT_PATH</span> &amp;&amp; rm -rf nezha-agent_linux_<span class="token variable">${os_arch}</span>.zip README.md
fi
if [ ! -x &quot;<span class="token variable">${NZ_AGENT_PATH}</span>/nezha-agent&quot; ]; then
chmod +x <span class="token variable">${NZ_AGENT_PATH}</span>/nezha-agent
fi
}
start_pre() {
if [ &quot;<span class="token variable">${RC_CMD}</span>&quot; != &quot;restart&quot; ]; then
checkconfig || return <span class="token variable">$?</span>
fi
}
EOF</span>
</code></pre></div><ul><li><p>Add execute permission</p><div class="language-shell"><pre><code><span class="token function">chmod</span> +x /etc/init.d/nezha-agent
</code></pre></div></li><li><p>Run Nezha-Agent</p><div class="language-shell"><pre><code>rc-service nezha-agent-hy start
</code></pre></div></li><li><p>Set self-start after boot</p><div class="language-shell"><pre><code>rc-update <span class="token function">add</span> nezha-agent
</code></pre></div></li></ul><h3 id="installing-agent-on-windows" tabindex="-1">Installing Agent on Windows <a class="header-anchor" href="#installing-agent-on-windows" aria-hidden="true">#</a></h3><ul><li>Please refer to the community article: <a href="https://nyko.me/2020/12/13/nezha-windows-client.html" target="_blank" rel="noopener noreferrer">哪吒探针 - Windows 客户端安装</a>(Chinese)<br><br></li></ul><h3 id="installing-agent-on-macos" tabindex="-1">Installing Agent on MacOS <a class="header-anchor" href="#installing-agent-on-macos" aria-hidden="true">#</a></h3><p><em><strong>This section is adapted from <a href="https://blog.mitsea.com/e796f93db38d49e4b18df234c6ee75f5" target="_blank" rel="noopener noreferrer">Mitsea Blog</a>, with permission from the original author</strong></em><br><br></p><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p>If you are prompted with &quot;macOS cannot verify this app&quot; during installation, please go to system settings to allow the app to run.</p></div><ul><li>First add a server in the admin panel</li><li>Go to the <a href="https://github.com/naiba/nezha/releases" target="_blank" rel="noopener noreferrer">Release</a> page to download the Agent binary and choose whether to download the darwin amd64 or arm64 Agent depending on the CPU architecture<br> 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</li><li>Create a new file named <code>nezha_agent.plist</code> and save it, edit the contents of the file:</li></ul><div class="language-xml"><pre><code><span class="token prolog">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</span>
<span class="token doctype"><span class="token punctuation">&lt;!</span><span class="token doctype-tag">DOCTYPE</span> <span class="token name">plist</span> <span class="token name">PUBLIC</span> <span class="token string">&quot;-//Apple//DTD PLIST 1.0//EN&quot;</span> <span class="token string">&quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>plist</span> <span class="token attr-name">version</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>1.0<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>dict</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>key</span><span class="token punctuation">&gt;</span></span>KeepAlive<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>key</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>true</span><span class="token punctuation">/&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>key</span><span class="token punctuation">&gt;</span></span>Label<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>key</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>string</span><span class="token punctuation">&gt;</span></span>nezha_agent<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>string</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>key</span><span class="token punctuation">&gt;</span></span>Program<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>key</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>string</span><span class="token punctuation">&gt;</span></span>Change the path of the Agent binary here, e.g. /Users/123/Downloads/nezha-agent<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>string</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>key</span><span class="token punctuation">&gt;</span></span>ProgramArguments<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>key</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>array</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>string</span><span class="token punctuation">&gt;</span></span>Change the path of the Agent binary here, e.g. /Users/123/Downloads/nezha-agent<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>string</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>string</span><span class="token punctuation">&gt;</span></span>--password<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>string</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>string</span><span class="token punctuation">&gt;</span></span>Communication Secret, eg: 529664783eeb23cc25<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>string</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>string</span><span class="token punctuation">&gt;</span></span>--server<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>string</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>string</span><span class="token punctuation">&gt;</span></span>Communication URL and RPC port, eg:data.example.com:5555<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>string</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>array</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>key</span><span class="token punctuation">&gt;</span></span>RunAtLoad<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>key</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>true</span><span class="token punctuation">/&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>dict</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>plist</span><span class="token punctuation">&gt;</span></span>
</code></pre></div><ul><li>Use the following command in Terminal to load the plist file into launchd<br><strong>Be sure to change the file path</strong></li></ul><div class="language-shell"><pre><code>launchctl load /Users/123/Desktop/nezha_agent.plist
</code></pre></div><ul><li>Start Service</li></ul><div class="language-shell"><pre><code>launchctl start nezha_agent
</code></pre></div><ul><li>Check if the service is running</li></ul><div class="language-shell"><pre><code>launchctl list <span class="token operator">|</span> <span class="token function">grep</span> nezha_agent
</code></pre></div><ul><li>Stop service and remove</li></ul><div class="language-shell"><pre><code>launchctl stop nezha_agent
</code></pre></div><div class="language-shell"><pre><code>launchctl remove nezha_agent
</code></pre></div><br><h3 id="installing-agent-on-openwrt" tabindex="-1">Installing Agent on OpenWRT <a class="header-anchor" href="#installing-agent-on-openwrt" aria-hidden="true">#</a></h3><p><strong>How to make the old version of OpenWRT/LEDE self-boot?</strong></p><ul><li>Please refer to the project:<br><a href="https://github.com/Erope/openwrt_nezha" target="_blank" rel="noopener noreferrer">哪吒监控 For OpenWRT</a> (Chinese) <br></li></ul><p><strong>How to make the new version of OpenWRT self-boot? By @艾斯德斯</strong></p><ul><li>First download the corresponding binary from the release, unzip the zip package and place it in <code>/root</code></li><li>Then run <code>chmod +x /root/nezha-agent</code> to give it execute access, create file <code>/etc/init.d/nezha-service</code></li></ul><div class="language-shell"><pre><code><span class="token shebang important">#!/bin/sh /etc/rc.common</span>
<span class="token assign-left variable">START</span><span class="token operator">=</span><span class="token number">99</span>
<span class="token assign-left variable">USE_PROCD</span><span class="token operator">=</span><span class="token number">1</span>
<span class="token function-name function">start_service</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
procd_open_instance
procd_set_param <span class="token builtin class-name">command</span> /root/nezha-agent -s data.example.com:5555 -p secreat -d
procd_set_param respawn
procd_close_instance
<span class="token punctuation">}</span>
<span class="token function-name function">stop_service</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
<span class="token function">killall</span> nezha-agent
<span class="token punctuation">}</span>
<span class="token function-name function">restart</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
stop
<span class="token function">sleep</span> <span class="token number">2</span>
start
<span class="token punctuation">}</span>
</code></pre></div><ul><li>Give it permission to execute: <code>chmod +x /etc/init.d/nezha-service</code></li><li>Start the service <code>/etc/init.d/nezha-service enable &amp;&amp; /etc/init.d/nezha-service start</code><br><br></li></ul><h2 id="faq" tabindex="-1">FAQ <a class="header-anchor" href="#faq" aria-hidden="true">#</a></h2><h3 id="is-there-a-docker-image-for-agent" tabindex="-1">Is there a Docker image for Agent? <a class="header-anchor" href="#is-there-a-docker-image-for-agent" aria-hidden="true">#</a></h3><p><strong>There is currently no Docker image for Agent.</strong><br> The Agent is designed to be the opposite of the Dashboard, in that the Dashboard is designed to work without affecting the server as much as possible, while the Agent needs to execute monitoring services and run commands in the server.<br> Putting the Agent in a container does continue to execute monitoring services, but features such as WebShell do not work, so we do not provide Docker image of the Agent.</p></div></div><footer class="page-footer" data-v-7eddb2c4 data-v-07c132fc><div class="edit" data-v-07c132fc><div class="edit-link" data-v-07c132fc data-v-1ed99556><a class="link" href="https://github.com/nezhahq/nezhahq.github.io/edit/main/docs/en_US/guide/agent.md" target="_blank" rel="noopener noreferrer" data-v-1ed99556>Edit this page on GitHub <svg class="icon outbound icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15" data-v-1ed99556><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div></div><div class="updated" data-v-07c132fc><p class="last-updated" data-v-07c132fc data-v-abce3432><span class="prefix" data-v-abce3432>Last Updated:</span><span class="datetime" data-v-abce3432></span></p></div></footer><div class="next-and-prev-link" data-v-7eddb2c4 data-v-38ede35f><div class="container" data-v-38ede35f><div class="prev" data-v-38ede35f><a class="link" href="/en_US/guide/dashboard" data-v-38ede35f><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon icon-prev" data-v-38ede35f><path d="M19,11H7.4l5.3-5.3c0.4-0.4,0.4-1,0-1.4s-1-0.4-1.4,0l-7,7c-0.1,0.1-0.2,0.2-0.2,0.3c-0.1,0.2-0.1,0.5,0,0.8c0.1,0.1,0.1,0.2,0.2,0.3l7,7c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3c0.4-0.4,0.4-1,0-1.4L7.4,13H19c0.6,0,1-0.4,1-1S19.6,11,19,11z"></path></svg><span class="text" data-v-38ede35f>Install Dashboard</span></a></div><div class="next" data-v-38ede35f><a class="link" href="/en_US/guide/servers" data-v-38ede35f><span class="text" data-v-38ede35f>Servers</span><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="icon icon-next" data-v-38ede35f><path d="M19.9,12.4c0.1-0.2,0.1-0.5,0-0.8c-0.1-0.1-0.1-0.2-0.2-0.3l-7-7c-0.4-0.4-1-0.4-1.4,0s-0.4,1,0,1.4l5.3,5.3H5c-0.6,0-1,0.4-1,1s0.4,1,1,1h11.6l-5.3,5.3c-0.4,0.4-0.4,1,0,1.4c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3l7-7C19.8,12.6,19.9,12.5,19.9,12.4z"></path></svg></a></div></div></div><!--[--><!--]--></div></main></div><!----><!--]--></div>
<script>__VP_HASH_MAP__ = JSON.parse("{\"case_case1.md\":\"6a48202f\",\"case_case2.md\":\"b80b7b41\",\"case_case3.md\":\"288c31d8\",\"case_case4.md\":\"f5843cd3\",\"case_index.md\":\"4fe867d6\",\"developer_index.md\":\"87fbeb7a\",\"developer_l10n.md\":\"d4a72e6d\",\"developer_theme.md\":\"0712c7d7\",\"en_us_case_case1.md\":\"a8cce32e\",\"en_us_case_case2.md\":\"b8938494\",\"en_us_case_case3.md\":\"c6bd0674\",\"en_us_case_case4.md\":\"695edab6\",\"en_us_case_index.md\":\"93820627\",\"en_us_developer_index.md\":\"900b57b7\",\"en_us_developer_l10n.md\":\"30a7b64a\",\"en_us_developer_theme.md\":\"6cc54156\",\"en_us_guide_agent.md\":\"e8bc4117\",\"en_us_guide_agentq.md\":\"bf532171\",\"en_us_guide_api.md\":\"ffef29aa\",\"en_us_guide_dashboard.md\":\"128cbc19\",\"en_us_guide_dashboardq.md\":\"f32b7fbe\",\"en_us_guide_loginq.md\":\"92c92b00\",\"en_us_guide_notifications.md\":\"a964b3ef\",\"en_us_guide_q2.md\":\"507afe99\",\"en_us_guide_q3.md\":\"aa4b4c9a\",\"en_us_guide_q4.md\":\"98945347\",\"en_us_guide_q5.md\":\"354e6c88\",\"en_us_guide_q6.md\":\"28e838cc\",\"en_us_guide_q7.md\":\"e802007a\",\"en_us_guide_servers.md\":\"eb3cd28a\",\"en_us_guide_services.md\":\"0e594e00\",\"en_us_guide_settings.md\":\"876b0741\",\"en_us_guide_tasks.md\":\"ce6bbbf0\",\"en_us_index.md\":\"9f7184ab\",\"guide_agent.md\":\"6566e255\",\"guide_agentq.md\":\"1e6dc99b\",\"guide_api.md\":\"58594611\",\"guide_dashboard.md\":\"31389ae2\",\"guide_dashboardq.md\":\"fe39b2ac\",\"guide_loginq.md\":\"1878b714\",\"guide_notifications.md\":\"4a15e25d\",\"guide_q1.md\":\"3f4f76eb\",\"guide_q2.md\":\"12654938\",\"guide_q3.md\":\"08238c54\",\"guide_q4.md\":\"39fa6f98\",\"guide_q5.md\":\"363a5156\",\"guide_q6.md\":\"64631719\",\"guide_q7.md\":\"c2aa9233\",\"guide_servers.md\":\"6f388725\",\"guide_services.md\":\"f1105b33\",\"guide_settings.md\":\"a28c4028\",\"guide_tasks.md\":\"21033202\",\"index.md\":\"ba590395\"}")</script>
<script type="module" async src="/assets/app.31af427a.js"></script>
</body>
</html>