dashboard v0.12.29 Windows Agent 一键安装

新增win一键 (need PS 管理员权限)

Co-authored-by: dysf888 <47450409+dysf888@users.noreply.github.com>
This commit is contained in:
naiba 2022-04-29 09:09:11 +08:00 committed by GitHub
commit fea86994f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 60 additions and 6 deletions

View File

@ -4,7 +4,7 @@
<br>
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
<br><br>
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.12.28&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.8.3-brightgreen?style=for-the-badge&logo=linux">
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.12.29&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.8.3-brightgreen?style=for-the-badge&logo=linux">
<br>
<br>
<p>:trollface: <b>哪吒监控</b> 一站式轻监控轻运维系统。支持系统状态、HTTP(SSL 证书变更、即将到期、到期)、TCP、Ping 监控报警,计划任务和在线终端。</p>
@ -38,6 +38,18 @@ CN=true sudo ./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
```
![image](https://user-images.githubusercontent.com/47450409/165829132-cb1ab16a-7b22-4c5f-9fdf-89d140cf7e40.png)
*如遇此图请选择 Y*
### Agent 自定义
#### 自定义监控的网卡和硬盘分区

View File

@ -44,7 +44,9 @@
data-tooltip="点击复制安装命令">
<i class="linux icon"></i>
</button>
<button class="ui icon mini button" data-tooltip="尚未支持请下载release手动安装">
<button class="ui icon green mini button"
data-clipboard-text="{{if $.Conf.GRPCHost}}set-ExecutionPolicy RemoteSigned;Invoke-WebRequest https://raw.githubusercontent.com/naiba/nezha/master/script/install.ps1 -OutFile C:\install.ps1;powershell.exe C:\install.ps1 {{$.Conf.GRPCHost}}:{{if $.Conf.ProxyGRPCPort}}{{$.Conf.ProxyGRPCPort}}{{else}}{{$.Conf.GRPCPort}}{{end}} {{$server.Secret}}{{if $.Conf.TLS}} --tls{{end}}{{else}}请先在设置页面配置 未接入CDN的面板服务器域名/IP{{end}}"
data-tooltip="点击复制安装命令">
<i class="windows icon"></i>
</button>
<button class="ui icon mini button" data-tooltip="尚未支持请下载release手动安装">
@ -130,4 +132,4 @@
})
}
</script>
{{end}}
{{end}}

40
script/install.ps1 Normal file
View File

@ -0,0 +1,40 @@
#Get server and key
param($server, $key)
# Download latest release from github
$repo = "naiba/nezha"
# x86 or x64
if ([System.Environment]::Is64BitOperatingSystem) {
$file = "nezha-agent_windows_amd64.zip"
}
else {
$file = "nezha-agent_windows_386.zip"
}
$releases = "https://api.github.com/repos/$repo/releases"
Write-Host "Determining latest nezha release" -BackgroundColor DarkGreen -ForegroundColor White
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$tag = (Invoke-WebRequest -Uri $releases -UseBasicParsing | ConvertFrom-Json)[0].tag_name
$download = "https://github.com/$repo/releases/download/$tag/$file"
Invoke-WebRequest $download -OutFile "C:\nezha.zip"
#使用nssm安装服务
Invoke-WebRequest "http://nssm.cc/release/nssm-2.24.zip" -OutFile "C:\nssm.zip"
#解压
Expand-Archive "C:\nezha.zip" -DestinationPath "C:\temp" -Force
Expand-Archive "C:\nssm.zip" -DestinationPath "C:\temp" -Force
if (!(Test-Path "C:\nezha")) { New-Item -Path "C:\nezha" -type directory }
#整理文件
Move-Item -Path "C:\temp\nezha-agent.exe" -Destination "C:\nezha\nezha.exe"
if ($file = "nezha-agent_windows_amd64.zip") {
Move-Item -Path "C:\temp\nssm-2.24\win64\nssm.exe" -Destination "C:\nezha\nssm.exe"
}
else {
Move-Item -Path "C:\temp\nssm-2.24\win32\nssm.exe" -Destination "C:\nezha\nssm.exe"
}
#清理垃圾
Remove-Item "C:\nezha.zip"
Remove-Item "C:\nssm.zip"
Remove-Item "C:\temp" -Recurse
#安装部分
C:\nezha\nssm.exe install nezha C:\nezha\nezha.exe -s $server -p $key -d
C:\nezha\nssm.exe start nezha
#enjoy
Write-Host "Enjoy It!" -BackgroundColor DarkGreen -ForegroundColor Red

View File

@ -125,7 +125,7 @@ before_show_menu() {
install_base() {
(command -v git >/dev/null 2>&1 && command -v curl >/dev/null 2>&1 && command -v wget >/dev/null 2>&1 && command -v tar >/dev/null 2>&1) ||
(install_soft curl wget git tar)
(install_soft curl wget git unzip)
}
install_soft() {
@ -205,7 +205,7 @@ install_agent() {
echo -e "${red}Release 下载失败,请检查本机能否连接 ${GITHUB_URL}${plain}"
return 0
fi
tar xf nezha-agent_linux_${os_arch}.zip &&
unzip nezha-agent_linux_${os_arch}.zip &&
mv nezha-agent $NZ_AGENT_PATH &&
rm -rf nezha-agent_linux_${os_arch}.zip README.md

View File

@ -12,7 +12,7 @@ import (
"github.com/naiba/nezha/pkg/utils"
)
var Version = "v0.12.28" // !!记得修改 README 中的 badge 版本!!
var Version = "v0.12.29" // !!记得修改 README 中的 badge 版本!!
var (
Conf *model.Config