|
|
@@ -1,6 +1,7 @@
|
|
|
package device
|
|
|
|
|
|
import (
|
|
|
+ "fmt"
|
|
|
"network-topology-discovery/pkg/models"
|
|
|
sshclient "network-topology-discovery/internal/ssh"
|
|
|
)
|
|
|
@@ -74,12 +75,17 @@ func DiscoverDevice(ip string, deviceType models.DeviceType, username, password
|
|
|
// 获取命令列表
|
|
|
commands := parser.GetCommands()
|
|
|
|
|
|
- // 执行命令
|
|
|
- outputs, err := client.ExecuteCommands(commands)
|
|
|
- if err != nil {
|
|
|
- device.ScanStatus = "failed"
|
|
|
- device.ErrorMessage = err.Error()
|
|
|
- return device, err
|
|
|
+ // 执行命令 - 允许部分命令失败
|
|
|
+ outputs := make([]string, 0, len(commands))
|
|
|
+ for _, cmd := range commands {
|
|
|
+ output, err := client.ExecuteCommand(cmd)
|
|
|
+ if err != nil {
|
|
|
+ // 记录警告但继续执行其他命令
|
|
|
+ fmt.Printf("Warning: command '%s' failed: %v\n", cmd, err)
|
|
|
+ outputs = append(outputs, "")
|
|
|
+ } else {
|
|
|
+ outputs = append(outputs, output)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 解析输出
|