Add flag -vppstats.api.addr and rename -vppstats.addr to -vppstats.stats.addr; Update README
This commit is contained in:
11
README.md
11
README.md
@ -87,7 +87,8 @@ CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION} -X main.buildTime=${
|
|||||||
|
|
||||||
| Flag | Default | Description |
|
| Flag | Default | Description |
|
||||||
|------|---------|-------------|
|
|------|---------|-------------|
|
||||||
| `-vppstats.addr` | `/var/run/vpp/stats.sock` | VPP statistics socket path |
|
| `-vppstats.api.addr` | `/var/run/vpp/api.sock` | VPP API socket path |
|
||||||
|
| `-vppstats.stats.addr` | `/var/run/vpp/stats.sock` | VPP statistics socket path |
|
||||||
| `-vppstats.period` | `10` | Interval in seconds for querying VPP interface stats |
|
| `-vppstats.period` | `10` | Interval in seconds for querying VPP interface stats |
|
||||||
| `-vppstats.ifindex-offset` | `1000` | Offset to add to VPP interface indices for SNMP |
|
| `-vppstats.ifindex-offset` | `1000` | Offset to add to VPP interface indices for SNMP |
|
||||||
|
|
||||||
@ -101,7 +102,10 @@ CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION} -X main.buildTime=${
|
|||||||
./govpp-snmp-agentx -vppstats.period 5
|
./govpp-snmp-agentx -vppstats.period 5
|
||||||
|
|
||||||
# Custom VPP stats socket
|
# Custom VPP stats socket
|
||||||
./govpp-snmp-agentx -vppstats.addr /custom/path/stats.sock
|
./govpp-snmp-agentx -vppstats.stats.addr /custom/path/stats.sock
|
||||||
|
|
||||||
|
# Custom VPP API socket
|
||||||
|
./govpp-snmp-agentx -vppstats.api.addr /custom/path/api.sock
|
||||||
|
|
||||||
# Custom interface index offset (start at 2000)
|
# Custom interface index offset (start at 2000)
|
||||||
./govpp-snmp-agentx -vppstats.ifindex-offset 2000
|
./govpp-snmp-agentx -vppstats.ifindex-offset 2000
|
||||||
@ -114,7 +118,8 @@ CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION} -X main.buildTime=${
|
|||||||
-agentx.addr /var/agentx/master \
|
-agentx.addr /var/agentx/master \
|
||||||
-debug \
|
-debug \
|
||||||
-vppcfg /etc/vpp/vppcfg.yaml \
|
-vppcfg /etc/vpp/vppcfg.yaml \
|
||||||
-vppstats.addr /var/run/vpp/stats.sock \
|
-vppstats.api.addr /var/run/vpp/api.sock \
|
||||||
|
-vppstats.stats.addr /var/run/vpp/stats.sock \
|
||||||
-vppstats.period 5 \
|
-vppstats.period 5 \
|
||||||
-vppstats.ifindex-offset 1000
|
-vppstats.ifindex-offset 1000
|
||||||
```
|
```
|
||||||
|
@ -17,7 +17,8 @@ type StatsCallback func(*api.InterfaceStats)
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
// Flags for VPP stats configuration
|
// Flags for VPP stats configuration
|
||||||
StatsAddr = flag.String("vppstats.addr", "/var/run/vpp/stats.sock", "VPP stats socket path")
|
ApiAddr = flag.String("vppstats.api.addr", "/var/run/vpp/api.sock", "VPP API socket path")
|
||||||
|
StatsAddr = flag.String("vppstats.stats.addr", "/var/run/vpp/stats.sock", "VPP stats socket path")
|
||||||
IfIndexOffset = flag.Int("vppstats.ifindex-offset", 1000, "Offset to add to VPP interface indices for SNMP")
|
IfIndexOffset = flag.Int("vppstats.ifindex-offset", 1000, "Offset to add to VPP interface indices for SNMP")
|
||||||
Period = flag.Int("vppstats.period", 10, "Interval in seconds for querying VPP interface stats")
|
Period = flag.Int("vppstats.period", 10, "Interval in seconds for querying VPP interface stats")
|
||||||
)
|
)
|
||||||
@ -29,7 +30,7 @@ func StartStatsRoutine(callback StatsCallback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func statsRoutine(period time.Duration, callback StatsCallback) {
|
func statsRoutine(period time.Duration, callback StatsCallback) {
|
||||||
logger.Debugf("Starting VPP stats routine with socket: %s, period: %v", *StatsAddr, period)
|
logger.Debugf("Starting VPP stats routine with API: %s, Stats: %s, period: %v", *ApiAddr, *StatsAddr, period)
|
||||||
|
|
||||||
var conn *core.Connection
|
var conn *core.Connection
|
||||||
var statsConn *core.StatsConnection
|
var statsConn *core.StatsConnection
|
||||||
@ -92,7 +93,7 @@ func statsRoutine(period time.Duration, callback StatsCallback) {
|
|||||||
|
|
||||||
// Create API connection first - only proceed if this succeeds
|
// Create API connection first - only proceed if this succeeds
|
||||||
var err error
|
var err error
|
||||||
conn, err = core.Connect(socketclient.NewVppClient("/var/run/vpp/api.sock"))
|
conn, err = core.Connect(socketclient.NewVppClient(*ApiAddr))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if wasConnected {
|
if wasConnected {
|
||||||
logger.Printf("VPP API connection lost: %v", err)
|
logger.Printf("VPP API connection lost: %v", err)
|
||||||
@ -125,7 +126,7 @@ func statsRoutine(period time.Duration, callback StatsCallback) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.Printf("Connected to VPP (API: /var/run/vpp/api.sock, Stats: %s)", *StatsAddr)
|
logger.Printf("Connected to VPP (API: %s, Stats: %s)", *ApiAddr, *StatsAddr)
|
||||||
connected = true
|
connected = true
|
||||||
wasConnected = true
|
wasConnected = true
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user