How to compile .mib file into .java fore for use in Agent

So I have been playing around with the snmp4j API and have been trying to get my own simulated agent set up. So far I’ve pretty much been working with the TestAgent.java example found in the snmp4j-agent library (using snmp-agent2.3.0) I’ve been able to trim down to the code to only include what I am needing.

Currently, I am to the point to where I am wanting to play with registering an entire .mib file rather than a single OID.I’ve been doing some reading and supposedly there’s a utility that allows you to generate a .java file from a .mib file. Once generated all you need to do is call the .registerMO() function.

However, most of the documentation I found refers me to SNMP4j Agent Pro. Unfortunately I do not believe I will have access to this tool as I only have access to the snmp4j.jar file and the snmp4j-agent.jar file. Upon further research I stumbled upon this article on the SNMP4j website, (https://doc.snmp.app/pages/viewpage.action?pageId=5799973). Here it appears that this is what I am wanting because it states, “Sample code to compile textual MIB specifications into the SNMP4J-SMI repository directory:” However, I still am not sure, mainly due to the top part of the article where it has a code snipped detailing a LicenseKey. I do not beleive I have a License Key.

I am just wondering if there is any existing api support to convert a .mib file into a .java file outside the AgentPro tool?

The MIB compiler in AgenPro and SNMP4J-SMI-PRO is not open-source and not available for free. That will not change in the future - at least for the next 15 years - hopefully :wink:, because that is one of the source of funding SNMP4J development.

Hope this answer helps anyway.

1 Like