Add -debug flag

This commit is contained in:
Pim van Pelt
2025-06-09 18:00:59 +02:00
parent a96b853d06
commit 6371e8eee2
3 changed files with 42 additions and 23 deletions

@ -17,6 +17,7 @@ func main() {
vppStatsAddr := flag.String("vpp-stats-addr", "/var/run/vpp/stats.sock", "VPP stats socket path")
period := flag.Float64("period", 10.0, "Interval in seconds for querying VPP interface stats")
ifIndexOffset := flag.Int("vpp-ifindex-offset", 1000, "Offset to add to VPP interface indices for SNMP")
debug := flag.Bool("debug", false, "Enable debug logging")
flag.Parse()
var network, address string
@ -36,7 +37,7 @@ func main() {
client.ReconnectInterval = 1 * time.Second
// Create the interface MIB
interfaceMIB := ifmib.NewInterfaceMIB(*ifIndexOffset)
interfaceMIB := ifmib.NewInterfaceMIB(*ifIndexOffset, *debug)
// Register the interface MIB with the AgentX client
if err := interfaceMIB.RegisterWithClient(client); err != nil {
@ -44,7 +45,7 @@ func main() {
}
// Start VPP stats routine with callback to update MIB
vppstats.StartStatsRoutine(*vppStatsAddr, time.Duration(*period*1000)*time.Millisecond, interfaceMIB.UpdateStats)
vppstats.StartStatsRoutine(*vppStatsAddr, time.Duration(*period*1000)*time.Millisecond, interfaceMIB.UpdateStats, *debug)
for {
time.Sleep(100 * time.Millisecond)