mibble-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Mibble-users] parse TRAP-TYPE


From: Per Cederberg
Subject: Re: [Mibble-users] parse TRAP-TYPE
Date: Tue, 28 May 2013 14:17:07 +0200

Yes, I think that will work in your case. MIB types are pretty complex sometimes and there are a number of variations that might cause bugs here and there. Currently, Mibble doesn't do quite enough to simplify this, but provides a rather "raw" (but complete) API to accessing the data.

Anyway, check out the source code for net.percederberg.mibble.MibWriter for tips on how to extract certain information from the parsed MIB tree.

Cheers,

/Per


On Tue, May 28, 2013 at 2:11 PM, "Tim Schöndorfer" <address@hidden> wrote:
Ok i have found a solution :

Mib mib = loader.load(mibfiles.get(i));

System.out.println(mib.getSymbolByOid("1.3.6.1.2.1.2.2.1.7.7").getName());

MibValueSymbol sy = mib.getSymbolByOid("1.3.6.1.2.1.2.2.1.7.7");

SnmpObjectType sno = (SnmpObjectType) sy.getType();

System.out.println(sno.getSyntax());

if(sno.getSyntax() instanceof IntegerType){

IntegerType in = (IntegerType) sno.getSyntax();

MibValueSymbol[] syin = in.getAllSymbols();

for(int j = 0; j<syin.length;j++){

if(syin[j].getValue().toString().contains("1")){

System.out.println(syin[j].getName());

}

}

}

i think i'm starting to have understood Mibble

Thanks,

Tim

 
 
Gesendet: Dienstag, 28. Mai 2013 um 13:42 Uhr
Von: "Tim Schöndorfer" <address@hidden>

An: "Announcements, support, and forum for Mibble users" <address@hidden>
Betreff: Re: [Mibble-users] parse TRAP-TYPE
Thank you for the fast answer.
 
I solved it with the iterator.
But now i have another problem with the use of mibble.
Some integer values have a specific meaning for example 1.3.6.1.2.1.2.2.1.8 (ifOperStatus) when i receive one thats mean its up , 2 for down and so on
How can i get this meanings from the mib ?
I try to get the MibValueSymbol with this function --> MibValueSymbol sy = mib.getSymbolByOid("1.3.6.1.2.1.2.2.1.8");
How can i search in this mibvaluesymbol for the valuedefintions ?
 
Thanks a lot,
 
Tim
Gesendet: Dienstag, 28. Mai 2013 um 13:24 Uhr
Von: "Per Cederberg" <address@hidden>
An: "Announcements, support, and forum for Mibble users" <address@hidden>
Betreff: Re: [Mibble-users] parse TRAP-TYPE
Yes, the TRAP-TYPE is parsed and accessible in Mibble. But in SMIv1, the traps aren't assigned to OIDs, so they are a bit more tricky to find. Basically you search for them with their numeric value ("1", "2", etc):
 
   mib.getSymbolByValue("1")
 
Or you can find the traps by iterating over all MibValueSymbol instances, filtering out the symbols with a type that is instanceof SnmpTrapType.
 
You can always inspect the parsed results by using the MibblePrinter utility (which pretty-prints the parsed MIB). A small example for RFC1382-MIB:

#> bin/MibblePrinter.sh src/mibs/ietf/RFC1382-MIB

x25Restart TRAP-TYPE
    ENTERPRISE      x25
    VARIABLES       { x25OperIndex }
    DESCRIPTION
            "This trap means the X.25 PLE sent or
            received a restart packet.  The restart that
            brings up the link should not send a
            x25Restart trap so the interface should send
            a linkUp trap.  Sending this trap means the
            agent does not send a linkDown and linkUp
            trap."
    ::= 1
 
Cheers,
 
/Per
 
On Tue, May 28, 2013 at 8:19 AM, "Tim Schöndorfer" <address@hidden> wrote:
Hello,
 
I writing a snmp-trapreceiver with mibble. But mibble can not find the trap in the MIB-file (i think thats because the trap isnt a object-type, it is save in the mib as a TRAP-TYPE).
I spending much time on search for a solution, but i didnt find a way to parse the mib file and get the trap description or the trap name. The traps are snmp v1 traps so i get the enterprise oid and a specific number from the trap pdu and i try to parse the mib file with "Mib mib = MibLoader.load(Mib-File) and mib.getSymbolByOid(EnterpriseOid+.0.+specificNumber);" but this doenst work(it only works with normal OIDs). So how can i parse a mib-file with mibble to get the TRAP-TYPEs?
 
Thanks, Tim Schöndorfer

_______________________________________________
Mibble-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/mibble-users
 

_______________________________________________
Mibble-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/mibble-users



reply via email to

[Prev in Thread] Current Thread [Next in Thread]