add node names from hostname, lldp, and snmp

populate local node name from hostname. extract system name from lldp packets and snmp sysname oid. call logtree after node merges.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ian Gulliver
2025-11-29 22:27:31 -08:00
parent ebfe18f84c
commit 0d36c21db2
5 changed files with 74 additions and 3 deletions

31
snmp.go
View File

@@ -113,9 +113,40 @@ func (t *Tendrils) querySNMPDevice(ip net.IP) {
}
defer snmp.Conn.Close()
t.querySysName(snmp, ip)
t.queryBridgeMIB(snmp, ip)
}
func (t *Tendrils) querySysName(snmp *gosnmp.GoSNMP, deviceIP net.IP) {
oid := "1.3.6.1.2.1.1.5.0"
result, err := snmp.Get([]string{oid})
if err != nil {
return
}
if len(result.Variables) > 0 {
variable := result.Variables[0]
if variable.Type == gosnmp.OctetString {
sysName := string(variable.Value.([]byte))
if sysName != "" {
t.nodes.mu.RLock()
if id, exists := t.nodes.ipIndex[deviceIP.String()]; exists {
t.nodes.mu.RUnlock()
t.nodes.mu.Lock()
node := t.nodes.nodes[id]
if node.Name == "" {
node.Name = sysName
}
t.nodes.mu.Unlock()
return
}
t.nodes.mu.RUnlock()
}
}
}
}
func (t *Tendrils) queryBridgeMIB(snmp *gosnmp.GoSNMP, deviceIP net.IP) {
portOID := "1.3.6.1.2.1.17.7.1.2.2.1.2"