💥 feat(agent)!: 添加主机监控代理首版
* 实现周期采集、快照缓存、本地 HTTP API 和主动上报 * 补齐 Linux 和 Windows 主机、网络、资源、进程和 TCP 采集 * 添加服务生命周期管理、配置加载、构建脚本和测试覆盖 BREAKING CHANGE: network.ips 拆分为 network.ipv4s 和 network.ipv6s。
This commit is contained in:
22
scripts/build-linux.sh
Executable file
22
scripts/build-linux.sh
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
OUT_DIR="${OUT_DIR:-${ROOT_DIR}/dist}"
|
||||
VERSION="${VERSION:-0.1.0}"
|
||||
GOOS_TARGET="${GOOS_TARGET:-linux}"
|
||||
GOARCH_TARGET="${GOARCH_TARGET:-amd64}"
|
||||
OUTPUT_NAME="${OUTPUT_NAME:-agent-${GOOS_TARGET}-${GOARCH_TARGET}}"
|
||||
|
||||
mkdir -p "${OUT_DIR}"
|
||||
|
||||
CGO_ENABLED="${CGO_ENABLED:-0}" \
|
||||
GOOS="${GOOS_TARGET}" \
|
||||
GOARCH="${GOARCH_TARGET}" \
|
||||
go build \
|
||||
-trimpath \
|
||||
-ldflags "-s -w -X main.version=${VERSION}" \
|
||||
-o "${OUT_DIR}/${OUTPUT_NAME}" \
|
||||
./cmd/agent
|
||||
|
||||
printf 'built %s\n' "${OUT_DIR}/${OUTPUT_NAME}"
|
||||
22
scripts/build-windows.ps1
Normal file
22
scripts/build-windows.ps1
Normal file
@@ -0,0 +1,22 @@
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$RootDir = Resolve-Path (Join-Path $PSScriptRoot "..")
|
||||
$OutDir = if ($env:OUT_DIR) { $env:OUT_DIR } else { Join-Path $RootDir "dist" }
|
||||
$Version = if ($env:VERSION) { $env:VERSION } else { "0.1.0" }
|
||||
$GoosTarget = if ($env:GOOS_TARGET) { $env:GOOS_TARGET } else { "windows" }
|
||||
$GoarchTarget = if ($env:GOARCH_TARGET) { $env:GOARCH_TARGET } else { "amd64" }
|
||||
$OutputName = if ($env:OUTPUT_NAME) { $env:OUTPUT_NAME } else { "agent-$GoosTarget-$GoarchTarget.exe" }
|
||||
|
||||
New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
|
||||
|
||||
$env:CGO_ENABLED = if ($env:CGO_ENABLED) { $env:CGO_ENABLED } else { "0" }
|
||||
$env:GOOS = $GoosTarget
|
||||
$env:GOARCH = $GoarchTarget
|
||||
|
||||
go build `
|
||||
-trimpath `
|
||||
-ldflags "-s -w -X main.version=$Version" `
|
||||
-o (Join-Path $OutDir $OutputName) `
|
||||
./cmd/agent
|
||||
|
||||
Write-Host "built $(Join-Path $OutDir $OutputName)"
|
||||
Reference in New Issue
Block a user