[SNMP4J] enable SNMP monitoring for Java app with existing MBeans

david pocivalnik dp.desoma at gmail.com
Tue Feb 19 11:10:36 CET 2013


Hi Frank,

thanks for your time and the helpful hints. I checked the classes out 
before, but didn't realize until checking more carefully how it was 
supposed to work.

I'll first try to manage a simple example w/o any tools, as I want to 
understand what's going on and how everything is working.

I managed to write a simple example where I have a MBean defined like 
this one:

public interface ExporterMBean {
	public static String BEANNAME = 
"test.mbeans.exporter:type=Exporter,name=Exporter";
	
	String getOutputDirectory();
	void setOutputDirectory(String outputDirectory);
	void startExport();
	int getNumberOfExporterThreadsWorking();
}

I defined OID's, added MOScalars to the MOFactory, registered them and 
added

private static final Object[][] SCALAR_MBEANS_EXPORTER = {
		{ TestManagementMib.oidExpDir, "OutputDirectory", String.class },
	    { TestManagementMib.oidExpThreads, 
"NumberOfExporterThreadsWorking", Integer.class } };

to scalarSupport. I'm able to get the status via nagios and my manager I 
wrote to test. Thanks for the hints!

but, I don't understand some details.
- why would I need, or, when would I need to pass on "MIB module name 
that defines the textual conventions", and "textualConvention the object 
name of the textual convention on which this scalar is based"; as done 
in the example implementation. e.g.
     jvmClassesVerboseLevel = 
moFactory.createScalar(oidJvmClassesVerboseLevel, 
       moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_WRITE),
new Integer32(),TC_MODULE_JVM_MANAGEMENT_MIB, TC_JVMVERBOSELEVELTC);

- when do I need a MOTable, or let's rephrase it, what would I need to 
have in the MBean to be needing a MOTable ?

- the OID's I'm using start with "1.3.6.1.4.", when adding a View (in 
the agent, vacm.addViewTreeFamily) I thought that when removing
vacm.addViewTreeFamily(new OctetString("fullReadView"), new OID("1.3"), 
new OctetString(), VacmMIB.vacmViewIncluded, StorageType.nonVolatile);
I would only get an error back, but I again received the value.

- I also couldn't figure out how notificationSupport is bound to a MBean

- with SNMP it is possible to set and get values, but just to be sure, i 
can't call a method from an SNMP manager that returns void, but executes 
the method called?

Thanks in advance for your time.

BR,
David

-- 

Hi David,

Please have a look at the JvmManagementMibInst.java example mapping
of the SNMP4J-AgentJMX library. There you can see how MBeans are mapped
to a MIB specification.

If do not already have a MIB specification, then creating that would be
the first
task. As creating the MIB spec. is most likely an interative task, I
would recommend
using MIB Designer to do it. Then you can fast and easily change the
structure
of the MIB to better fit your mapping needs.

You can then use AgenPro to generate the MIB stub-code (like it had been
done
for the JvmManagement.java class)

With SNMP4J-AgentJMX the mapping can be done descriptive an almost all
cases.
So coding is reduced to a minimum.

Best regards,
Frank

Am 17.02.2013 10:57, schrieb david pocivalnik:
> Hi,
>
> I'm new to snmp4j, snmp in general as well. I posted a question to
>
>
http://stackoverflow.com/questions/14896501/enable-snmp-monitoring-for-java-app-with-existing-mbeans
>
> and I thought you might be able to answer the question as well. If you
> need more information please just let me know.
>
> I have MBeans in my Java application that are registered to the MBean
> server, and I can monitor my application. I know want to also offer the
> possibility to have an SNMP manager monitor the application as well. I
> found tools and ways to generate the Java code from some files that
> define the interface, but I want to do it the other way around. I
> couldn't find any example that would guide me through this procedure,
> even in the JMX example no mbeans are used.
>
> Thanks in advance and BR
> david
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j



More information about the SNMP4J mailing list