ソースを参照

Fix: 添加命令间500毫秒延迟防止H3C设备速率限制

- 每个SSH命令执行后等待500毫秒
- 解决命令交替返回0字节的问题
Your Name 1 ヶ月 前
コミット
c311a570da
1 ファイル変更6 行追加1 行削除
  1. 6 1
      internal/device/parser.go

+ 6 - 1
internal/device/parser.go

@@ -77,9 +77,14 @@ func DiscoverDevice(ip string, deviceType models.DeviceType, username, password
 	// 获取命令列表
 	commands := parser.GetCommands()
 
-	// 执行命令 - 允许部分命令失败,增加详细日志
+	// 执行命令 - 允许部分命令失败,增加详细日志和延迟防止设备速率限制
 	outputs := make([]string, 0, len(commands))
 	for i, cmd := range commands {
+		// 每个命令之间等待500毫秒,防止设备速率限制导致返回空数据
+		if i > 0 {
+			time.Sleep(500 * time.Millisecond)
+		}
+		
 		fmt.Printf("[PARSER] Executing command %d/%d: %s\n", i+1, len(commands), cmd)
 		output, err := client.ExecuteCommand(cmd)
 		if err != nil {