Generator errors of cannot find oid

95 views
Skip to first unread message

qingtao wu

unread,
Jul 31, 2021, 2:02:47 AM7/31/21
to Prometheus Users
The generate subcommand adds an option "fail-on-oid-notfound" default is "true". When "false", we print the "warn" or" error" log instead of exiting the program so that we can see all the missing oids.

example possible:


// Find all top-level nodes.

metricNodes := map[*Node]struct{}{}

for _, oid := range toWalk {

metricNode, oidType := getMetricNode(oid, node, nameToNode)

switch oidType {

case oidNotFound:


if *failOnOidNotFound {
return nil, fmt.Errorf("cannot find oid '%s' to walk", oid)
}
level.Warn(logger).Log("msg", " cannot find oid", "oid", oid)
continue

case oidSubtree:

needToWalk[oid] = struct{}{}

case oidInstance:

// Add a trailing period to the OID to indicate a "Get" instead of a "Walk".

needToWalk[oid+"."] = struct{}{}

// Save instance index for lookup.

index := strings.Replace(oid, metricNode.Oid, "", 1)

tableInstances[metricNode.Oid] = append(tableInstances[metricNode.Oid], index)

case oidScalar:

// Scalar OIDs must be accessed using index 0.

needToWalk[oid+".0."] = struct{}{}

}

metricNodes[metricNode] = struct{}{}

}

Brian Candler

unread,
Jul 31, 2021, 4:52:25 AM7/31/21
to Prometheus Users
I'm sorry, it's not clear: is this a question? A statement? Or a proposal for something to change?

My best guess is it's the latter.  If so, can you provide a use case when this would be helpful?

I note that this is a change to the generator, not the exporter. It means that if you run the generator, but have forgotten to install the necessary MIBs, then it will carry on and ignore the missing MIBs, and therefore generate an incorrect/incomplete snmp.yml output.

Maybe you don't have those MIBs, but surely in this case it would be better to update generator.yml to remove the MIBs you are not interested in?  This makes it explicit that you don't want these MIBs to be included in snmp.yml.

qingtao wu

unread,
Jul 31, 2021, 9:45:25 AM7/31/21
to Prometheus Users
Yes, this is a  proposal.

Others have told me that I need to monitor some OIDs and have provided a private MIB file, but when the generator works, it only tells me the first OID not found.

 In this case, I need to delete the added OID and run again, repeating several times to find all the invalid OIDs.

Brian Candler

unread,
Jul 31, 2021, 11:05:10 AM7/31/21
to Prometheus Users
If you run the generator, and it can't find a required MIB, it stops to give you an opportunity to install the correct MIB.  But if I understand you correctly, you're saying it's inconvenient to install one missing MIB, run generator again, only to find there's another missing MIB, and so on.  You'd rather see all the problems at once.

In that case, I think a better solution would be to continue running, and then abort at the end.  No extra flag like "fail-on-oid-notfound" would be required then.

However I suspect it could generate a very noisy output, because MIBs have dependencies on each other: one missing MIB high up in the tree could result in many errors being reported.  Equally, many tables may all come from the same missing MIB, so listing all the table names may not be all that helpful.

However, you could certainly try implementing this and see if it behaves sensibly. Just print an error and set a fail flag on oidNotFound.

qingtao wu

unread,
Aug 1, 2021, 12:23:18 AM8/1/21
to Prometheus Users
Thanks!

You are right, the snmp.yml file should not be generated when the OID does not exist.

I have now modified the generator code locally so that if any OID does not exist, print an error containing all missing OIDS without exiting until all module traversal is complete. If the OID of any module is missing, print "Some OID missing".

But I don't know if anyone else needs it.

Ben Kochie

unread,
Aug 1, 2021, 6:46:45 AM8/1/21
to Brian Candler, Prometheus Users
Part of the difficulty is that we wrap the net-snmp C library in Go. The error response of the library isn't all that easy to work with.

There are some options for pure-Go MIB parsing now, but converting the generator to this would take some work.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/fd5b01d0-426d-4a63-a0ee-1013866c9ea0n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages