如何为MIB表生成代码

时间:2011-06-10 07:58:19

标签: snmp

我有一个KAVITA-MIB:

KAVITA-MIB DEFINITIONS ::= BEGIN

IMPORTS
    OBJECT-TYPE,MODULE-IDENTITY     FROM SNMPv2-SMI
    TEXTUAL-CONVENTION              FROM SNMPv2-TC;

kavita MODULE-IDENTITY
     LAST-UPDATED "200205290000Z"            -- 29 May 2002, midnight
     ORGANIZATION "net-snmp"
     CONTACT-INFO "postal:   Wes Hardaker
                             P.O. Box 382
                             Davis CA  95617

                   email:    net-snmp-coders@lists.sourceforge.net"
     DESCRIPTION  "A simple mib for demonstration purposes."

::={enterprises 1100}

RowStatus ::= TEXTUAL-CONVENTION
    STATUS       current
    DESCRIPTION
        "The RowStatus textual convention is used to manage the
        creation and deletion of conceptual rows, and is used as the
        value of the SYNTAX clause for the status column of a
        conceptual row."
    SYNTAX   INTEGER {
         -- the following two values are states:
         -- these values may be read or written
         active(1),          -- state:  read/write
         notInService(2),    -- state:  read/write
         notReady(3),        -- state:  read only
         createAndGo(4),     -- action: write only
         createAndWait(5),   -- action: write only
         destroy(6)      -- action: write only
    }


    kavitaScalar OBJECT IDENTIFIER ::= {kavita 1}
    kavitaTable OBJECT IDENTIFIER ::= {kavita 2}

    scalar1 OBJECT-TYPE
        SYNTAX      Integer32
        MAX-ACCESS  read-write
        STATUS      current
        DESCRIPTION "scalar1"
    DEFVAL { 2 }
    ::= { kavitaScalar 1 }

    scalar2 OBJECT-TYPE
        SYNTAX      Integer32
        MAX-ACCESS  read-write
        STATUS      current
        DESCRIPTION "scalar2"
        DEFVAL { 4 }
    ::= { kavitaScalar 2 }

    kavitaTableOne OBJECT-TYPE
        SYNTAX      SEQUENCE OF kavitaTable1Entry
        MAX-ACCESS  not-accessible
        STATUS      current
        DESCRIPTION "Table 1"
    ::= { kavitaTable 1 }

    kavitaTable1Entry OBJECT-TYPE
        SYNTAX      kavitaTable1Entry
        MAX-ACCESS  not-accessible
        STATUS      current
        DESCRIPTION "Entry"
        INDEX { tIndex }
    ::= { kavitaTableOne 1 }

    kavitaTable1Entry ::= SEQUENCE {
        tIndex      Integer32,
        tName       DisplayString,
        tMarks      Integer32,
        tRowStatus  INTEGER
    }

    tIndex OBJECT-TYPE
        SYNTAX      Integer32 (1..100)
        MAX-ACCESS  read-only
        STATUS      current
        DESCRIPTION "Index for Table 1"
    ::= { kavitaTable1Entry 1 }

    tName OBJECT-TYPE
        SYNTAX      DisplayString
        MAX-ACCESS  read-create
        STATUS      current
        DESCRIPTION "Name for Table 1"
    ::= { kavitaTable1Entry 2 }

    tMarks OBJECT-TYPE
        SYNTAX      Integer32(1..100)
        MAX-ACCESS  read-create
        STATUS      current
        DESCRIPTION "Marks for Table 1"
    ::= { kavitaTable1Entry 3 } 


    tRowStatus OBJECT-TYPE
        SYNTAX     RowStatus
        MAX-ACCESS read-create
        STATUS     current
        DESCRIPTION "The status"
    ::= { kavitaTable1Entry 4 }      

END

我应该如何为“kavitaTableOne”生成mib2c代码。

我尝试过使用过  env MIBS =“+ KAVITA-MIB”MIBDIRS =“/ usr / share / snmp / mibs”mib2c -c mib2c.mfd.conf kavitaTableOne

但它说 KAVITA-MIB中未链接的OID:kavita :: = {企业1100} 未定义的标识符:/usr/share/snmp/mibs/KAVITA-MIB.txt第7行附近的企业 此模块只能用于表,而不能用于分支或整个MIB。 请指定和OID是一个表。 (OID:kavitaTableOne)

请帮助......

2 个答案:

答案 0 :(得分:0)

在MIB的顶部,您可以先重复:

kavita        OBJECT IDENTIFIER ::= { enterprises 1100 }

之后尝试编译:

env MIBS="+KAVITA-MIB" mib2c kavitaTable

答案 1 :(得分:0)

您缺少导入enterprises

IMPORTS
    OBJECT-TYPE,MODULE-IDENTITY,enterprises     FROM SNMPv2-SMI