how to load custom mib file to snmpd agent

331 views Asked by At

I'm running snmpd in docker (polinux/snmpd:alpine image) and I want to use my custom mib file with my OIDs objects of different data types that I prepared for testing purposes and validated it by 2 different online mib validators then I fixed all errors that they pointed out to me and now my file should be ok, but I still can't find my oids by snmpwalk or my module by snmptranslate. Here is what I tried:

  1. pass -m <mib file> or/and -M <mibs dir> arguments to snmpd - didn't work
  2. add
mibdirs +/etc/snmpd/
mibs +ALL

to the snmpd.conf file - didn't work either

Am I missing something? What could be wrong?

My mib:

MY-MIB DEFINITIONS ::= BEGIN

IMPORTS
    MODULE-IDENTITY,
    OBJECT-TYPE,
    Counter32,
    Counter64,
    Gauge32,
    TimeTicks,
    IpAddress
        FROM SNMPv2-SMI
        DisplayString, TimeStamp
        FROM SNMPv2-TC
        OBJECT-GROUP
        FROM SNMPv2-CONF;

myMIB MODULE-IDENTITY
    LAST-UPDATED "202310110000Z"
    ORGANIZATION "My Organization"
    CONTACT-INFO "[email protected]"
    DESCRIPTION "Example Custom MIB"
    REVISION "202310110000Z"
    DESCRIPTION "Initial revision"
    ::= { iso(1) identified-organization(3) dod(6) internet(1) private(4) enterprises(1) 9999 }
    
myObjects OBJECT IDENTIFIER ::= { myMIB 1 }
    
myObjectGroup OBJECT-GROUP
    OBJECTS { myBits,
              myCounter32,
              myCounter64,
              myGauge,
              myInteger,
              myIpAddress,
              myOctetString,
              myString,
              myTimeTicks }
    STATUS current
    DESCRIPTION
        "A group of my objects."
    ::= { myMIB 2 }

myString OBJECT-TYPE
    SYNTAX      DisplayString
    MAX-ACCESS  read-write
    STATUS      current
    DESCRIPTION "Example scalar object"
    DEFVAL { "example" }
    ::= { myObjects 1 }


myInteger OBJECT-TYPE
    SYNTAX      INTEGER
    MAX-ACCESS  read-only
    STATUS      current
    DESCRIPTION "Example integer object"
    DEFVAL { 1 }
    ::= { myObjects 2 }


myCounter32 OBJECT-TYPE
    SYNTAX      Counter32
    MAX-ACCESS  read-only
    STATUS      current
    DESCRIPTION "Example counter object"
    ::= { myObjects 3 }


myCounter64 OBJECT-TYPE
    SYNTAX      Counter64
    MAX-ACCESS  read-only
    STATUS      current
    DESCRIPTION "Example counter object"
    ::= { myObjects 4 }


myGauge OBJECT-TYPE
    SYNTAX      Gauge32
    MAX-ACCESS  read-only
    STATUS      current
    DESCRIPTION "Example gauge object"
    DEFVAL { 1 }
    ::= { myObjects 5 }


myTimeTicks OBJECT-TYPE
    SYNTAX      TimeTicks
    MAX-ACCESS  read-only
    STATUS      current
    DESCRIPTION "Example timeticks object"
    DEFVAL { 1 }
    ::= { myObjects 6 }


myIpAddress OBJECT-TYPE
    SYNTAX IpAddress
    MAX-ACCESS read-write
    STATUS current
    DESCRIPTION "My IPADDRESS object"
    DEFVAL { 'c0210415'H } -- 192.33.4.21
    ::= { myObjects 7 }


myOctetString OBJECT-TYPE
    SYNTAX OCTET STRING (SIZE(0..255))
    MAX-ACCESS read-write
    STATUS current
    DESCRIPTION "My OCTET STRING object"
    DEFVAL { "255" }
    ::= { myObjects 8 }


myBits OBJECT-TYPE
    SYNTAX BITS {
                bit1(0),
                bit2(1),
                bit3(2)
            }
    MAX-ACCESS read-write
    STATUS current
    DESCRIPTION "My BITS object"
    DEFVAL { { bit1 } }
    ::= { myObjects 9 }


END
1

There are 1 answers

1
sbusgs On

This is probably not the best answer, but it works.

Put MIB file in /usr/share/snmp/mibs

snmp.conf: mibs +MY-MIB

I have never gotten the mibdirs directive to work