add -period flag
This commit is contained in:
@ -9,16 +9,16 @@ import (
|
||||
"go.fd.io/govpp/core"
|
||||
)
|
||||
|
||||
// StartStatsRoutine starts a goroutine that queries VPP interface stats every 10 seconds
|
||||
func StartStatsRoutine() {
|
||||
go statsRoutine()
|
||||
// StartStatsRoutine starts a goroutine that queries VPP interface stats at the specified interval
|
||||
func StartStatsRoutine(statsSocketPath string, period time.Duration) {
|
||||
go statsRoutine(statsSocketPath, period)
|
||||
}
|
||||
|
||||
func statsRoutine() {
|
||||
log.Println("Starting VPP stats routine...")
|
||||
func statsRoutine(statsSocketPath string, period time.Duration) {
|
||||
log.Printf("Starting VPP stats routine with socket: %s, period: %v", statsSocketPath, period)
|
||||
|
||||
// Create stats client
|
||||
client := statsclient.NewStatsClient("/var/run/vpp/stats.sock")
|
||||
client := statsclient.NewStatsClient(statsSocketPath)
|
||||
|
||||
// Connect using core.ConnectStats (proper way)
|
||||
c, err := core.ConnectStats(client)
|
||||
@ -28,7 +28,7 @@ func statsRoutine() {
|
||||
}
|
||||
defer c.Disconnect()
|
||||
|
||||
ticker := time.NewTicker(10 * time.Second)
|
||||
ticker := time.NewTicker(period)
|
||||
defer ticker.Stop()
|
||||
|
||||
for {
|
||||
|
Reference in New Issue
Block a user