Add -vppcfg flag to set ifAlias from the 'description' fields in vppcfg.yaml

This commit is contained in:
Pim van Pelt
2025-06-09 19:12:05 +02:00
parent 069b1b6fc2
commit 458168e308
6 changed files with 136 additions and 2 deletions

View File

@ -75,6 +75,7 @@ CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION} -X main.buildTime=${
|------|---------|-------------|
| `-agentx-addr` | `localhost:705` | AgentX master agent address (hostname:port or Unix socket path) |
| `-debug` | `false` | Enable debug logging |
| `-vppcfg` | `""` | VPP configuration YAML file to read interface descriptions from |
#### VPP Statistics Module Flags
@ -99,15 +100,48 @@ CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION} -X main.buildTime=${
# Custom interface index offset (start at 2000)
./vpp-snmp-agent -vppstats.ifindex-offset 2000
# With VPP configuration file for interface descriptions
./vpp-snmp-agent -vppcfg /etc/vpp/vppcfg.yaml
# Full configuration
./vpp-snmp-agent \
-agentx-addr /var/agentx/master \
-debug \
-vppcfg /etc/vpp/vppcfg.yaml \
-vppstats.addr /var/run/vpp/stats.sock \
-vppstats.period 5 \
-vppstats.ifindex-offset 1000
```
## VPP Configuration File
The `-vppcfg` flag accepts a YAML configuration file that describes VPP interfaces and their descriptions. This file is used to populate the `ifAlias` (.18) field in the ifXTable with meaningful interface descriptions.
### YAML Format Example
```yaml
interfaces:
GigabitEthernet82/0/0:
description: 'Infra: Management interface'
TenGigabitEthernet1/0/2:
description: 'Infra: Core uplink'
sub-interfaces:
100:
description: 'Cust: Customer VLAN 100'
200:
description: 'Transit: Provider VLAN 200'
loopbacks:
loop0:
description: 'Core: Router loopback'
```
### Description Mapping
- **Main interfaces**: Use the `description` field directly
- **Sub-interfaces**: Use the `description` field from the `sub-interfaces` section
- **Loopbacks**: Use the `description` field from the `loopbacks` section
- **Fallback**: If no description is found, the interface name is used as the alias
## SNMP Interface Mapping
VPP interfaces are mapped to SNMP indices with a configurable offset (default 1000):
@ -135,6 +169,7 @@ The application implements the ifXTable (1.3.6.1.2.1.31.1.1.1) with the followin
| `.11.{index}` | ifHCOutUcastPkts | Counter64 | TX unicast packets (high capacity) |
| `.12.{index}` | ifHCOutMulticastPkts | Counter64 | TX multicast packets (high capacity) |
| `.13.{index}` | ifHCOutBroadcastPkts | Counter64 | TX broadcast packets (high capacity) |
| `.18.{index}` | ifAlias | DisplayString | Interface description/alias (from VPP config or interface name) |
## SNMP Query Examples
@ -148,6 +183,16 @@ snmpwalk -v2c -c public localhost 1.3.6.1.2.1.31.1.1.1.1
snmpget -v2c -c public localhost 1.3.6.1.2.1.31.1.1.1.1.1000
```
### Query Interface Descriptions
```bash
# Get all interface descriptions/aliases
snmpwalk -v2c -c public localhost 1.3.6.1.2.1.31.1.1.1.18
# Get specific interface description (interface 0 with default offset)
snmpget -v2c -c public localhost 1.3.6.1.2.1.31.1.1.1.18.1000
```
### Query Interface Counters
```bash