Include multicast and broadcast packets in interface pps stats

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ian Gulliver
2026-01-31 07:35:49 -08:00
parent f97bf04eef
commit 5c4266f89c
2 changed files with 10 additions and 4 deletions

View File

@@ -90,7 +90,8 @@
"Bash(git -C /home/flamingcow/multicast diff --name-only)",
"Bash(du:*)",
"Bash(tree:*)",
"Bash(go get:*)"
"Bash(go get:*)",
"Bash(go test:*)"
],
"ask": [
"Bash(rm *)"

11
snmp.go
View File

@@ -204,7 +204,11 @@ func (t *Tendrils) queryInterfaceStats(snmp *gosnmp.GoSNMP, node *Node, ifNames
ifHCInOctets := t.getInterfaceTable64(snmp, "1.3.6.1.2.1.31.1.1.1.6")
ifHCOutOctets := t.getInterfaceTable64(snmp, "1.3.6.1.2.1.31.1.1.1.10")
ifHCInUcastPkts := t.getInterfaceTable64(snmp, "1.3.6.1.2.1.31.1.1.1.7")
ifHCInMcastPkts := t.getInterfaceTable64(snmp, "1.3.6.1.2.1.31.1.1.1.8")
ifHCInBcastPkts := t.getInterfaceTable64(snmp, "1.3.6.1.2.1.31.1.1.1.9")
ifHCOutUcastPkts := t.getInterfaceTable64(snmp, "1.3.6.1.2.1.31.1.1.1.11")
ifHCOutMcastPkts := t.getInterfaceTable64(snmp, "1.3.6.1.2.1.31.1.1.1.12")
ifHCOutBcastPkts := t.getInterfaceTable64(snmp, "1.3.6.1.2.1.31.1.1.1.13")
poeStats := t.getPoEStats(snmp, ifNames)
now := time.Now()
@@ -240,12 +244,13 @@ func (t *Tendrils) queryInterfaceStats(snmp *gosnmp.GoSNMP, node *Node, ifNames
stats.OutErrors = uint64(outErr)
}
inPkts, hasInPkts := ifHCInUcastPkts[ifIndex]
outPkts, hasOutPkts := ifHCOutUcastPkts[ifIndex]
inBytes, hasInBytes := ifHCInOctets[ifIndex]
outBytes, hasOutBytes := ifHCOutOctets[ifIndex]
if hasInPkts && hasOutPkts && hasInBytes && hasOutBytes {
inPkts := ifHCInUcastPkts[ifIndex] + ifHCInMcastPkts[ifIndex] + ifHCInBcastPkts[ifIndex]
outPkts := ifHCOutUcastPkts[ifIndex] + ifHCOutMcastPkts[ifIndex] + ifHCOutBcastPkts[ifIndex]
if hasInBytes && hasOutBytes {
key := node.ID + ":" + name
ifaceTracker.mu.Lock()
prev, hasPrev := ifaceTracker.counters[key]