将代码与测试注释改为中文以符合仓库规范;新增中文部署指南、 示例配置,并完善构建脚本对 VERSION 注入的说明。 Co-authored-by: Cursor <cursoragent@cursor.com>
82 lines
1.9 KiB
Markdown
82 lines
1.9 KiB
Markdown
# MFD Monitor Agent
|
|
|
|
Single-binary host status agent implemented in Go.
|
|
|
|
## Features
|
|
|
|
- `GET /health` returns process liveness and latest snapshot metadata.
|
|
- `GET /status` returns the cached full host snapshot.
|
|
- Periodic background collection keeps HTTP responses fast.
|
|
- Optional periodic HTTP POST reporting reuses the same `HostStatus` JSON.
|
|
- Linux collectors read host, network, CPU, memory, disk, process, and TCP listener data from the OS.
|
|
- Windows and Linux service lifecycle commands are exposed through the CLI.
|
|
|
|
**完整部署说明(中文):** [docs/DEPLOYMENT.md](docs/DEPLOYMENT.md)
|
|
|
|
## Commands
|
|
|
|
```bash
|
|
agent run [-config config.json]
|
|
agent install [-config config.json] [-exe /path/to/agent]
|
|
agent uninstall [-config config.json]
|
|
agent start [-config config.json]
|
|
agent stop [-config config.json]
|
|
agent version
|
|
```
|
|
|
|
## Build
|
|
|
|
Linux:
|
|
|
|
```bash
|
|
./scripts/build-linux.sh
|
|
```
|
|
|
|
Windows PowerShell:
|
|
|
|
```powershell
|
|
.\scripts\build-windows.ps1
|
|
```
|
|
|
|
Cross-compile Windows from Linux:
|
|
|
|
```bash
|
|
GOOS_TARGET=windows GOARCH_TARGET=amd64 OUTPUT_NAME=agent-windows-amd64.exe ./scripts/build-linux.sh
|
|
```
|
|
|
|
Build outputs are written to `dist/`, which is intentionally ignored by Git.
|
|
|
|
## Configuration
|
|
|
|
Example config: [configs/example.json](configs/example.json). See [docs/DEPLOYMENT.md](docs/DEPLOYMENT.md) for defaults, environment variables, and production deployment steps.
|
|
|
|
```json
|
|
{
|
|
"host_id": "host-a",
|
|
"http": {
|
|
"listen_address": "127.0.0.1:8080"
|
|
},
|
|
"collect": {
|
|
"interval": "30s",
|
|
"timeout": "10s"
|
|
},
|
|
"report": {
|
|
"enabled": true,
|
|
"endpoint": "http://center.example.internal/agent/status",
|
|
"interval": "60s",
|
|
"timeout": "5s"
|
|
}
|
|
}
|
|
```
|
|
|
|
Environment overrides:
|
|
|
|
- `MFD_AGENT_HOST_ID`
|
|
- `MFD_AGENT_LISTEN`
|
|
- `MFD_AGENT_COLLECT_INTERVAL`
|
|
- `MFD_AGENT_COLLECT_TIMEOUT`
|
|
- `MFD_AGENT_REPORT_ENABLED`
|
|
- `MFD_AGENT_REPORT_ENDPOINT`
|
|
- `MFD_AGENT_REPORT_INTERVAL`
|
|
- `MFD_AGENT_REPORT_TIMEOUT`
|