新增 auto-check 工具:网段扫描+SSH登录+压力测试永久循环工作流

- pkg/discovery: TCP端口探测存活主机,ARP表解析MAC作为设备唯一标识
- pkg/sshclient: SSH连接(密码/密钥认证)与远程命令执行
- pkg/stress: stress-ng/stressapptest 压测(cpu/memory/disk/memnative/full)+温度与dmesg监控
- pkg/report: 检测报告生成(文本/JSON)
- pkg/workflow: 永久循环工作流(间隔可配),MAC唯一标识设备,增量测试+状态变化打印
- pkg/config: YAML分类配置(scan/ssh/stress/report/workflow)
- cmd: cobra入口,仅 --config 指定配置文件
This commit is contained in:
张威33321
2026-08-10 20:30:23 +08:00
parent c6d83a4a94
commit 19f6050147
18 changed files with 2077 additions and 0 deletions

33
auto-check/cmd/run.go Normal file
View File

@@ -0,0 +1,33 @@
package cmd
import (
"fmt"
"auto-check/pkg/config"
"auto-check/pkg/workflow"
"github.com/spf13/cobra"
)
var runCmd = &cobra.Command{
Use: "run",
Short: "启动永久循环工作流:扫描 → 增量压测 → 状态打印",
RunE: func(cmd *cobra.Command, args []string) error {
// 从配置文件加载配置
cfg, err := config.Load(configFile)
if err != nil {
return err
}
fmt.Printf(" [配置] 加载完成: 网段=%s 间隔=%v 压测=%s\n",
cfg.Scan.CIDR, cfg.Workflow.Interval, cfg.Stress.Types)
// 启动工作流(永久循环)
ctx := workflow.NewContext()
ctx.Config = *cfg
return workflow.Loop(ctx)
},
}
func init() {
rootCmd.AddCommand(runCmd)
}