diff --git a/internal/device/parser.go b/internal/device/parser.go index 5790414..ced7432 100644 --- a/internal/device/parser.go +++ b/internal/device/parser.go @@ -35,11 +35,12 @@ func DiscoverDevice(ip string, deviceType models.DeviceType, username, password Type: deviceType, } - // 创建SSH客户端 - 默认启用不安全加密算法以兼容老旧设备 + // 创建SSH客户端 - 默认启用不安全加密算法以兼容老旧设备,增加超时时间 client := sshclient.NewClient(sshclient.Config{ Host: ip, Username: username, Password: password, + Timeout: 30 * time.Second, // 增加到30秒,防止大输出超时 InsecureCiphers: true, // 启用旧版加密算法支持 }) @@ -75,15 +76,17 @@ func DiscoverDevice(ip string, deviceType models.DeviceType, username, password // 获取命令列表 commands := parser.GetCommands() - // 执行命令 - 允许部分命令失败 + // 执行命令 - 允许部分命令失败,增加详细日志 outputs := make([]string, 0, len(commands)) - for _, cmd := range commands { + for i, cmd := range commands { + fmt.Printf("[PARSER] Executing command %d/%d: %s\n", i+1, len(commands), cmd) output, err := client.ExecuteCommand(cmd) if err != nil { // 记录警告但继续执行其他命令 fmt.Printf("Warning: command '%s' failed: %v\n", cmd, err) outputs = append(outputs, "") } else { + fmt.Printf("[PARSER] Command '%s' returned %d bytes\n", cmd, len(output)) outputs = append(outputs, output) } }