JASMINe header

Introducing MBeanCmd

MBeanCmd is a command-line tool written in Java for interacting with MBeans on any J2EE server. It can:

It does not depend on any J2EE package. The various outputs (for example, file, graph and JASMINe Event Switch) can be combined.

MBeans and your J2EE server

What is an MBean ?

MBeans are managed beans, i.e. Java objects that represent resources to be managed. An MBean has a management interface consisting of:

For example, an MBean representing an application's configuration could have attributes representing the different configuration parameters, such as a cache size.

MBeans in JOnAS

Getting to the list of available MBeans in JOnAS is pretty straightforward, thanks to the JOnAS Administration interface: simply click on MBeans on the menu on the left and the list of currently deployed MBeans will appear.

jonasadmin_mbeans.gif

Connecting to MBeans on a J2EE server

Note that not all those MBeans are available remotely: to connect to any MBean, one needs to use a connetor MBean. To get the list of the connector MBeans and their addresses in JOnAS, click on Other MBeans - Connectors. In the Attributes tab of a connector MBean, you can see its JMX Service URL:

jonasadmin_connector_mbean.gif

This is the URL MBeanCmd will connect to in order to manage any MBean.

Using MBeanCmd

Getting help

To launch MBeanCmd, just go to the folder where mbean.jar is present and launch:

java -jar mbean.jar

Since no option has been specified, this will simply display the help. To display the help for a command, say poll, type in:

java -jar mbean.jar help poll

Note that the help file for poll is quite large: it includes the usage options and the DTD to use to display a graph.

Defining targets

To use MBeanCmd for capturing statistics periodically (poll and stat commands), you first need to define which J2EE server(s) you're targeting. This can be done in two ways:

jasmine.jmx.url.j1 = service:jmx:rmi:///jndi/rmi://localhost:1099/jrmpconnector_jonas0
jasmine.jmx.url.j3 = service:jmx:rmi:///jndi/rmi://localhost:1099/jrmpconnector_jonas1
jasmine.jmx.url.j2 = service:jmx:rmi:///jndi/rmi://192.168.7.5:1099/jrmpconnector_jonas
jasmine.jmx.default.target = j1

Usage example: output the number of threads

If we browse the JOnAS Administration interface, we see that the JVM J2EE Bean (called in our case jonas:j2eeType=JVM,name=jonas,J2EEServer=jonas) has an attribute called allThreadsCount (The number of active threads in the JVM).

jonasadmin_j2eeType_JVM.gif

We'll now output this information on different mediums.

On the console

We know that:

Therefore, the command to launch is:

java -Djasmine.jmx.url=service:jmx:rmi:///jndi/rmi://129.183.101.109:1099/jrmpconnector_jonas -jar mbean.jar stat -p 1 
     -name "*:j2eeType=JVM,*" -a allThreadsCount

This displays the following output:

date;time;sname;server;domain;mbean;allThreadsCount
2007/12/21 11:03:22;1198231402118;jonas;jonas;jonas;jonas:j2eeType=JVM,name=jonas,J2EEServer=jonas;125
2007/12/21 11:03:23;1198231403194;jonas;jonas;jonas;jonas:j2eeType=JVM,name=jonas,J2EEServer=jonas;126
2007/12/21 11:03:24;1198231404254;jonas;jonas;jonas;jonas:j2eeType=JVM,name=jonas,J2EEServer=jonas;123
2007/12/21 11:03:25;1198231405313;jonas;jonas;jonas;jonas:j2eeType=JVM,name=jonas,J2EEServer=jonas;130
2007/12/21 11:03:26;1198231406373;jonas;jonas;jonas;jonas:j2eeType=JVM,name=jonas,J2EEServer=jonas;126
[etc]

On that output, you'll notice that:

On a spreadsheet

Since any spreadsheet software can read comma separated values, it is rather trivial to import data captured by MBeanCmd into a spreadsheet: just copy and paste the console output:

mbeancmd_excel.gif

In a graph

The -graph option can be used to display the sampled data in a graph. The XML DTD of a graph can be accessed by typing:

java -jar mbean.jar help stat
or
java -jar mbean.jar help poll

To display the number of threads in a simple graph, the following graph.xml file can be used:

<?xml version='1.0' encoding='UTF-8' ?>
<monitor separator=";" timeformat="long" >
	<serie-def id="s1">
		<name>Number of threads</name>
		<x col="time" type="time"/>
		<y col="allThreadsCount" type="long"/>
	</serie-def>
	<graph id="g1">
		<title>Number of threads</title>
		<serie ref="s1"/>
	</graph>
</monitor>

Launching it can be done as follows:

java -Djasmine.jmx.url=service:jmx:rmi:///jndi/rmi://129.183.101.109:1099/jrmpconnector_jonas -jar mbean.jar stat -p 1
     -graph graph.xml -name "*:j2eeType=JVM,*" -a allThreadsCount

Which will display the following graph:

mbeancmd_nthreads.gif

Note that you can also display multiple series on one graph.

Mgen: configuration generation tool

mgen tool aims at generating quickly a mbeancmd configuration for monitoring a whole JOnAS cluster platform in a few steps.

mgen relies on an uniq XML file (mgen-conf.xml) describing the comprehensive JOnAS platform: 1) the 'servers' element gathers the network parameters of the JOnAS instances 2) the 'components' element lists the module to supervise for each JOnAS instance, tx, sessions, http, axis, slsb, ds, … 3) the 'variables' element describes the application variables reused in the component command

mgen is delivered with the mbeancmd code source in the 'mgen' subdirectory.

Usage: After having filling the mgen-conf.xml with your platform parameters and your monitoring requirements, just run 'ant'

Note that if your JOnAS platform host several applications, you may have to define several mgen-conf.xml file (one per application), at least for supervizing the application components (servlet,session,...).

Log-in , Last update: 2008/04/10 12:55

Copyright © 2006-2010, JASMINe Logo

Java, and all Java-based trademarks, JMX and all JMX based trademarks, are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. Bull is independent of Sun Microsystems, Inc..