Question

Actually I'm trying to generate .h & .c files by given sysSwYear as MIBNODE and I'm using following command:

mib2c -c mib2c.scalar.conf sysSwYear

but it produces the following error:

You didn't give mib2c a valid OID to start with. IE, I could not find any information about the mib node "sysSwYear.0". This could be caused because you supplied an incorrectly node, or by the MIB that you're trying to generate code from isn't loaded. To make sure your mib is loaded, run mib2c using this as an example:

   env MIBS="+MY-PERSONAL-MIB" mib2c -c mib2c.scalar.conf sysSwYear.0

You might wish to start by reading the MIB loading tutorial at:

http://www.net-snmp.org/tutorial-5/commands/mib-options.html

And making sure you can get snmptranslate to display information about your MIB node. Once snmptranslate works, then come back and try mib2c again.

I have already done everything needed like setting environment variable for MIB and defining a private MIB file in /usr/share/snmp/mibs ...but still no success. What to do?

Was it helpful?

Solution

You need to do exactly what it says: get the MIB to load first into the parser. Start with using snmptranslate to make sure you can load and parse the MIB:

# export MIBS="+NAME-OF-YOUR-MIB"
# snmptranslate -IR sysSwYear

If that doesn't work, then your MIB isn't being found or loaded because it has errors (or both). If so, run snmptranslate with the -Dparse option and it'll give you way too much information about what it's doing, but it'll let you know where the problems are if you read it all.

Once snmptranslate works as above, then mib2c should work fine (assuming you leave the MIBS environment variable set).

[note: I used export assuming you're using a sh-based shell; use setenv instead and no = sign if you are using a csh-based shell]

OTHER TIPS

If you are on Linux, the default permissions for /var/lib/net-snmp/mib_indexes are 0700 resulting in interesting errors for normal users.

The fix for this is

linux ~ $ mkdir -p ~/.snmp/persist
linux ~ $ echo "persistentDir ~/.snmp/persist" >> ~/.snmp/snmp.conf

Try this if the commands work for superuser but not normal users. Please note that the accepted answer is right but does not address using those commands as a normal user as denoted by '#'.

I found it more intuitive to issue the command as follows:

mib2c -c mib2c.scalar.conf MY-PERSONAL-MIB::sysSwYear.0

The mib must be in one of the directories listed in the output of the following command:

linux ~ $ net-snmp-config --default-mibdirs
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top