Files
aiops/agent/deploy/install.ps1
T
Logan.Li e0d652d211 feat: 完善堡垒机与 Agent 智能运维能力
- 支持 Windows Agent 构建、安装脚本和统一上报协议

- 增强 RDP 剪贴板、虚拟盘和文件传输能力

- 新增 AIOps 上下文工具、告警 RCA trace 落库和回放接口

- 重构 docs 模块文档并补充终端、堡垒机、监控、AI Agent 设计
2026-07-05 23:49:36 +08:00

72 lines
2.2 KiB
PowerShell

param(
[Parameter(Mandatory = $true)]
[string]$Server,
[Parameter(Mandatory = $false)]
[string]$Token = "none",
[Parameter(Mandatory = $false)]
[int]$Interval = 10
)
$ErrorActionPreference = "Stop"
function Assert-Admin {
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
$principal = New-Object Security.Principal.WindowsPrincipal($identity)
if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
throw "请使用管理员 PowerShell 执行安装脚本"
}
}
function Normalize-Server([string]$Value) {
return $Value.TrimEnd("/")
}
Assert-Admin
$Server = Normalize-Server $Server
$InstallDir = "C:\Program Files\AIOps"
$LogDir = "C:\ProgramData\AIOps\logs"
$AgentPath = Join-Path $InstallDir "aiops-agent.exe"
$ServiceName = "AIOpsAgent"
$BinaryUrl = "$Server/agent/aiops-agent-windows-amd64.exe"
Write-Host ""
Write-Host "AIOps Agent Windows 安装"
Write-Host "Server: $Server"
Write-Host "Binary: $BinaryUrl"
Write-Host ""
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
New-Item -ItemType Directory -Force -Path $LogDir | Out-Null
$Tmp = Join-Path $env:TEMP "aiops-agent-windows-amd64.exe"
Invoke-WebRequest -Uri $BinaryUrl -OutFile $Tmp -UseBasicParsing
Copy-Item -Force $Tmp $AgentPath
$Args = "-server `"$Server`" -interval $Interval -token `"$Token`""
$Existing = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
if ($Existing) {
Stop-Service -Name $ServiceName -Force -ErrorAction SilentlyContinue
sc.exe delete $ServiceName | Out-Null
Start-Sleep -Seconds 1
}
New-Service -Name $ServiceName `
-DisplayName "AIOps Agent" `
-Description "AIOps Windows monitoring and task agent" `
-BinaryPathName "`"$AgentPath`" $Args" `
-StartupType Automatic | Out-Null
Start-Service -Name $ServiceName
Start-Sleep -Seconds 2
$Status = (Get-Service -Name $ServiceName).Status
if ($Status -ne "Running") {
throw "服务启动失败,当前状态: $Status"
}
Write-Host ""
Write-Host "安装成功,AIOps Agent 已作为 Windows 服务启动"
Write-Host "查看状态: Get-Service AIOpsAgent"
Write-Host "停止服务: Stop-Service AIOpsAgent"
Write-Host "卸载服务: Stop-Service AIOpsAgent; sc.exe delete AIOpsAgent"