This is a simple utility to work with JMX from command line interface.
Requirements:
- jshell from jdk is required.
- management agent have to be started. Can be started on running JVM with
jcmd PID ManagementAgent.start_local
Usage:
jshell -R-Dpid=PID -R-Dcommand=getBeans jmxclient.jshjshell -R-Dpid=PID -R-Dcommand=getBeanInfo -R-Dbean=java.lang:type=Memory jmxclient.jshjshell -R-Dpid=PID -R-Dcommand=getAttribute -R-Dbean=java.lang:type=Memory -R-Dmethod=HeapMemoryUsage jmxclient.jshjshell -R-Dpid=PID -R-Dcommand=invoke -R-Dbean=java.lang:type=Memory -R-Dmethod=gc jmxclient.jshjshell -R-Dpid=PID -R-Dcommand=dumpBeans jmxclient.jshjshell -R-Dpid=PID -R-Dcommand=dumpBeans -R-Dbean=java.lang:* jmxclient.jshjshell -R-Dpid=PID -R-Dcommand=dumpBeansAsJson jmxclient.jshjshell -R-Dpid=PID -R-Dcommand=dumpBeansAsJson -R-Dbean=java.lang:* jmxclient.jsh
Available options:
-R-Dpid=PID- java process id you want attach to-R-Dcommand=help|getBeans|getBeanInfo|getAttribute|invoke|dumpBeans|dumpBeansAsJson- specify what to do-R-Dbean=BEAN_PATH- full path to mbean object like: java.lang:type=Memory, supports wildcards for dumpBeans and dumpBeansAsJson-R-Dmethod=METHOD_NAME- attribute or operation name-R-Dargs=ARGUMENTS- additional method arguments separated by space
Commands:
- help - show help
- getBeans - output a list of all available MBeans
- getBeanInfo - output all available attributes and operations for MBean
- getAttribute - output MBean attribute value
- invoke - run MBean operation
- dumpBeans - dump all MBean attribute values as a flat list in beanName.attribute = value format; optionally scoped to a wildcard bean pattern
- dumpBeansAsJson - dump all MBean attribute values as JSON; optionally scoped to a wildcard bean pattern