diff --git a/internal/device/h3c.go b/internal/device/h3c.go index c2695ac..db8399b 100644 --- a/internal/device/h3c.go +++ b/internal/device/h3c.go @@ -47,11 +47,14 @@ func (p *H3CParser) Parse(device *models.Device, outputs []string) error { for _, iface := range device.Interfaces { if iface.MAC != "" { macSet[iface.MAC] = true + } else { + fmt.Printf(" Interface %s has no MAC address\n", iface.Name) } } for mac := range macSet { device.MACAddresses = append(device.MACAddresses, mac) } + fmt.Printf(" Collected %d unique MAC addresses for device %s\n", len(macSet), device.IP) } // 解析ARP表用于MAC到IP映射(允许失败) @@ -289,6 +292,7 @@ func (p *H3CParser) parseNeighbors(output string, arpTable map[string]string) [] mac := strings.TrimSpace(strings.ToLower(macParts[0])) // 保存MAC地址 currentNeighbor.RemoteMAC = mac + fmt.Printf(" Parsed neighbor MAC: %s (from line: %s)\n", mac, line) // 通过ARP表查找IP(如果有) if ip, ok := arpTable[mac]; ok { @@ -298,7 +302,11 @@ func (p *H3CParser) parseNeighbors(output string, arpTable map[string]string) [] // 如果ARP表中没有,使用MAC地址作为标识(但RemoteIP仍为空) currentNeighbor.RemoteDevice = mac } + } else { + fmt.Printf(" WARNING: Could not parse MAC from ChassisID line: %s\n", line) } + } else { + fmt.Printf(" WARNING: ChassisID line has no colon: %s\n", line) } }