【问题标题】:SNMP MIB SMIv2 Conformance Group IssueSNMP MIB SMIv2 一致性组问题
【发布时间】:2013-05-25 06:52:12
【问题描述】:

我有一个开始工作的 MIB,但 smilint 抱怨缺少一致性组。如何将此一致性组添加到我的文件中?

BLEH-PRODUCT-MIB DEFINITIONS ::= BEGIN

-- Objects in this MIB are implemented in the local SNMP agent.

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

   blehProductMIB MODULE-IDENTITY
     LAST-UPDATED "201305290000Z"
     ORGANIZATION "Bleh Corporation"
     CONTACT-INFO "           Joe Shmoe
                   Postal:    Bleh Corporation
                              23 Telnet Road
                              Ottawa, ON, K1K 1K1
                              Canada

                   Tel:       +1 555 555 5555 x5555
                   Fax:       +1 555 555 5556
                   E-mail:    joe.shmoe@bleh.com"
     DESCRIPTION "MIB module describing Product objects."
     REVISION    "201305290000Z"
     DESCRIPTION "Initial"
     ::= { bleh 911 }

   bleh              OBJECT IDENTIFIER ::= { enterprises 54321 }

   productStatus OBJECT-TYPE
           SYNTAX       OCTET STRING (SIZE (0..65535))
           MAX-ACCESS   read-only
           STATUS       current
           DESCRIPTION  "The status of the Product system
                         Details are shown as text"
           ::= { blehProductMIB 1 }


   binaryProductStatus OBJECT-TYPE
           SYNTAX      Integer32 (0..1)
           MAX-ACCESS  read-only
           STATUS      current
           DESCRIPTION "The status of the Product system
                        Zero is unhealthy and One is healthy"
           ::= { blehProductMIB 2 }
END

smilint的输出:

$ smilint ./BLEH-PRODUCT-MIB 
./BLEH-PRODUCT-MIB:28: warning: node `productStatus' must be contained in at least one conformance group
./BLEH-PRODUCT-MIB:37: warning: node `binaryProductStatus' must be contained in at least one conformance group

【问题讨论】:

    标签: snmp asn.1 mib


    【解决方案1】:

    这只是意味着您应该在 MIB 文档中定义 OBJECT-TYPE 实体之前定义 OBJECT-GROUP 实体。

    以 RFC 1907 为例,

    https://www.rfc-editor.org/rfc/rfc1907

    snmpGroup OBJECT-GROUP
        OBJECTS { snmpInPkts,
                  snmpInBadVersions,
                  snmpInASNParseErrs,
                  snmpSilentDrops,
                  snmpProxyDrops,
                  snmpEnableAuthenTraps }
        STATUS  current
        DESCRIPTION
                "A collection of objects providing basic instrumentation and
                control of an SNMPv2 entity."
        ::= { snmpMIBGroups 8 }
    

    先定义,再定义

    snmpInPkts OBJECT-TYPE
        SYNTAX     Counter32
        MAX-ACCESS read-only
        STATUS     current
        DESCRIPTION
                "The total number of messages delivered to the SNMP entity
                from the transport service."
        ::= { snmp 1 }
    

    关于为什么组很重要,您可以阅读 RFC 2580。

    https://www.rfc-editor.org/rfc/rfc2580

    由于您要定义组,因此建议添加关联的 MODULE-COMPLIANCE。

    【讨论】:

    • 好的,但是 oid 呢?我应该把它设置成什么?另外如何避免对象组引用警告?我需要 MODULE COMPLIANCE 部分吗?
    • 没有关于 OID 选择的严格规定,但您可以遵循行业最佳实践(例如,tools.cisco.com/Support/SNMP/do/… 中的 Cisco 样式)。由于您要定义组,因此建议添加关联的 MODULE-COMPLIANCE。
    • 能否将 MODULE-COMPLIANCE 部分添加到您的答案中,以便我接受?
    【解决方案2】:

    这有点晚了,但我最近一直在努力解决对象组、通知组、模块合规性的问题。 smilint 给了我错误。然后我把所有的部分放在一起,创造了这个。现在即使使用自闭症 smilint -l 6 也可以通过

    TEMPORARY-RESEARCH-MIB DEFINITIONS ::= BEGIN
    
    
    IMPORTS
                          MODULE-IDENTITY, OBJECT-TYPE, enterprises, Integer32, NOTIFICATION-TYPE FROM SNMPv2-SMI
                          OBJECT-GROUP, NOTIFICATION-GROUP, MODULE-COMPLIANCE FROM SNMPv2-CONF;
    
    
    exampleCorp           MODULE-IDENTITY
                          LAST-UPDATED "202111241500Z"
                          ORGANIZATION
                             "Example corp ltd"
                          CONTACT-INFO
                            "Example corp address"
                          DESCRIPTION
                            "This MIB file contains definitions for the
                             Example corps next coolest product!"
                          REVISION "202111241500Z"
                          DESCRIPTION
                            "MIB file created"
                          ::= { enterprises 55555 }
    
    
    theSystem             OBJECT IDENTIFIER ::= { exampleCorp 10 }
    mibMeta               OBJECT IDENTIFIER ::= { theSystem 1 }
    productTypeOne        OBJECT IDENTIFIER ::= { theSystem 2 }      
    
    
    productObjects        OBJECT-GROUP
                          OBJECTS {
                            devTempAlarm,
                            devVoltAlarm
                          }
                          STATUS  current
                          DESCRIPTION
                            "A collection of objects providing support for
                             the system MIB."
                          ::= { mibMeta 1 }
    
    productNotifications  NOTIFICATION-GROUP
                          NOTIFICATIONS {
                            problemsTrap
                          }
                          STATUS  current
                          DESCRIPTION
                          "A collection of notifications providing support for
                           the system MIB."
                          ::= { mibMeta 2 }
    
    productCompliances    MODULE-COMPLIANCE
                          STATUS     current
                          DESCRIPTION
                            "Compliance statement for the the entities in this (theSystem) MIB."
                          MODULE
                          MANDATORY-GROUPS {
                            productObjects,
                            productNotifications
                          }
                          ::= { mibMeta 3 }
    
    -- Traps parent need to be always SOMEOID.0.
    -- Ie, the zero is important.
    trapsOne              OBJECT IDENTIFIER ::= { productTypeOne 0 }
    
    problemsTrap          NOTIFICATION-TYPE
                          STATUS  current
                          DESCRIPTION
                            "This trap is send automatically if problems are detected."
                          ::= { trapsOne 1 }
    
    trapDataTable         OBJECT-TYPE
                          SYNTAX  SEQUENCE OF DevEntry
                          MAX-ACCESS  not-accessible
                          STATUS  current
                          DESCRIPTION
                            "The table of Devices."
                          ::= { productTypeOne 1 }
    
    trapDataTableEntry    OBJECT-TYPE
                          SYNTAX  DevEntry
                          MAX-ACCESS  not-accessible
                          STATUS  current
                          DESCRIPTION
                            "The entry to show a row of device information."
                          INDEX { devIndex }
                          ::= { trapDataTable 1 }
    
    DevEntry              ::= SEQUENCE {
                            devIndex      Integer32,
                            devTempAlarm  Integer32,
                            devVoltAlarm  Integer32
                          }
    
    devIndex              OBJECT-TYPE
                          SYNTAX  Integer32(1..5)
                          MAX-ACCESS  not-accessible
                          STATUS  current
                          DESCRIPTION
                            "A unique value to index the device."
                          ::= { trapDataTableEntry  1 }
    
    devTempAlarm          OBJECT-TYPE
                          SYNTAX  Integer32(0..1)
                          MAX-ACCESS  read-only
                          STATUS  current
                          DESCRIPTION
                            "The state of the device temperature alarm:
                             0 = Alarm OFF,
                             1 = Alarm ON"
                         ::= { trapDataTableEntry  2 }
    
    devVoltAlarm         OBJECT-TYPE
                         SYNTAX  Integer32(0..1)
                         MAX-ACCESS  read-only
                         STATUS  current
                         DESCRIPTION
                           "The state of the device voltage alarm:
                            0 = Alarm OFF,
                            1 = Alarm ON"
                        ::= { trapDataTableEntry  3 }
    
    
    END
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多