I am currently using jconsole
to monitor performance metrics of my Java application and would like to script this data acquisition.
Is there a way to retrieve these VM metrics (heap memory usage, thread count, CPU usage etc.) to STDOUT
?
The data in top -p PID -b -n 1
doesn't quite cut it.
Thanks
jstack offers a number of useful bits of information in its normal output. Heap memory usage is directly available, broken down by GC region; thread count could be determined with a little bit of perl / grep / etc.
Maybe jvmtop is worth a look.
It's a command-line tool which provides a live-view for several metrics.
Example output of the VM overview mode:
You might find jvm-mon useful for this. It is a JVM monitoring tool for the command line that disaplys:
The metrics and charts update while the tool is open.
Sample: