add debug flags for arp, lldp, and snmp discovery
This commit is contained in:
4
arp.go
4
arp.go
@@ -44,6 +44,10 @@ func (t *Tendrils) readARPTable() {
|
||||
continue
|
||||
}
|
||||
|
||||
if t.DebugARP {
|
||||
log.Printf("[arp] %s: ip=%s mac=%s", entry.iface, entry.ip, entry.mac)
|
||||
}
|
||||
|
||||
t.nodes.Update([]net.IP{entry.ip}, []net.HardwareAddr{entry.mac}, entry.iface, "", "arp")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,9 @@ func main() {
|
||||
noSNMP := flag.Bool("no-snmp", false, "disable SNMP discovery")
|
||||
logTree := flag.Bool("log-tree", false, "log full tree on changes")
|
||||
logReasons := flag.Bool("log-reasons", false, "log addition reasons")
|
||||
debugARP := flag.Bool("debug-arp", false, "debug ARP discovery")
|
||||
debugLLDP := flag.Bool("debug-lldp", false, "debug LLDP discovery")
|
||||
debugSNMP := flag.Bool("debug-snmp", false, "debug SNMP discovery")
|
||||
flag.Parse()
|
||||
|
||||
t := tendrils.New()
|
||||
@@ -22,5 +25,8 @@ func main() {
|
||||
t.DisableSNMP = *noSNMP
|
||||
t.LogTree = *logTree
|
||||
t.LogReasons = *logReasons
|
||||
t.DebugARP = *debugARP
|
||||
t.DebugLLDP = *debugLLDP
|
||||
t.DebugSNMP = *debugSNMP
|
||||
t.Run()
|
||||
}
|
||||
|
||||
4
lldp.go
4
lldp.go
@@ -64,6 +64,10 @@ func (t *Tendrils) handleLLDPPacket(ifaceName string, packet gopacket.Packet) {
|
||||
}
|
||||
}
|
||||
|
||||
if t.DebugLLDP {
|
||||
log.Printf("[lldp] %s: mac=%s port=%s name=%s", ifaceName, mac, childPort, systemName)
|
||||
}
|
||||
|
||||
t.nodes.Update(nil, []net.HardwareAddr{mac}, ifaceName, childPort, "lldp")
|
||||
|
||||
if systemName != "" {
|
||||
|
||||
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 {
|
||||
|
||||
@@ -18,6 +18,9 @@ type Tendrils struct {
|
||||
DisableSNMP bool
|
||||
LogTree bool
|
||||
LogReasons bool
|
||||
DebugARP bool
|
||||
DebugLLDP bool
|
||||
DebugSNMP bool
|
||||
}
|
||||
|
||||
func New() *Tendrils {
|
||||
|
||||
Reference in New Issue
Block a user