toni-moreno / snmpcollector

A full featured Generic SNMP data collector with Web Administration Interface for InfluxDB
MIT License
290 stars 53 forks source link

[QUESTION] BGP Prefixes Received #490

Closed jjess closed 3 years ago

jjess commented 3 years ago

Hi:

This question is similar (not identical) to https://github.com/toni-moreno/snmpcollector/issues/252 but I cannot figure out how to implement it.

I want to retrieve received BGP prefixes (routes) only from specific BGP Peers belonging to a specific VRF. So I guess I must use some OID Condition to filter out.

The VRF Peer table with the name of the VRF can be obtained with:

snmpwalk -v2c -c xxxx IP 1.3.6.1.4.1.2011.5.25.177.1.1.1 . . . 1.3.6.1.4.1.2011.5.25.177.1.1.1.1.6.2.1.1.1.4.10.187.1.77 = STRING: "MYVRF" 1.3.6.1.4.1.2011.5.25.177.1.1.1.1.6.2.1.1.1.4.10.187.4.14 = STRING: "MYVRF" 1.3.6.1.4.1.2011.5.25.177.1.1.1.1.6.2.1.1.1.4.10.187.6.29 = STRING: "MYVRF" 1.3.6.1.4.1.2011.5.25.177.1.1.1.1.6.2.1.1.1.4.10.187.10.69 = STRING: "MYVRF" 1.3.6.1.4.1.2011.5.25.177.1.1.1.1.6.2.1.1.1.4.10.187.18.69 = STRING: "MYVRF" 1.3.6.1.4.1.2011.5.25.177.1.1.1.1.6.2.1.1.1.4.10.187.142.6 = STRING: "MYVRF" There are more, but I only want those Peers with VRF Name="MYVRF". They have a '2' after the '6'. This '2' number is an internal Index for the defined VRFs, and I need it in order to compose the proper OID to retrieve the prefixes I want (instead of all the equipment can provide).

The measurement (received BGP prefixes) can be obtained with:

snmpwalk -On -v2c -c xxxx IP 1.3.6.1.4.1.2011.5.25.177.1.1.3.1.1 1.3.6.1.4.1.2011.5.25.177.1.1.3.1.1.1.1.1.1.4.10.187.121.14 = Counter32: 0 1.3.6.1.4.1.2011.5.25.177.1.1.3.1.1.1.1.1.1.4.10.187.121.22 = Counter32: 0 1.3.6.1.4.1.2011.5.25.177.1.1.3.1.1.2.1.1.1.4.10.187.1.77 = Counter32: 59 <<<< 1.3.6.1.4.1.2011.5.25.177.1.1.3.1.1.2.1.1.1.4.10.187.4.14 = Counter32: 0 <<<< 1.3.6.1.4.1.2011.5.25.177.1.1.3.1.1.2.1.1.1.4.10.187.6.29 = Counter32: 27 <<<< 1.3.6.1.4.1.2011.5.25.177.1.1.3.1.1.2.1.1.1.4.10.187.10.69 = Counter32: 2 <<<< 1.3.6.1.4.1.2011.5.25.177.1.1.3.1.1.2.1.1.1.4.10.187.18.69 = Counter32: 1 <<<< 1.3.6.1.4.1.2011.5.25.177.1.1.3.1.1.2.1.1.1.4.10.187.142.6 = Counter32: 2 <<<< 1.3.6.1.4.1.2011.5.25.177.1.1.3.1.1.3.1.1.1.4.172.28.141.53 = Counter32: 12 1.3.6.1.4.1.2011.5.25.177.1.1.3.1.1.3.1.1.4.1.1.1.4.172.16.123.45 = Counter32: 14 1.3.6.1.4.1.2011.5.25.177.1.1.3.1.1.3.1.1.5.1.1.1.4.172.29.35.5 = Counter32: 0

But I need only those marked with '<<<<'. All of them have the '2' after '1.1.3.1.1'; it's the internal id for the VRF.

So, my question is how to filter by VRF Name (those VRFs with name 'MYVRF' ) but at the same time obtain this internal VRF ID ('2' in the example) and then generate a measurement only for those Peers belonging to that VRF (with the internal id '2' in the example). It's obvious that the internal VRF id can change in every equipment.

Because I think I should filter out (because the big number of peers in my equipments) the solution in the mentioned issue is not suitable for me...

Thanks in advance,

Jes

toni-moreno commented 3 years ago

Hello @jjess , could you please attach to this issue ( or send by email ) a snapshot sim_data_issue_490_<DATE>.tar.gz of data from your router in order to simulate ourselves this use case?.

# git clone https://github.com/etingof/snmpsim.git`
# cd snmpsim
# sudo python3 setup.py install
# mkdir sim_data
# snmpsim-record-commands --protocol-version 2c --community <your_comunity> --agent-udpv4-endpoint=<your_bgp_router_data>:161 --output-file=./sim_data/issue490/bgp_example_router_data
# tar zcvf sim_data_issue_490_<DATE>.tar.gz sim_data

Thank you in advance

jjess commented 3 years ago

Hi:

I ended up with the solution by myself. So I describe it here to help other people...

In order to filter by VRF in my router I created an OID like:

image

So I'm filtering by the name of the VRF (something with L3VPNLTE.... or whatever).

An example of metric to be gathered:

image

The interesting thing is how to properly tag the measurements. Here I wanted to use the IP of the bgp peer as the object that holds the metrics I want to collect (prefixes). I use IndexTagFormat=${IDX1|DOT[5:9]} as my tag:

image

So, no more support is needed.

Thanks

Jes