jmxdump is a tool that scans the exposed Mbeans on a local JVM using the Attach API. Only tested in a Linux OS, but the script can be adpated for Windows, OSX and other *nix.
The attach API is contained in the jar tools.jar, so a JDK is mandatory on the server.
jmxdump doesn't run with a JRE.
The file jmxdump.sh must be excutable and must be launched with the same unix user of the JVM, or with root user ( a « su » command is done in the script).
The covered JDKs are JDK 1.6 « HotSpot » ( Oracle / Open JDK) and IBM JDK J9 1.6 .
The usage of this script is described below :
echo "Usage (if it is possible execute with root user, at least with the same user of the JVM you want to scan) :"
echo "./jmxdump.sh -h|-help\nto obtain this help\n\n"
echo " ./jmxdump.sh -pid=<PID first argument JVM mandatory> -attr|-obj(opt) -model=<model(opt,default *:*)> -excl=<excl(opt)> "
echo "-attr is the default => gives the values of attributes,"
echo "-obj => gives the types of attributes,"
echo "-model must be an ObjectName regex , excl => for excluding Mbean is a normal regex see java.util.Pattern"
echo " when adding -freq=<timeInSecond> and -boucles=<number> :"
echo "The script is excecuted <boucles> times spaced by <freq> seconds."
The output is the stdout, it can be redirected to a file.
Simple output with 2 boucles is given below :
./jmxdump.sh -pid=19632 -model="jboss.as:deployment=jdbc_pool_basic.war,subsystem=web,servlet=PutData" -boucles=2 -frequency=2
and the output :
Date = 2013/11/20:18:23:00.140
########################################################
PID JVM =19632
########################################################
-----------------------------------------------------------
objectName=jboss.as:deployment=jdbc_pool_basic.war,subsystem=web,servlet=PutData
-----------------------------------------------------------
minTime = 1
loadTime = 1
processingTime = 505
maxTime = 202
requestCount = 2
-----------------------------------------------------------
########################################################
End JMXDump = 2013/11/20:18:23:00.181
Date = 2013/11/20:18:23:02.187
########################################################
PID JVM =19632
########################################################
-----------------------------------------------------------
objectName=jboss.as:deployment=jdbc_pool_basic.war,subsystem=web,servlet=PutData
-----------------------------------------------------------
minTime = 1
loadTime = 1
processingTime = 505
maxTime = 202
requestCount = 2
-----------------------------------------------------------
########################################################
End JMXDump = 2013/11/20:18:23:02.209
The build is realized with Maven plugin to Eclipse (m2m) downloaded from this update site.
The license is jmxdump is Apache 2.0 => http://www.apache.org/licenses/LICENSE-2.0