Fix: 清理SSH客户端代码并增加命令延迟到2秒
- 移除所有残留的Shell模式代码 - 使用简洁的session.Run模式 - 命令间延迟从500ms增加到2秒,防止H3C速率限制 - 超时时间设置为30秒
This commit is contained in:
@@ -80,9 +80,9 @@ func DiscoverDevice(ip string, deviceType models.DeviceType, username, password
|
||||
// 执行命令 - 允许部分命令失败,增加详细日志和延迟防止设备速率限制
|
||||
outputs := make([]string, 0, len(commands))
|
||||
for i, cmd := range commands {
|
||||
// 每个命令之间等待500毫秒,防止设备速率限制导致返回空数据
|
||||
// 每个命令之间等待2秒,防止H3C交换机速率限制导致返回空数据或执行失败
|
||||
if i > 0 {
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
|
||||
fmt.Printf("[PARSER] Executing command %d/%d: %s\n", i+1, len(commands), cmd)
|
||||
|
||||
Reference in New Issue
Block a user