add debug flags for arp, lldp, and snmp discovery
This commit is contained in:
12
snmp.go
12
snmp.go
@@ -3,6 +3,7 @@ package tendrils
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -109,10 +110,17 @@ func (t *Tendrils) querySwitches() {
|
||||
func (t *Tendrils) querySNMPDevice(ip net.IP) {
|
||||
snmp, err := t.connectSNMP(ip)
|
||||
if err != nil {
|
||||
if t.DebugSNMP {
|
||||
log.Printf("[snmp] %s: connect failed: %v", ip, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
defer snmp.Conn.Close()
|
||||
|
||||
if t.DebugSNMP {
|
||||
log.Printf("[snmp] %s: connected", ip)
|
||||
}
|
||||
|
||||
t.querySysName(snmp, ip)
|
||||
t.queryBridgeMIB(snmp, ip)
|
||||
}
|
||||
@@ -219,6 +227,10 @@ func (t *Tendrils) queryBridgeMIB(snmp *gosnmp.GoSNMP, deviceIP net.IP) {
|
||||
}
|
||||
}
|
||||
|
||||
if t.DebugSNMP {
|
||||
log.Printf("[snmp] %s: mac=%s port=%s", deviceIP, mac, ifName)
|
||||
}
|
||||
|
||||
if addToParent {
|
||||
t.nodes.Update([]net.IP{deviceIP}, []net.HardwareAddr{mac}, "", "", "snmp")
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user