Hi Maurice,

You simply need to load the MIB module(s). SmiManager.listModules() list the modules that are available in the repository. SmiManager.getLoadedModuleNames() returns
the module names that are loaded and thus available for parsing.

Calling smiManager.loadModule("SNMPv2-MIB"); once before the first "parse" will do
the trick.

Best regards,
Frank


Am 18.12.2013 06:00, schrieb Garcia, Maurice:
I hope this is a trivial fix, I am really new to SNMP4J.

I simply want to simply translate an OID name to a OID dot notation.  I can 
find any clear documentation on how to do this.

Also do I need to compile new MIBS or simple provide the text files?

Below is just a test file to get me started

Any help Please!!!!

Thanks,

Maurice

public class SmiManagerTest {

        public static void main(String[] args) {

               SmiManager smiManager = null;

               String sLicense = "";

               try {

                   smiManager = new SmiManager(sLicense, new 
File("C:\\mibrepository"));
                   SNMP4JSettings.setOIDTextFormat(smiManager);
                   SNMP4JSettings.setVariableTextFormat(smiManager);

               } catch (IOException e) {
                      e.printStackTrace();
               }

               try {

                      for (String sModule : smiManager.listModules()) {
                            System.out.println("Module: " + sModule);
                      }

               } catch (IOException e) {
                      e.printStackTrace();
               }

               try {
                      smiManager.parse("sysContact.0");
               } catch (ParseException e) {
                      e.printStackTrace();
               }

               OID oOID = null;

               try {
                      oOID = new OID(smiManager.parse("sysContact.0"));
               } catch (ParseException e) {
                      e.printStackTrace();
               }

               System.out.println("OID: "  + oOID.format());

        }

}


OUTPUT:

Module: ACCOUNTING-CONTROL-MIB
Module: ADSL-LINE-EXT-MIB
Module: ADSL-LINE-MIB
Module: ADSL-TC-MIB
Module: ADSL2-LINE-MIB
Module: ADSL2-LINE-TC-MIB
Module: AGENTPP-AGENTX-MIB
Module: AGENTPP-BUILTIN-CAP
.
.
.
Module: VDSL-LINE-MIB
Module: VRRP-MIB
Module: WWW-MIB
java.text.ParseException: Could not resolve OID 'sysContact'
        at com.snmp4j.smi.SmiManager.parse(SmiManager.java:784)
        at SmiManagerTest.main(SmiManagerTest.java:42)
java.text.ParseException: Could not resolve OID 'sysContact.0'
        at com.snmp4j.smi.SmiManager.parse(SmiManager.java:784)
        at SmiManagerTest.main(SmiManagerTest.java:50)
Exception in thread "main" java.lang.NullPointerException
        at SmiManagerTest.main(SmiManagerTest.java:55)
_______________________________________________
SNMP4J mailing list
[email protected]
http://lists.agentpp.org/mailman/listinfo/snmp4j

--
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231

_______________________________________________
SNMP4J mailing list
[email protected]
http://lists.agentpp.org/mailman/listinfo/snmp4j

Reply via email to