0

I add my own MIB module to net-snmp.

I put my Mib txt file under - '/usr/local/share/snmp/mibs'

I see that if i change net-snmp files their the change is reflected , so this mibs are loaded correct. It seems that it not load my MIB file from there.

When i run snmptranslate on my Mib like this:

snmptranslate .1.3.6.1.4.1.8077

I get:

SNMPv2-SMI::enterprises.8077

My MIB def:

TEST-MIB DEFINITIONS ::= BEGIN
IMPORTS
    MODULE-IDENTITY, enterprises FROM SNMPv2-SMI;

testMib MODULE-IDENTITY
    DESCRIPTION
    "First draft"
    ::= { enterprises 8077}

testMibObject              OBJECT IDENTIFIER ::= {testMib 1}


END
Avihai Marchiano
  • 612
  • 3
  • 16
  • 32

2 Answers2

2

To find the location of snmp.conf you can use :

snmpd -Dread_config -H 2>&1 | grep "config path" | sort –u

then tell the tools to load this MIB

(examples)::

    snmpwalk -m +MY-MIB .....

        (load it for this command only)

or

    export MIBS=+MY-MIB

        (load it for this session only)

or

    echo "mibs +MY-MIB" >> $HOME/.snmp/snmp.conf

        (load it every time)
Avihai Marchiano
  • 612
  • 3
  • 16
  • 32
0

Here you can find references for all situations: Using and loading MIBS

I saved your MIB to a file TEST-MIB, placed it under /usr/share/snmp/mibs and snmptranslate is able to find the testMib object, although your MIB is missing some fields to properly conform to the standard:

$ snmptranslate .1.3.6.1.4.1.8077
No log handling enabled - using stderr logging
Expected LAST-UPDATED (DESCRIPTION): At line 6 in /usr/share/snmp/mibs/TEST-MIB
TEST-MIB::testMib

For making your MIBs conform you can use the tool smidump, which will tell you everything your MIB is missing to properly conform:

$ smidump /usr/share/snmp/mibs/TEST-MIB 
/usr/share/snmp/mibs/TEST-MIB:6: syntax error, unexpected DESCRIPTION, expecting LAST_UPDATED
/usr/share/snmp/mibs/TEST-MIB:13: missing MODULE-IDENTITY clause in SMIv2 MIB
/usr/share/snmp/mibs/TEST-MIB:10: unknown object identifier label `testMib'
smidump: module `/usr/share/snmp/mibs/TEST-MIB' contains errors, expect flawed output
smidump: aborting due to severe parsing errors
smidump: use the -k option to force continuation
Claudio
  • 159
  • 6
  • This wasnt enough. i place it there, but in additional i need to create snmp.conf and define the mib file there – Avihai Marchiano Oct 31 '12 at 12:39
  • Did you already create this snmp.conf file with something like this inside? `mibs +TEST-MIB` (In my system it works without this, but it might help) – Claudio Oct 31 '12 at 12:41
  • I didnt have this file, so i added this file with 2 lines: mibfile and mibs (i think that mibfile is sufficient) , but without this file it wasnt work unless you do export for the session – Avihai Marchiano Oct 31 '12 at 12:43