开发者

Mibble MIB Parser - extracting comments from the mib

开发者 https://www.devze.com 2022-12-15 06:05 出处:网络
I am using the Mibble MIB Parser to extract all simple data types from an MIB file. I\'ve been successful until my attempt to extract comment text.

I am using the Mibble MIB Parser to extract all simple data types from an MIB file. I've been successful until my attempt to extract comment text.

Take the following module as an example:

invBookLis开发者_如何学JAVAt OBJECT-TYPE
    SYNTAX  INTEGER {
                    mobydick(1),     -- call me ishmael 
                    paradiselost(2), -- aComment
                    1984(3),         -- aComment
                    solaris(4)       -- aComment
            }
    MAX-ACCESS      read-only
    STATUS          current
    DESCRIPTION
            "A few Books for an example."
    ::= { invMasterList 43 }

According to Mibble's API, the OBJECT-TYPE can be accessed by extracting an SnmpObjectType and then calling the appropriate getter method. Which I have done, and can successfully extract all of the text except the comments in the INTEGER syntax.

I have tried calling getSyntax().getComment() on the SnmpObjectType, but always returns null. getSyntax() will extract the INTEGER syntax, e.g.:

mobydick(1),paradiselist(2),1984(3),solaris(4)

but unfortunately strips out the comments.

Any one out there have experience with Mibble Parser who knows how to extract the comments?

Many Thanks.


First, you need to use version 2.9 of Mibble. Then look into MibWriter.java to understand how to use the API:

https://github.com/cederberg/mibble/blob/master/src/java/net/percederberg/mibble/MibWriter.java

0

精彩评论

暂无评论...
验证码 换一张
取 消