how to generate C code using mib2c command - Ubuntu/Linux?

Bali Vinayak Source

Here is my MIB File -

Battery-MIB

batteryTable OBJECT-TYPE
    SYNTAX     SEQUENCE OF BatteryEntry
    MAX-ACCESS not-accessible
    STATUS     current
    DESCRIPTION
        "The (conceptual) table of batteries contained by the
        module."
    ::= { monitor 1 }

batteryEntry OBJECT-TYPE
    SYNTAX     BatteryEntry
    MAX-ACCESS not-accessible
    STATUS     current
    DESCRIPTION
        "A (conceptual) entry for one battery contained by
        the module.  The batteryIndex in the index represents
        the entry in the batteryTable that corresponds to the
        batteryEntry.

        As an example of how objects in this table are named,
        an instance of the batteryVoltage object might be
        named batteryVoltage.3"
    INDEX { batteryIndex }
    ::= { batteryTable 1 }

batteryIndex OBJECT-TYPE
    SYNTAX      DeviceIndex
    MAX-ACCESS  read-only
    STATUS      current
    DESCRIPTION
            "A unique value, greater than zero, for each battery. 
            It is recommended that values are assigned contiguously
            starting from 1."
    ::= { batteryEntry 1 }

batteryVoltage    OBJECT-TYPE 
   SYNTAX Integer32 
   ACCESS read-only 
   STATUS current 
   DESCRIPTION 
      "Voltage A/D value" 
   ::= { batteryEntry 2 }

I am trying to generate c code using this MIB file. However, I am getting a lot of errors. I tried debugging it using

#export MIBS="+Battery-MIB"
#snmptranslate -Dparse -IR batteryVoltage

I get the following dParse information

parse-mibs: Checking file: /usr/share/mibs/ietf/MIP-MIB...
parse-mibs:   Module 329 MIP-MIB is in /usr/share/mibs/ietf/MIP-MIB
parse-mibs: Checking file: /usr/share/mibs/ietf/T11-FC-FABRIC-LOCK-MIB...
parse-mibs:   Module 330 T11-FC-FABRIC-LOCK-MIB is in /usr/share/mibs/ietf/T11-FC-FABRIC-LOCK-MIB
parse-mibs: Checking file: /usr/share/mibs/ietf/HPR-IP-MIB...
parse-mibs:   Module 331 HPR-IP-MIB is in /usr/share/mibs/ietf/HPR-IP-MIB
parse-mibs: Checking file: /usr/share/mibs/ietf/DOCS-CABLE-DEVICE-MIB...
parse-mibs:   Module 332 DOCS-CABLE-DEVICE-MIB is in /usr/share/mibs/ietf/DOCS-CABLE-DEVICE-MIB
parse-mibs: Checking file: /usr/share/mibs/ietf/PARALLEL-MIB...
parse-mibs:   Module 333 PARALLEL-MIB is in /usr/share/mibs/ietf/PARALLEL-MIB
parse-mibs: Checking file: /usr/share/mibs/ietf/SYSLOG-TC-MIB...
parse-mibs:   Module 334 SYSLOG-TC-MIB is in /usr/share/mibs/ietf/SYSLOG-TC-MIB
parse-mibs: Scanning directory /usr/share/mibs/netsnmp
parse-mibs: No index
parse-mibs: Checking file: /usr/share/mibs/netsnmp/Battery-MIB...
Unknown object identifier: batteryVoltage

What is wrong here? How to generate the c code from this MIB?

clinuxsnmpnet-snmpmib

Answers

comments powered by Disqus