snmpcollector icon indicating copy to clipboard operation
snmpcollector copied to clipboard

[Question] regarding tag values mapping

Open Naumis1 opened this issue 2 years ago • 10 comments

Hello, I have a question. How can I map index values from ifIndex to some other values? For example: tp-link switches uses interesting port indexing IF-MIB::ifDescr.49153, IF-MIB::ifDescr.49154, IF-MIB::ifDescr.49155 (port 1, 2, 3) and so on. So how to do, that the port name (tag value in influxdb) would be "1/0/1" instead of "49153", "1/0/2" instead of "49154"... Other devices uses normal indexing e.g. .1 and so on, but still we need mapping for example from .1 to 1/1, depends on manufacturer and model.

I tried to use Custom Filters, added some filtering, but still can't see no new Tag values in influx. Thanks!

  • SnmpCollector version: 0.10.0
  • OS: CentOS Linux release 8.3.2011
  • Trying to add Custom Filter
  • Custom port mapping
  • Not working Screenshot from 2021-08-24 14-30-05

Naumis1 avatar Aug 24 '21 12:08 Naumis1

Hello @Naumis1 .

I can not understand why are you indexing by .1.3.6.1.2.1.2.2.1.1 (ifIndex) if you can index by the description (ifDesc) ".1.3.6.1.2.1.2.2.1.2" As you can see in the following example: https://github.com/toni-moreno/snmpcollector/wiki/Example:-Configuring-Cisco-Catalyst-Switch

You can configure you measurement with indexOID .1.3.6.1.2.1.2.2.1.2 and you can name it as "portName" ,

image

And add all other defined metrics from the Iftable : Example for configure

image

image

Obviously you should create all these SnmpMetrics from the table (https://www.alvestrand.no/objectid/1.3.6.1.2.1.2.2.1.html) and also these other special "STRINGEVAL" if you need it.

hope this can help you

toni-moreno avatar Aug 24 '21 16:08 toni-moreno

For me it does not matter if I do indexing by ifDescr or with ifIndex. I am trying to map port names to manufacturer and model specific ones. e.g 1/0/1, 1/1, 1:1 or just 1. I am doing it so, in order to fit snmpcollector in to exsisting infrastructure. I noticed something interesting here: snmpcollector/conf/lp_file_filter_a.txt. But still can't get it working.

Naumis1 avatar Aug 24 '21 17:08 Naumis1

Of course you can use the file filters also

But I thought that you had manufacturer port names at "ifDescr". ( it should be standard at SNMP MIB-2 definitions in most of routers and switches)

Anyway. Could you please show us the output from snmpwalk .1.3.6.1.2.1.2.2.1.2 please ?

If you need only a bit of the full response you can use STRINGPARSER metric type to preprocess the response before sent to the backend

toni-moreno avatar Aug 24 '21 18:08 toni-moreno

If you need only a bit of the full response you can use STRINGPARSER metric type to preprocess the response before sent to the backend

Yes i thought about that, but problem, is that I have ~25K different brand and model switches. Mostly D-Link and TP-Link. For example: TP-link looks good: IF-MIB::ifDescr.49153 = STRING: gigabitEthernet 1/0/1 : copper ---> 1/0/1 D-Link looks not so good: IF-MIB::ifDescr.1 = STRING: D-Link DES-3200-28 R1.89 Port 1 ---> (should be 1/1) Other D-link: IF-MIB::ifDescr.2 = STRING: D-Link DGS-3000-28SC R5.10.B00 Port 2 on Unit 1 ----> (should be 1:2)

These are quite good examples, So port mapping is the solution for me.

Of course you can use the file filters also

Could you tell here a bit more?

Naumis1 avatar Aug 24 '21 18:08 Naumis1

Not sure that port mapping will be the best solution for you. File filter has been designed for really edge cases and each file should fit only one device ( not easily maintainable)

In most of our customers we have designed different configurention templates ( measurement groups) for each manufacturer/model and deployed configurarions for hundreds of devices using the snmpcollector API choosing for each device its specific config template.

And , not sure but I think you would be able to look for the appropiate regular expresion for TP-Link and different regexp for D-Link.

If you need a more specific solution we can offer you advanced consultancy for your use case and also custom features develop as part of our commerial support.

Hope these tips could help you.

toni-moreno avatar Aug 24 '21 20:08 toni-moreno

But as I see from webgui it looks like Custom Filters is one filter per device and Measurement Filters with filter type "file" is for multi devices. Am I wrong?

Thanks!

Naumis1 avatar Aug 24 '21 20:08 Naumis1

Both type of filters could be shared among different devices.

But if I'm not wrong, you could add in this file, one config line per interface for all possible strings in different manufacturer/model ( hundreds or perhaps thousands of different config lines) that you could of course use in all devices.

In my previous approach only one regular expression per manufacturer/model ( perhaps 15/20/30 different regexp ?) It depends on the all existing IfDesc responses

toni-moreno avatar Aug 24 '21 21:08 toni-moreno

Could you please give an example how would regexp look like from my pasted examples?

TP-link looks good: IF-MIB::ifDescr.49153 = STRING: gigabitEthernet 1/0/1 : copper ---> 1/0/1 D-Link looks not so good: IF-MIB::ifDescr.1 = STRING: D-Link DES-3200-28 R1.89 Port 1 ---> (should be 1/1) Other D-link: IF-MIB::ifDescr.2 = STRING: D-Link DGS-3000-28SC R5.10.B00 Port 2 on Unit 1 ----> (should be 1:2)

Naumis1 avatar Aug 24 '21 21:08 Naumis1

Hi @Naumis1 ,

As @toni-moreno is proposing, I would create a single regex for each kind of device, for all type of interface responses. I would recommend you to set test the output of ifName query:

Example response ifName query (1.3.6.1.2.1.31.1.1.1.1) over an  DGS-1510-20 Gigabit Ethernet SmartPro Switch

OID | Type | Value
-- | -- | --
.1.3.6.1.2.1.31.1.1.1.1.1 | OctetString | eth1/0/1
.1.3.6.1.2.1.31.1.1.1.1.2 | OctetString | eth1/0/2
.1.3.6.1.2.1.31.1.1.1.1.3 | OctetString | eth1/0/3
...

Following your example:

TP-link looks good: IF-MIB::ifDescr.49153 = STRING: gigabitEthernet 1/0/1 : copper ---> 1/0/1
^\w+ (.*) : .*$ --> $1 capture group will contain 1/0/1
> Model DGS-3000
D-Link looks not so good: IF-MIB::ifDescr.1 = STRING: D-Link DES-3200-28 R1.89 Port 1 ---> (should be 1/1)
.*Port (\d+) --> $1 and set the first index? 
> Model DGS-3200
Other D-link: IF-MIB::ifDescr.2 = STRING: D-Link DGS-3000-28SC R5.10.B00 Port 2 on Unit 1 ----> (should be 1:2)
.*Port (\d+) on Unit (\d+) --> $1 and $2 will contain required info

sbengo avatar Aug 27 '21 10:08 sbengo

Hello @Naumis1 We hope you can continue working with snmpcollector with all our previous suggestions . If thera are not any update in next hours we will close this issue. Thank you.

toni-moreno avatar Oct 13 '21 20:10 toni-moreno