Use jmxsh – JMX CLI tool – to troubleshoot remote JMX RMI connection

Overview

Occasionally when creating SiteScope JMX monitors  you might want to verify connectivity or to troubleshoot remote JMX RMi connection. You might also want to be able to provide a tool to the (monitored target) Java application team to try the connectivity locally on the target  server.

jmxsh is a command line utility that allows you to connect to (local or remote) JMX and browse the counters.

Basic Tool Usage – troubleshoot remote JMX RMI connection

  • You must have a java installed on the server that will be intiating the tool – the source server
  • Download the jar from here http://code.google.com/p/jmxsh/downloads/detail?name=jmxsh-R5.jar&can=2&q=
  • Copy the jar to the source server to a temporary folder (for ex: to E:\Temp\Ilya\JMX)
  • Start the tool with ‘-l’ option which enables logging and provide a log file name
E:\Temp\Ilya\JMX>java -jar jmxsh-R5.jar -l s02345678901
History file null/.jmxsh_history not writable, command-line history disabled.
jmxsh v1.0, Wed Jan 23 03:23:12 EST 2008
Type 'help' for help. Give the option '-?' to any command for usage help.
Starting up in shell mode.
  • Connect to the JMX server. Must provide host (-h) and port (-p) and optionally user (-U) and password (-P).parameters
% jmx_connect -h s02345678901 -p 29602Connected to service:jmx:rmi:///jndi/rmi://s02345678901:29602/jmxrmi.%
  • If you can see the “Connected to service…….” then the connectivity test is complete. If not then look into the logfile that was created to get some insights.

Extra

If you wish to explore the JMX a bit more proceed to the next step. For example following the next step will provide you the same information as that SiteScope monitor:

SiteScope JMX Monitor
SiteScope JMX Monitor
  • Hit Enter and you will see the list of all the available domains
Entering browse mode.
==================================================== Available Domains: 
1. JMImplementation 
2. com.sun.management 
3. Loader 
4. Foundations 
5. Topaz 
6. java.nio 
7. java.lang 
8. Domain1.s02345678901 
9. java.util.logging 
SERVER: service:jmx:rmi:///jndi/rmi://s02345678901:29602/jmxrmi
====================================================
Select a domain: 7
==================================================== Available MBeans: 
1. java.lang:type=Memory 
2. java.lang:type=MemoryPool,name=PS Eden Space 
3. java.lang:type=MemoryPool,name=PS Survivor Space 
4. java.lang:type=MemoryPool,name=Code Cache 
5. java.lang:type=GarbageCollector,name=PS MarkSweep 
6. java.lang:type=Runtime 
7. java.lang:type=ClassLoading 
8. java.lang:type=Threading 
9. java.lang:type=Compilation 
10. java.lang:type=MemoryPool,name=PS Perm Gen 
11. java.lang:type=GarbageCollector,name=PS Scavenge 
12. java.lang:type=OperatingSystem 
13. java.lang:type=MemoryPool,name=PS Old Gen 
14. java.lang:type=MemoryManager,name=CodeCacheManager SERVER: service:jmx:rmi:///jndi/rmi://s02345678901:29602/jmxrmi
DOMAIN: java.lang
====================================================
Select an mbean: 1
==================================================== Attribute List: 
1. irw boolean Verbose 
2. -r- javax.management.openmbean.CompositeData HeapMemoryUsage 
3. -r- javax.management.openmbean.CompositeData NonHeapMemoryUsage 
4. -r- int ObjectPendingFinalizationCount 
5. -r- javax.management.ObjectName ObjectName 
Operation List: 
6. void gc() 
SERVER: service:jmx:rmi:///jndi/rmi://s02345678901:29602/jmxrmi DOMAIN: java.lang 
MBEAN: java.lang:type=Memory
====================================================
Select an attribute or operation: 2
===================================================== Accessing Attribute HeapMemoryUsage
HeapMemoryUsage = javax.management.openmbean.CompositeDataSupport(compositeType=javax.management.openmbean.CompositeType(name=java.lang.management.MoryUsage,items=((itemName=committed,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=init,itemType=javax.management.opmbean.SimpleType(name=java.lang.Long)),(itemName=max,itemType=javax.management.openmbean.SimpleType(name=java.lang.Long)),(itemName=used,itemType=jax.management.openmbean.SimpleType(name=java.lang.Long)))),contents={committed=268173312, init=268435456, max=268173312, used=94103128})

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.