Files
xugou/agent/README.md
T
2025-05-05 23:37:15 +08:00

105 lines
2.1 KiB
Markdown
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.
# Xugou Agent
Xugou Agent 是一个系统监控客户端,用于收集系统信息并上报到监控服务器。它可以收集 CPU、内存、磁盘、网络等系统信息,并定期上报到指定的服务器。
## 功能特点
- 收集系统基本信息(主机名、操作系统、平台等)
- 监控 CPU 使用率和负载
- 监控内存使用情况
- 监控磁盘使用情况
- 监控网络接口状态
- 支持自定义收集间隔
- 支持配置文件和环境变量配置
## 计划
- 压缩二进制文件,最小化体积,我希望能够在更多的低功耗平台运行
## 安装
### 从源码构建
```bash
git clone https://github.com/zaunist/xugou.git
cd agent
go build -o xugou-agent
```
## 使用方法
### 基本命令
```bash
# 显示帮助信息
./xugou-agent --help
# 显示版本信息
./xugou-agent version
# 启动客户端
./xugou-agent start
```
### 配置选项
可以通过命令行参数、配置文件或环境变量来配置 Xugou Agent:
#### 命令行参数
```bash
# 指定服务器地址
./xugou-agent --server https://monitor.example.com
# 指定 API 令牌
./xugou-agent --token YOUR_API_TOKEN
# 指定日志级别
./xugou-agent --log-level debug
# 指定收集间隔(秒)
./xugou-agent start --interval 30
# 指定http 代理
./xugou-agent start --proxy http://proxy.example.com:8080
```
#### 环境变量
所有配置选项也可以通过环境变量设置,环境变量名称格式为 `XUGOU_*`:
```bash
export XUGOU_SERVER=https://monitor.example.com
export XUGOU_TOKEN=YOUR_API_TOKEN
export XUGOU_INTERVAL=60
export XUGOU_LOG_LEVEL=info
```
## 开发
### 依赖项
- Go 1.18 或更高版本
- github.com/spf13/cobra
- github.com/spf13/viper
- github.com/shirou/gopsutil/v3
### 项目结构
```
agent/
├── cmd/
│ └── agent/ # 命令行命令
│ ├── root.go # 根命令
│ ├── start.go # 启动命令
│ └── version.go # 版本命令
├── pkg/
│ ├── collector/ # 数据收集器
│ └── reporter/ # 数据上报器
└── main.go # 程序入口
```
## 许可证
MIT