cederberg / mibble Goto Github PK
View Code? Open in Web Editor NEWMibble is an open-source SNMP MIB parser library for Java.
Home Page: https://www.mibble.org/
License: Other
Mibble is an open-source SNMP MIB parser library for Java.
Home Page: https://www.mibble.org/
License: Other
First - great work!
Second - I'm going through code thinking about porting it to .NET Core. If I decide to do so - I'll contact you about licensing related stuff...
Question:
I've noted that in line https://github.com/cederberg/mibble/blob/master/src/java/net/percederberg/mibble/Mib.java#L184 old value can be overridden (multiple MibValueSymbol
instances can have the same value).
Is it expected behavior or it is a bug?
Thanks!
There is currently no easy way to store the state of a loaded Mib, so the same files have to be parsed every time which may be time consuming. By adding object serialization or similar this might be faster.
The SNMPv1 TRAP-TYPE values are normally not part of the OID tree. So they are not displayed in the MibbleBrowser, since it operates on the OID tree only.
This is a really nice library and I've been using it for a lot of years now.
Please please please get yourself set up to use Sonatype's OSS repository hosting so you can publish Mibble artifacts via Maven Central.
This will make it so much easier for open source libraries like Tnm4j to make use of Mibble without having to explain to developers how to manually install Mibble artifacts in their local repository.
First I would like to thank for this amazing API !!
I also had the following questions regarding the imports that are present in the beginning of the Mib file:
Going through the past issues I found that you have to copy all the related MIbs to the mib being pased into the directory that you specify in the loader.addDir() and that the location of the path mentioned in the addDir() should always be in the classpath. So I wand to make if that the case ?
A lot of the mib file that I try to load have missing imports so I keep on getting undefined symbol 'xxx' , however when I add the import to the import section of the mib file it seems to work, even though I tried loading all the standard mibs before loading the specific mib I still encounters a MibLoaderException. So I wanted to know if there is any way to make sure that any loaded mib will not encounter this MibLoaderException if the symbol is not mentioned in the imports?
Thanks in advance !!
One of the problems we are getting on an increasingly common basis is Mibble not being able to parse MIB files that all other MIB tools (e.g. iReasoning) can handle without issue.
It seems to boil down to the strictness of the parser adhering to the standard - other tools are a lot more accommodating.
Here is a typical example of loading a rack PDU MIB from Austin Hughes;
Warning: in InfraSolutionX-MIB.txt: line 6:
value identifier 'AustinHughes' doesn't start with a lowercase
character
AustinHughes OBJECT IDENTIFIER ::= { enterprises 34550 }
^
Warning: in InfraSolutionX-MIB.txt: line 7:
value identifier 'InfraSolutionX' doesn't start with a lowercase
character
InfraSolutionX OBJECT IDENTIFIER ::= { AustinHughes 10 }
^
Warning: in InfraSolutionX-MIB.txt: line 8:
value identifier 'InfraBox' doesn't start with a lowercase
character
InfraBox OBJECT IDENTIFIER ::= { InfraSolutionX 1 }
^
Warning: in InfraSolutionX-MIB.txt: line 12:
value identifier 'FrontHandleControl' doesn't start with a
lowercase character
FrontHandleControl OBJECT IDENTIFIER ::= { handleControl 1 }
^
Warning: in InfraSolutionX-MIB.txt: line 13:
value identifier 'RearHandleControl' doesn't start with a
lowercase character
RearHandleControl OBJECT IDENTIFIER ::= { handleControl 2 }
^
Warning: in InfraSolutionX-MIB.txt: line 124:
value identifier 'InfraBoxAdmin' doesn't start with a lowercase
character
InfraBoxAdmin OBJECT IDENTIFIER ::= { InfraBox 1 }
^
Warning: in InfraSolutionX-MIB.txt: line 125:
value identifier 'InfraBoxModel' doesn't start with a lowercase
character
[InfraSolutionX-MIB.txt](https://github.com/cederberg/mibble/files/801539/InfraSolutionX-MIB.txt)
etc etc
What are your thoughts?
Would it be possible to introduce a flag to indicate non-strict mode?
The following NPE stacktrace was reported by Mark Ponthier @firescope:
java.lang.NullPointerException
at net.percederberg.mibble.MibDirectoryCache.initNameCache(MibDirectoryCache.java:114)
at net.percederberg.mibble.MibDirectoryCache.findByName(MibDirectoryCache.java:100)
at net.percederberg.mibble.MibLoader.locate(MibLoader.java:785)
at net.percederberg.mibble.MibLoader.loadQueue(MibLoader.java:719)
at net.percederberg.mibble.MibLoader.load(MibLoader.java:550)
at net.percederberg.mibble.MibLoader.load(MibLoader.java:479)
at com.firescope.commonservice.mib.compiler.MIBCompiler.loadMib(MIBCompiler.java:176)
at com.firescope.commonservice.mib.compiler.MIBCompiler.compileAllMibs(MIBCompiler.java:126)
at com.firescope.commonservice.mib.compiler.MIBCompilerProcessor.compileAllMibs(MIBCompilerProcessor.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:301)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
at $Proxy135.compileAllMibs(Unknown Source)
at com.firescope.commonservice.mib.compiler.MIBCompilerMain.execute(MIBCompilerMain.java:41)
at com.firescope.commonservice.mib.compiler.MIBCompilerMain.main(MIBCompilerMain.java:99)
When trying to load SNMPv2-CONF, which is part of RFC 1904, the MIB loader reports an error.
I came across this problem when trying to load SNMPv2-MIB, which is part of RFC 3418, to have the definitions for the v2 notifications equivalent to the generic traps like "cold start", "warm start", "link down", "link up" etc.
Since the 'erroneous' line in SNMPv2-CONF is originally defined like this in RFC 1904, is assume there is a bug in mibble concerning this.
Find all MIBs needed in attached archive SNMPv2-MIB.zip
ERROR: unexpected token "SYNTAX", expected "END"
in file "C:\Users\stroeste\dev\CARTA-SnmpTrapSender\doc\mibs\rfc\SNMPv2-CONF.mib"
at line 157, column 33
"SYNTAX" type(SYNTAX)
^
WARNING: couldn't find referenced MIB 'SNMPv2-CONF', skipping import of 3 symbols
in file "C:\Users\stroeste\dev\CARTA-SnmpTrapSender\doc\mibs\rfc\SNMPv2-MIB.mib"
at line 17, column 17
FROM SNMPv2-CONF;
^
Clarifications needed in the API docs:
When loading a MIB file with multiple MIB definitions, the MibbleBrowser app only shows the first MIB in the file. All MIB:s in the file should be displayed. Optionally, all loaded MIB:s (dependencies) should also be shown.
When parsing SMIv1 files, any usage of symbols or constructs from SMIv2 should trigger a warning.
The opposite goes for SMIv2 files.
I am successfully launching MibbleBrowser from the command line with:
java -jar ~/github/mibble-2.10.1/MibbleBrowser.jar
It would be useful to pass along the IP address of a target as an argument in the command line. (I would like the MibbleBrowser window to display information about that device instead of the default 127.0.0.1) Is this possible? Thanks!
Download source code for testing, analysis of a mib file the following error:
net.percederberg.mibble.MibLoaderException: found 232 MIB loader errors
at net.percederberg.mibble.MibLoader.loadQueue(MibLoader.java:796)
at net.percederberg.mibble.MibLoader.load(MibLoader.java:602)
at net.percederberg.mibble.MibLoader.load(MibLoader.java:529)
at TestMain.test(TestMain.java:32)
at TestMain.main(TestMain.java:21)
Then I print a specific error similar to the following error
undefined symbol 'experimental'
referenced value is not an object identifier
undefined symbol 'DisplayString'
But these keywords, such as experimental, TimeTicks, DisplayString have been imported, why this error can not find it?
I downloaded the source code directly and executed MibbleBrowser.bat, but it gives an "Error: Could not find or load main class" error. I tried modifying the bat file and successfully executed the MibbleBrowser class, but it still throws an error. I'm not sure if I missed any steps or if it's a bug in the original code.
Mibble is not able to parse a comment like the following:
-- -- Module Name: HMS023R10.MIB SCTE-HMS-ALARMS-MIB
It complains about a syntax error. If you remove the forth "-" sign in that line, the MIB is parsed successfully. Seems it depends on whether the MIB contains an even (not working) or an uneven number (working) of "-" signs.
From my understanding everything preceeded by "--" is a comment as long as it's on the same line.
Via email from Matthew Walker:
From Current sorting (since OIDs are treated as Strings) results in inaccuracies like this:
1.3.6.1.2.1.33.1.9.1.0
1.3.6.1.2.1.33.1.9.10.0
1.3.6.1.2.1.33.1.9.2.0
It seems the ObjectIdentifierValue.compareTo()
method doesn't perform the proper numerical sorting, but only a simple `toString().compareTo()´.
Oddly enough, it seems that NumberValue.compareTo()
is properly implemented with numerical comparison. So it shouldn't be too hard to fix this.
The current API for OID searches -- Mib.getSymbolByOid(String)
-- does not allow for searches across all loaded MIB files or in the OID tree.
A number of new API methods should probably be added.
Please add support for AES Privacy mode. This is currently an option for the linux snmpcmd -x argument.
Following the docs/install.xml I have a Java 7+ and am clicking on the .bat and .sh files. They flicker for a second and don't do anything. Please advise.
In the instructions the following files are required in the lib directory:
mibble-parser-2.10.1.jar
The parser library and app code
mibble-mibs-2.10.1.jar
The bundled IANA and IETF MIBs
snmp6_1.jar
The Westhawk SNMP stack (only used by MibbleBrowser)
My local lib folder only contains:
grammatica-1.6.jar
snmp6_1.jar
If I run the .bat files from console I get:
Using environment variables:
MIBBLE_HOME = C:\Data\Projects\XPORT-~1\src\www\node-mib\mibble\src
JAVA_HOME = C:\Program Files\Java\jre1.8.0_131
CLASSPATH = lib@NAME@-parser-@[email protected]; lib@NAME@-mibs-@[email protected]; lib\snmp6_1.jar
Error: Could not find or load main class net.percederberg.mibble.MibbleBrowser
When I run java - version in console:
java version "1.8.0_131"
Java(TM) SE Runtime Enviroment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-BIt Server VM (build 25.131-b11, mixed mode)
Other specs:
Windows Server 2012 R2 Standard 64 bit
Mibble has been based on JDK 1.4 for very long. But it is now time to upgrade to Java 6:
I am using Mibble 2.9.3 to parse my MIB files (all files are in same folder) using mibble-parser-2.9.3.jar.
I have taken the MIBs from http://www.juniper.net/techpubs/software/junos/junos141/juniper-mibs-14.1R1.10.zip. I have downloaded ENTITY-MIB and added to this package.
The loading code is as follows:
MibLoader mibLdr = new MibLoader();
loadMandatoryMibs(mibLdr); // Here, the mandatory MIBs are loaded -- Successfully
Mib m = mibLdr.load(mibFile);
Out of my 229 MIB files, 22 files are failing to load with same exception:
mib-802.1ag.txt
mib-802.1ap.txt
mib-jnx-atm-cos-Orig.txt
mib-jnx-atm-cos.txt
mib-jnx-bl.txt
mib-jnx-chas-defines.txt
mib-jnx-if-accounting.txt
mib-jnx-ifotn.txt
mib-jnx-ipsec-monitor-asp.txt
mib-jnx-ldp.txt
mib-jnx-mobile-gateway-aaa.txt
mib-jnx-mobile-gateway-appfw.txt
mib-jnx-mobile-gateway-charging.txt
mib-jnx-mobile-gateway-gtp.txt
mib-jnx-mobile-gateway-rmps.txt
mib-jnx-mobile-gateway-sgw-charging.txt
mib-jnx-mobile-gateway-sgw-gtp.txt
mib-jnx-mobile-gateway-sgw-mfwd.txt
mib-jnx-mobile-gateway-sm-ip-pool.txt
mib-jnx-pwatm.txt
mib-jnx-pwtdm.txt
mib-jnx-vpls-bgp.txt
I am receiving below exception for all these files:
Unable to read: mib-jnx-mobile-gateway-sm-ip-pool.txt With exception.getMessage: found 1 MIB loader errors
net.percederberg.mibble.MibLoaderException: found 1 MIB loader errors
at net.percederberg.mibble.MibLoader.load(MibLoader.java:552)
at net.percederberg.mibble.MibLoader.load(MibLoader.java:479)
at com.juniper.mibble.mibTester.testMibs(mibTester.java:38)
at com.juniper.mibble.mibTester.main(mibTester.java:26)
However, if I load the above MIBs to Mibble UI, the loading is successful. I have tried to see if there is anything wrong with MIB files; but the exception message returned by JAR file is not clear. So, could you please let me know what am I missing that is causing these MIBs fail to load?
Thank you.
There seems to be an issue in parsing value-range constraints. Consider the following toy MIB:
MY-MIB DEFINITIONS ::= BEGIN
IMPORTS OBJECT-TYPE, Integer32 FROM SNMPv2-SMI;
my-parameter OBJECT-TYPE
SYNTAX Integer32 (100..200)
MAX-ACCESS read-only
STATUS current
DESCRIPTION "Simple parameter"
::= { iso 1 }
END
The exitValueConstraint method process the constraints and eventually creates an ValueRangeConstraint
instance with lowerbound of 200 and no upperbound. There is possibly an issue inside for
loop in determining the presence of low and upper bounds.
I am trying to use the MibbleBrowser from 2.10.1 to do SNMP GETs from a Net-SNMP agent. I know the SNMPv3 configuration, except "Context Name" and "Context Engine" are a mystery to me, so I'm leaving them blank. The first time I do a GET request from a particular IP, all is well and I get the answer I'm looking for. However, after that first GET, I get this error:
GET: Error: Engine ID discovery: Timed out
Is this a Mibble issue? Westhawk issue? User issue?
The MIB source text should be available, both for the full MIB and for each of the symbols within.
Hello
I got a issue while loading mib files.
MibLoaderException getLog show error: undefined symbol 'none'
The mib file can download from here
http://nickos.free.fr/MIB/Switch/ECS4610-24F/ECS4610-24F_V1.2.2.1.mib
Below is detail console error message
MibLoaderException occurred!!
Warning: in /home/ubuntu/mibs/ECS4610-24F_V1.2.2.1.mib: line 1267:
missing import for 'Counter64', using definition from SNMPv2-SMI
portInOctetRate Counter64,
^
Warning: in /home/ubuntu/mibs/ECS4610-24F_V1.2.2.1.mib: line 1268:
missing import for 'Counter64', using definition from SNMPv2-SMI
portInPacketRate Counter64,
^
Warning: in /home/ubuntu/mibs/ECS4610-24F_V1.2.2.1.mib: line 1270:
missing import for 'Counter64', using definition from SNMPv2-SMI
portOutOctetRate Counter64,
^
Warning: in /home/ubuntu/mibs/ECS4610-24F_V1.2.2.1.mib: line 1271:
missing import for 'Counter64', using definition from SNMPv2-SMI
portOutPacketRate Counter64,
^
Warning: in /home/ubuntu/mibs/ECS4610-24F_V1.2.2.1.mib: line 1286:
missing import for 'Counter64', using definition from SNMPv2-SMI
SYNTAX Counter64
^
Warning: in /home/ubuntu/mibs/ECS4610-24F_V1.2.2.1.mib: line 1293:
missing import for 'Counter64', using definition from SNMPv2-SMI
SYNTAX Counter64
^
Warning: in /home/ubuntu/mibs/ECS4610-24F_V1.2.2.1.mib: line 1308:
missing import for 'Counter64', using definition from SNMPv2-SMI
SYNTAX Counter64
^
Warning: in /home/ubuntu/mibs/ECS4610-24F_V1.2.2.1.mib: line 1315:
missing import for 'Counter64', using definition from SNMPv2-SMI
SYNTAX Counter64
^
Error: in /home/ubuntu/mibs/ECS4610-24F_V1.2.2.1.mib: line 13013:
undefined symbol 'none'
DEFVAL { none }
^
Error: in /home/ubuntu/mibs/ECS4610-24F_V1.2.2.1.mib: line 13648:
undefined symbol 'none'
DEFVAL { none }
^
Warning: in /home/ubuntu/mibs/ECS4610-24F_V1.2.2.1.mib: line 18541:
missing import for 'ifOperStatus', using definition from IF-MIB
ifOperStatus,
^
Is this mib file invalid or this is a loader bug?
Reading a long list of MibLoaderLog.LogEntry instances is hard, since the entries are sorted by detection order, not their importance or location in the file.
Preferably, MibLoaderLog.entries() should return a sorted list of log entries, with errors first and warnings second. Inside each group, the entries should be sorted by file and line number.
If a loaded MIB has TRAP-TYPE definitions, they act as a catch-all when using getSymbolByOid(String oid)
.
This prohibits loading several MIBs and looping over them in a getMibForOid(String oid)
routine without editing the MIB and removing the TRAP-TYPE definitions or without further inspecting and rejecting the candidate symbol.
Mibble fails to load MIB files referencing symbols from other MIBs not imported. Typical case is that the SMI or TC MIBs are not referenced, but some symbols from them are used anyway.
Mibble should provide a fallback for this, reporting a warning and silently loading the proper default symbol. SMIv1 or SMIv2 must be automatically detected.
Gradle build appears to be broken. The 'test' task in build.xml requires being renamed in order for build to succeed.
Using Java SE Runtime Environment 7u80
Installation instructions mention these files in the lib directory:
mibble-parser-2.10.1.jar
mibble-mibs-2.10.1.jar
snmp6_1.jar
My download only has:
grammatica-1.6.jar
snmp6_1.jar
Whenever i attempt to execute the .jar files, absolutely nothing happens and attempting to execute any of the batch files in the src/bin
directory results in the console opening, then immediately closing.
Am I doing something wrong?
The library currently does not provide any API for building an SNMP agent or client. With an API for using WestHawk SNMP and/or SNMP4J, a more integrated and easier solution could be provided.
While using mibble v2.10.1 on the mib file VMWARE-ESX-AGENTCAP-MIB.mib (included in linked file), mibble throws a NullPointerException.
The error printout as well as 3 sets of mibs for test cases is included in the attached file. Using MibbleValidator.sh in the directories "broken" and "broken2" causes the issue. The issue is not present when running MibbleValidator.sh in "works" directory.
Mib files and error printout:
https://drive.google.com/file/d/1LcSXrG320rlksOd3GLf1E82wZF6YybCu/view?usp=sharing
I am getting error while parsing one of the 'cisco' mib file. It is giving me 81 errors. Do I need to add any other files where I have copied my mib file?
Thanks
For a trap sender utilities UI, I try to determine the variables and their data types and description provided with the trap that should be sent.
From the SnmpTrapType Object I can get a List of MibValue Objects, representing the variables, but as I understood so far, I need the corresponding MibValueSymbol Objects to get access to the oids and data types of the variables. The getReferenceSymbol() Method of the MibValue Object should return this, but returns 'null' instead.
Is that a bug, or did I misunderstand the API in that point?
Example code:
MibValueSymbol v1Trap = ...
SnmpTrapType snmpTrapType = (SnmpTrapType)v1Trap.getType();
//get enterprise and according oid
MibValue enterprise = snmpTrapType.getEnterprise();
System.out.print("\tenterprise: ");
System.out.print(enterprise.getName());
System.out.print(" ");
System.out.print((enterprise.getReferenceSymbol() == null ? "'no reference symbol'" : enterprise.getReferenceSymbol().getOid().toString()));
System.out.println();
// get the variables and according oids
ArrayList<MibValue> variables = snmpTrapType.getVariables();
if (!variables.isEmpty()) {
System.out.println("\tvariables:");
for (MibValue variable : variables) {
System.out.print("\t\t");
System.out.print(variable.getName());
System.out.print(" ");
System.out.print((variable.getReferenceSymbol() == null ? "'no reference symbol'" : variable.getReferenceSymbol().getOid().toString()));
System.out.println();
}
}
symbolvaluemap in Mib.java has keys in the format like "referencetovalue.2" instead of full oid string like ".1.3.6.1.2.3.4"
Full oid string is universal accepted key which should be used to search for mibvaluesymbol from the map.
First of all, thank you for providing such great library.
There has been some attempts to port Mibble to other languages (e.g. MibbleSharp as a C# port). As they might have become outdated by now, I am considering to port Mibble again in C#.
I wanted to make sure I have got a good understanding of the Mibble code structure before starting such task.
Apparently the only part of codes that are auto-generated are located at src/java/net/percederberg/mibble/asn1
. Is that right?
Honestly, I didn't expected the scale of hand-written code for an SNMP MIB parser. I expected it to be mostly auto-generated code for the grammar plus a light wrapper that loads the MIB file and feeds the parser to build the AST tree and then a minimal API for querying that tree.
I've looked through code and understood some parts of it (e.g. mechanism for importing multiple MIBs) but I'm sure I am missing many other functionalities. For instance, why types such as MibValueSymbol.java needs to be implemented? Do they abstract away the underlying AST parser nodes? And MibAnalyzer.java is one of the main places where these abstraction is carried out?
asn1.grammar
file.Do you have any comments on these? The second approach could generate a more optimal and "native" code. However, I am not sure if the generated code is compatible with the rest of codes.
This was originally submitted by richb-hanover about our fork. It is a problem with the original repository.
The problem I saw was that, when MibbleBrowser starts up, it attempts to load a MIB that wasn't loaded the previous time. Here's how to make it happen:
Proposed fix:
The MibLoader.MibSource class uses a static reference to the ASN.1 parser:
private static class MibSource {
private static Asn1Parser parser = null;
This means that two threads using the MibLoader simultaneously will use the same stateful parser object with the result that both parsings fail with unpredictive results.
Some ways to fix the issue:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.