Files
membank/auto-check/README.md
张威33321 0a0e5fdf7f 0822
2026-08-22 17:19:47 +08:00

94 lines
2.8 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.
# auto-check
自动化目标扫描 + SSH 登录 + 远程压力测试工具(支持 CIDR 和 IP 范围格式)。
基于 [cobra](https://github.com/spf13/cobra) 命令行框架。
## 功能
| 子命令 | 功能 | 包 |
|--------|------|-----|
| `run` | 完整流程:发现 → SSH → 压测 | 全部 |
| `scan` | 仅扫描目标,发现存活设备 | `pkg/discovery` |
| `stress` | 对指定 IP 执行压力测试 | `pkg/stress` + `pkg/sshclient` |
## 安装
```bash
go build -o auto-check .
```
## 使用
```bash
# 查看帮助
./auto-check --help
# 仅扫描目标CIDR 格式)
./auto-check scan --cidr 192.168.1.0/24
# 仅扫描目标IP 范围格式)
./auto-check scan --cidr 192.168.1.1-192.168.1.100
# 对指定主机执行压力测试
./auto-check stress --ips 192.168.1.100,192.168.1.101 --user root --password secret --stress cpu,memory,disk
# 完整流程(扫描 → SSH → 压测)
./auto-check run --cidr 192.168.1.0/24 --user root --password secret --stress cpu,memory,disk
```
## 全局标志
| 标志 | 默认值 | 说明 |
|------|--------|------|
| `--cidr` | `192.168.1.0/24` | 目标网段或 IP 范围 (CIDR 或 起始IP-结束IP) |
| `--user` | `root` | SSH 用户名 |
| `--password` | _(空)_ | SSH 密码 |
| `--key` | _(空)_ | SSH 私钥路径 |
| `--port` | `22` | SSH 端口 |
| `--timeout` | `3s` | 超时 |
| `--concurrency` | `50` | 并发扫描数 |
| `--report` | _(自动生成)_ | 报告输出路径 |
## 子命令标志
### `run` / `stress`
| 标志 | 默认值 | 说明 |
|------|--------|------|
| `--stress` | `cpu,memory` | 压测类型: `cpu`, `memory`, `disk`, `memnative`, `full` |
| `--duration` | `30s` | 持续时间 |
| `--threads` | `4` | 线程数 |
| `--ips` | _(必填,仅stress)_ | 目标 IP (逗号分隔) |
## 压力测试类型
| 类型 | 工具 | 说明 |
|------|------|------|
| `cpu` | stress-ng | CPU 全方法压测 |
| `memory` | stress-ng | 内存压测 |
| `disk` | stress-ng | 磁盘IO混合压测 |
| `memnative` | stressapptest | 内存稳定性精压(数据完整性校验) |
| `full` | stress-ng | CPU+内存+磁盘 三合一综合压测 |
## 项目结构
```
auto-check/
├── main.go
├── cmd/
│ └── root.go # 所有子命令
├── pkg/
│ ├── discovery/ # 设备发现
│ ├── sshclient/ # SSH 客户端
│ ├── stress/ # 压力测试
│ │ ├── types.go # 类型定义
│ │ ├── tools.go # 工具检测 + 监控
│ │ ├── runners.go # 压测实现
│ │ └── runner.go # 调度器
│ └── report/ # 报告模块
├── go.mod
└── README.md
```
> ⚠️ 请在授权设备上使用,未授权扫描/测试可能违反法律法规。