package main import ( "flag" "log" "strings" "time" "github.com/posteo/go-agentx" "govpp-snmp-example/config" "govpp-snmp-example/ifmib" "govpp-snmp-example/vppstats" ) func main() { addr := flag.String("agentx-addr", "localhost:705", "Address to connect to (hostname:port or Unix socket path)") debug := flag.Bool("debug", false, "Enable debug logging") flag.Parse() // Set global debug flag config.Debug = *debug var network, address string if strings.HasPrefix(*addr, "/") { network = "unix" address = *addr } else { network = "tcp" address = *addr } client, err := agentx.Dial(network, address) if err != nil { log.Fatalf("Failed to dial %s %s: %v", network, address, err) } client.Timeout = 1 * time.Minute client.ReconnectInterval = 1 * time.Second // Create the interface MIB interfaceMIB := ifmib.NewInterfaceMIB() // Register the interface MIB with the AgentX client if err := interfaceMIB.RegisterWithClient(client); err != nil { log.Fatalf("Failed to register interface MIB: %v", err) } // Start VPP stats routine with callback to update MIB vppstats.StartStatsRoutine(interfaceMIB.UpdateStats) for { time.Sleep(100 * time.Millisecond) } }