Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Allow indexed ID to be specified in the middle of OID for SNMP metric #324

Open
dhoutz opened this issue Feb 12, 2018 · 15 comments
Labels
enhancement help wanted measure-design Related to improve design for metric gathering
Milestone

Comments

@dhoutz
Copy link

dhoutz commented Feb 12, 2018

Hi,

I'm currently trying to poll our Raritan PDUs to get per outlet metrics however I've run into an issue due to the OID layout that Raritan uses. Unlike most indexed tables I've dealt with, such as ifTable, where the indexed instance is appended to the end the of the OID, Raritan puts the index mid OID.

For example, to get the current Watts being pulled from an outlet you would use:

.1.3.6.1.4.1.13742.6.5.4.3.1.6.1.<OUTLET#>.5

To get the current for outlet:

1.3.6.1.4.1.13742.6.5.4.3.1.6.1.<OUTLET#>.1

In this case the specific outlet on the PDU (1-24) comes before the counter (5 for Watts, 1 for Current).

Unless I'm overlooking something this makes it impossible to define an SNMP metric with the OID and then define an Influx Measurement with a GetMode Indexed SNMP Table.

I think this could be solved by defining where the index goes in the OID when defining a new SNMP metric. Currently I believe they are just added to the end.

Link to Raritan SNMP MIB Doc: http://support.raritan.com/px2/version-3.0.0/PX2_MIB_Guide.pdf

Section

@jackson-tim
Copy link

+1

2 similar comments
@tomeknet
Copy link

+1

@pstanczak
Copy link

+1

@tardoe
Copy link

tardoe commented Feb 12, 2018 via email

@mikemrm
Copy link

mikemrm commented Feb 16, 2018

+1

@sbengo
Copy link
Collaborator

sbengo commented Feb 22, 2018

Hi guys,

Sorry for the late answer and thanks for the explanation.
This feature was already asked on #252 (last comment) and I personally think that could be achieved setting up a new field called "Metric Suffix" which would be appended at the index.

As I answered on the related issue, this feature requires a huge change on the core metric/measurement behaviour, we are thinking on it, but it would take some time to do it

Thanks for the patience!!
Regards!

@toni-moreno toni-moreno added this to the 0.8 milestone Apr 14, 2018
@jasonyates
Copy link

+1 for this.

I have a similar issue with Cisco WLC's. The Index is by Access Point name however to pull something like clients per Access Point the information is presented per radio and a .0 and .1 is appended to each OID.

@SteveRodrigue
Copy link

+1

In the case of IP SLA, there could even be multiple "dot" after the index...

Here is an example:
snmpwalk -v2c -c ***** router.example.com .1.3.6.1.4.1.9.9.42.1.3.2.1.2<INDEX> SNMPv2-SMI::enterprises.9.9.42.1.3.2.1.2.<INDEX>.1694441214.1.1 = INTEGER: 1801 SNMPv2-SMI::enterprises.9.9.42.1.3.2.1.2.<INDEX>.1694801214.1.1 = INTEGER: 1377

@toni-moreno toni-moreno modified the milestones: 0.8, 0.9 Nov 5, 2018
@syepes
Copy link

syepes commented Jan 17, 2019

+1
Facing the same issue with the Cisco WLC

@jasonyates Did you finalize implementing the WLC collections? If yes would you care in shearing an export of the "Measurement Groups"

@wurmrobert
Copy link

+1

@wurmrobert
Copy link

wurmrobert commented Mar 9, 2019

@toni-moreno i have about the same requirements on some devices. So i have forked your collector and tried to understand your code and implement a running solution which works fine for my cases.

My solution idea was:

We have a oid like previous discussed from @dhoutz:

.1.3.6.1.4.1.13742.6.5.4.3.1.6.1.<OUTLET#>.5

In my case i have the following oids:

.1.3.6.1.4.1.4491.2.1.20.1.4.1.5.<x>.<y>
like
.1.3.6.1.4.1.4491.2.1.20.1.4.1.5.1.1
.1.3.6.1.4.1.4491.2.1.20.1.4.1.5.2.2
.1.3.6.1.4.1.4491.2.1.20.1.4.1.5.3.3
.1.3.6.1.4.1.4491.2.1.20.1.4.1.5.2.1
.1.3.6.1.4.1.4491.2.1.20.1.4.1.5.2.2
..
..

So i created an measurement (indexed with direct tag):
IndexOId: .1.3.6.1.4.1.4491.2.1.20.1.3.1.2
IndexTag: mac

This oid gives the first indexes -> variable <x>
In @dhoutz example this would be the <OUTLET> example.

I created a metric with the Base OID:
.1.3.6.1.4.1.4491.2.1.20.1.4.1.5

After debugging the collector i realized that you fetch all variables correct with the get bulk operation.
But you only store one variable in the SnmpMetric struct at the attribute ComputedValue.

So i changed the struct, so that i can store all variables in a map where the key is the first index:

CookedValue map[string]interface{}
CurValue    map[string]interface{}
LastValue   map[string]interface{}

To split indexes with values i had to change the SnmpWalkData method:

func (m *Measurement) SnmpWalkData() (int64, int64, int64, error) {

	now := time.Now()
	var gathered int64
	var processed int64
	var errors int64

	setRawData := func(pdu gosnmp.SnmpPDU) error {
		m.Debugf("received SNMP  pdu:%+v", pdu)
		gathered++
		if pdu.Value == nil {
			m.Warnf("no value retured by pdu :%+v", pdu)
			errors++
			return nil //if error return the bulk process will stop
		}


		if metr, ok := m.OidSnmpMap[pdu.Name]; ok {
			m.Debugf("OK measurement %s SNMP RESULT OID %s MetricFound", pdu.Name, pdu.Value)
			processed++
			metr.SetRawData(pdu, nil, "", now)
		} else {
			var subSet = false
			for k, v := range m.OidSnmpMap {
				var subOids = strings.Split(pdu.Name, k)
				
				
				// get sub oid
				var pduOids = strings.Split(pdu.Name, ".")
				var mOids = strings.Split(k, ".")



				if len(subOids) > 1 && (len(mOids) >= len(mOids)) && (mOids[len(mOids) -1] == pduOids[len(mOids) -1])  {
					// its a sub oid

					var subOid = strings.Join(subOids,"")

					fmt.Println("sub: ", subOid)

					subSet    = true

					metr = v


					m.Debugf("OK measurement %s SNMP RESULT OID %s MetricFound", pdu.Name, pdu.Value)

					processed++
					metr.SetRawData(pdu, subOids, subOid, now)

				}
			}


			if !subSet {
				m.Debugf("returned OID from device: %s  Not Found in measurement /metr list: %+v", pdu.Name, m.cfg.ID)
			}
		}

		return nil
	}

	for _, v := range m.cfg.FieldMetric {
		if err := m.Walk(v.BaseOID, setRawData); err != nil {
			m.Errorf("SNMP WALK (%s) for OID (%s) get error: %s\n", m.snmpClient.Target, v.BaseOID, err)
			errors += int64(m.MetricTable.Len())
		}
	}

	return gathered, processed, errors, nil
}

I had also changed many other methods, like the convertion methods.
At the end (most important) i changed the storage of the influxpoints that i get for each leading index a measurement row where i tagged the row with the index:

time                SNR     host                mac                 subIndexes
----                ------- --------------      ----                ------ 
1551438780000000000 363     10.159.201.251      00:00:00:00:00:00   .1
1551438780000000000 361     10.159.201.251      00:00:00:00:00:00   .2
1551438780000000000 362     10.159.201.251      00:00:00:00:00:00   .3
1551438780000000000 363     10.159.201.252      00:00:00:00:00:00   .1
...
...

My questions to you @toni-moreno:

  1. Do you think that this implementation is not nonsense?
  2. Do you think that this implementation could also be used for this feature request?

@toni-moreno
Copy link
Owner

Hi @wurmrobert , thanks a lot for your suggestion, and sorry for the delay in the answer.

I think this could be a good staring point, but we need to review first... Could you send us a Pull Request with your changes , please ?

Thanks a lot!

@deejaypro
Copy link

Hey,
i really would like to see this feature in snmpcollector. Because this prevents us from gathering snmp metrics from a specific vendor. And the Telegraf SNMP Collector isn't that great if i'm honest.
@wurmrobert do you thing, that you are able to create a feature request soon or make your fork visibile for others so we can see what changes you made?

@toni-moreno
Copy link
Owner

Hello @wurmrobert, I would like to release a new version with this new feature.

would be great if you could send us a PR with your changes. ( don't worry if there is some merge conflict) , we can rebase for you.

Thank you very much.

@toni-moreno toni-moreno modified the milestones: 0.9, 0.10, 1.0 Feb 28, 2021
@toni-moreno toni-moreno added the measure-design Related to improve design for metric gathering label Mar 8, 2021
@jjess
Copy link

jjess commented May 4, 2021

I need this feature as well because of some Qos tables where the Index referring the interface is not located at the end of the OID. For example:

.1.3.6.1.4.1.2011.5.25.32.4.1.4.3.3.1.5.109.0.1 = Counter64: 526551509130967 .1.3.6.1.4.1.2011.5.25.32.4.1.4.3.3.1.5.109.0.2 = Counter64: 0 .1.3.6.1.4.1.2011.5.25.32.4.1.4.3.3.1.5.109.0.3 = Counter64: 22915176814254 .1.3.6.1.4.1.2011.5.25.32.4.1.4.3.3.1.5.109.0.4 = Counter64: 0 .1.3.6.1.4.1.2011.5.25.32.4.1.4.3.3.1.5.109.0.5 = Counter64: 736916480948778 .1.3.6.1.4.1.2011.5.25.32.4.1.4.3.3.1.5.109.0.6 = Counter64: 384464519432 .1.3.6.1.4.1.2011.5.25.32.4.1.4.3.3.1.5.109.0.7 = Counter64: 4446961646 .1.3.6.1.4.1.2011.5.25.32.4.1.4.3.3.1.5.109.0.8 = Counter64: 988307868 .1.3.6.1.4.1.2011.5.25.32.4.1.4.3.3.1.5.109.0.9 = Counter64: 1286773070197087

Where "109" is the interface Index.

BR,

Jes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted measure-design Related to improve design for metric gathering
Projects
None yet
Development

No branches or pull requests