Files
govpp-snmp-agentx/main.go
2025-06-10 13:28:30 +02:00

42 lines
948 B
Go

package main
import (
"flag"
"log"
"govpp-snmp-example/agentx"
"govpp-snmp-example/config"
"govpp-snmp-example/ifmib"
"govpp-snmp-example/vppstats"
)
func main() {
debug := flag.Bool("debug", false, "Enable debug logging")
vppcfg := flag.String("vppcfg", "", "VPP configuration YAML file to read interface descriptions from")
flag.Parse()
// Set global debug flag
config.Debug = *debug
// Create the interface MIB
interfaceMIB := ifmib.NewInterfaceMIB()
// Load VPP config if specified
if *vppcfg != "" {
if err := interfaceMIB.LoadVPPConfig(*vppcfg); err != nil {
log.Fatalf("Failed to load VPP config: %v", err)
}
}
// Start AgentX routine
if err := agentx.StartAgentXRoutine(interfaceMIB); err != nil {
log.Fatalf("Failed to start AgentX: %v", err)
}
// Start VPP stats routine with callback to update MIB
vppstats.StartStatsRoutine(interfaceMIB.UpdateStats)
// Keep the main routine running
select {}
}