Using jcmd - A powerful tool for listing your Java processes

I have come across a tool called jcmd which is shipped with Java itself. Here is how I use it in my every day life.

1. Find which Java processes are running

Just jcmd
It produces the following output (list all the Java processes)
3533 org.apache.catalina.startup.Bootstrap start
28814 org.apache.zookeeper.server.quorum.QuorumPeerMain /opt/kafka/confluent-5.3.1/etc/kafka/zookeeper.properties
4216 sun.tools.jcmd.JCmd
Filter them with grep jcmd | grep Kafka

2. View system properties of a Java process

jcmd 3497 VM.system_properties (where 3497 is the process id)

3. View the command line

jcmd 3497 VM.command_line

4. Know the up time

Know since how long a Java process is running.
jcmd 3497 VM.uptime
There are many other options which you can see by invoking help jcmd 3497 help. The list is as follows
The following commands are available:
VM.native_memory
ManagementAgent.stop
ManagementAgent.start_local
ManagementAgent.start
VM.classloader_stats
GC.rotate_log
Thread.print
GC.class_stats
GC.class_histogram
GC.heap_dump
GC.finalizer_info
GC.heap_info
GC.run_finalization
GC.run
VM.uptime
VM.dynlibs
VM.flags
VM.system_properties
VM.command_line
VM.version
help
ధన్యవాదాలు (Thank you)

No comments: