Getting error in generating config file using generator

828 views
Skip to first unread message

Monica

unread,
Apr 11, 2023, 10:53:42 AM4/11/23
to Prometheus Users
Hi All,

I am trying to generate snmp.yml by using the generator binary. Below is the sample of my generator file :-

modules:
  HPE_3PAR:
    walk:
      - ldskHasFailedSet

While generating the same I am getting below error, however snmptranslate is working fine for the same-:

level=info ts=2023-04-10T19:15:14.879Z caller=net_snmp.go:142 msg="Loading MIBs" from=mibs
level=warn ts=2023-04-10T19:15:14.883Z caller=main.go:120 msg="NetSNMP reported parse error(s)" errors=595
level=info ts=2023-04-10T19:15:14.883Z caller=main.go:52 msg="Generating config for module" module=HPE_3PAR
level=error ts=2023-04-10T19:15:14.884Z caller=main.go:130 msg="Error generating config netsnmp" err="cannot find oid 'storeServAlertsGroup' to walk"
[root@hos

Brian Candler

unread,
Apr 11, 2023, 11:16:06 AM4/11/23
to Prometheus Users
It looks like you're missing some MIB files. It's quite common for some MIB files to depend on other MIB files, so you need to fetch the dependencies too.

Monica

unread,
Apr 12, 2023, 4:26:49 AM4/12/23
to Prometheus Users
Hi Brian,

Thank you so much for the update. I have copied the entire folder from one of my prod servers and the OS version and other dependencies are also same. However, the issue still persists.
Could you pls help me on this. 
Message has been deleted

Monica

unread,
Apr 13, 2023, 11:29:14 PM4/13/23
to Prometheus Users
Hi,
Pls reply

Brian Candler

unread,
Apr 14, 2023, 3:09:15 AM4/14/23
to Prometheus Users
Unless you show exactly which MIB files you're using and where to obtain them (the exact download URLs), all I can really say is "there's a problem with your MIB files".

The error suggests you're loading a MIB file contains a reference to "storeServAlertsGroup" which should be in some other MIB file, but you're missing that other MIB file.  Or else there's an error in the MIB file (broken MIB files are not that uncommon, unfortunately).

Monica

unread,
Apr 14, 2023, 8:05:58 AM4/14/23
to Prometheus Users
Hi Brian,

Thank you for the update. could you pls share your email ID, will share the exact MIB file to you.

Thanks in advance!!

Brian Candler

unread,
Apr 14, 2023, 8:25:02 AM4/14/23
to Prometheus Users
No, it doesn't work like that: see http://www.eyrie.org/~eagle/faqs/questions.html and http://www.catb.org/~esr/faqs/smart-questions.html#noprivate

If the MIB files you're using are available for public download, and you want us to help you, then please post the URLs of the files you are using publicly.

If you have the MIB files under some sort of private arrangement or non-disclosure agreement, then please say so and we'll understand. We won't be able to help you in this forum, but you could look at getting paid support from one of various orgs which provide Prometheus consultancy.

Monica

unread,
Apr 14, 2023, 8:35:11 AM4/14/23
to Prometheus Users
Hello Brian,

No it's not confidential, same is available for public download. PFA MIB file FYR.

mibfile.txt

Brian Candler

unread,
Apr 14, 2023, 10:08:36 AM4/14/23
to Prometheus Users
OK.

At first glance, I see you're trying to walk OID "ldskHasFailedSet", but that's not a table, that's a NOTIFICATION-TYPE object. Presumably this is an OID which would be used in a trap message, not an OID that you can poll using get/getbulk.  Therefore, I think even if you get the generator to work, it's not going to do anything useful.

However, the problem you have appears to be down to how you're running the generator and the mib files you're providing (or not providing). Since the generator uses net-snmp to parse the files, you can get a more detailed error if you run the "snmptranslate" command.

e.g. suppose you have the mib file in a subdirectory called "mibs" within the current directory (but no other mibs are in that directory), and you run the following command:

$ MIBDIRS=mibs MIBS=: snmptranslate -On ThreeParMIB::ldskHasFailedSet
No log handling enabled - using stderr logging
MIB search path: mibs
Cannot find module (SNMPv2-TC): At line 74 in mibs/ThreeParMIB.mib
Cannot find module (SNMPv2-SMI): At line 79 in mibs/ThreeParMIB.mib
Module not found (SNMPv2-MIB): At line 236 in mibs/ThreeParMIB.mib
Module not found (SNMPv2-MIB): At line 251 in mibs/ThreeParMIB.mib
Did not find 'DisplayString' in module #-1 (mibs/ThreeParMIB.mib)
Did not find 'enterprises' in module #-1 (mibs/ThreeParMIB.mib)
Unlinked OID in ThreeParMIB: threepar ::= { enterprises 12925 }
Undefined identifier: enterprises near line 81 of mibs/ThreeParMIB.mib
ThreeParMIB::ldskHasFailedSet: Unknown Object Identifier

You can see all the other mib files it's referring to, and failing to find.

Next, suppose you have a checkout of the snmp_exporter git repository, and you are in the "generator" subdirectory. Now you type "make generate" which fetches all the dependent mibs. After doing this, you copy the TreeParMIB.mib file into the mibs subdirectory in addition to those already there.

Now we see:

$ MIBDIRS=mibs MIBS=: snmptranslate -On ThreeParMIB::ldskHasFailedSet
.1.3.6.1.4.1.12925.1.2.0.21

Successful.  (I strongly recommend you use the mibs downloaded by "make generate", not any mibs you happen to have lying around on your system; those are often broken).

Now you can run the generator, replacing generator.yml with the one you supplied:

$ MIBDIRS=mibs ~/go/bin/generator generate
ts=2023-04-14T14:02:32.239Z caller=net_snmp.go:161 level=info msg="Loading MIBs" from=mibs
ts=2023-04-14T14:02:32.660Z caller=main.go:119 level=warn msg="NetSNMP reported parse error(s)" errors=2
ts=2023-04-14T14:02:32.739Z caller=main.go:51 level=info msg="Generating config for module" module=HPE_3PAR
ts=2023-04-14T14:02:32.762Z caller=main.go:66 level=info msg="Generated metrics" module=HPE_3PAR metrics=0
ts=2023-04-14T14:02:32.764Z caller=main.go:91 level=info msg="Config written" file=/Users/brian/git/snmp_exporter/generator/snmp.yml

This has successfully generated an snmp.yml:

$ cat snmp.yml
# WARNING: This file was auto-generated using snmp_exporter generator, manual changes will be lost.
HPE_3PAR:
  walk:
  - 1.3.6.1.4.1.12925.1.2.0.21
  metrics: []

Don't worry about the "errors=2".  I can see that "make generate" also says there are 2 errors; this must be some other issue in the set of MIBs.

Anyway: that's how you run the generator to create snmp.yml.  But in order to get useful results, you'll have to select an OID tree that's actually walkable.

Brian Candler

unread,
Apr 14, 2023, 12:11:45 PM4/14/23
to Prometheus Users
On Friday, 14 April 2023 at 15:08:36 UTC+1 Brian Candler wrote:
Don't worry about the "errors=2".  I can see that "make generate" also says there are 2 errors; this must be some other issue in the set of MIBs.

 
Workaround:
sed -i '' -e 's/\(DisplayString[[:space:]]*FROM \)RFC1213-MIB/\1SNMPv2-TC/' mibs/CyberPower.MIB mibs/apc-powernet-mib

Reply all
Reply to author
Forward
0 new messages