JVM monitoring tools

[2014-10-01]

A list of useful JVM monitoring tools

I’ve gathered a list of basic tools for troubleshooting Java applications. There are many other tools out there, but these are the ones I used and find useful.

JVM tools

jps - print java processes PID and parameters on a target JVM

➜ jps -lmv
29379 sample.App -testParam1

jinfo $PID - prints details about the java process (VM parameters and flags, java system properties)

jstack $PID - prints stacktrace of all threads in the process with PID

jstat - print various garbage collection statistics (or jstatd daemon for remote monitoring)

jmap - print heap statistics on a runnning process

➜ jmap -histo:all 29379
No dump file specified
WARNING: Ran out of C-heap; undercounted 368 total instances in data below
num     #instances         #bytes  class name (module)
-------------------------------------------------------
1:          1049        2739072  [I (java.base@14.0.1)
2:         12206         668472  [B (java.base@14.0.1)
3:         10700         256800  java.lang.String (java.base@14.0.1)
4:          1326         164112  java.lang.Class (java.base@14.0.1)
5:          1611         112296  [Ljava.lang.Object; (java.base@14.0.1)
6:          3147         100704  java.util.HashMap$Node (java.base@14.0.1)
7:            41          67888  [C (java.base@14.0.1)
8:           393          61648  [Ljava.util.HashMap$Node; (java.base@14.0.1)
9:          1098          35136  java.util.concurrent.ConcurrentHashMap$Node (java.base@14.0.1)
10:           608          24320  java.util.LinkedHashMap$Entry (java.base@14.0.1)
11:           416          21616  [Ljava.lang.String; (java.base@14.0.1)
12:            47          17968  [Ljava.util.concurrent.ConcurrentHashMap$Node; (java.base@14.0.1)
13:           354          16992  java.util.HashMap (java.base@14.0.1)
14:           361           8664  java.lang.module.ModuleDescriptor$Exports (java.base@14.0.1)
15:           347           8328  java.lang.StringBuilder (java.base@14.0.1)
.....................

jhat - tool for analyzing java heap files

Linux tools for troubleshooting

iostat - CPU and device I/O statistics (e.g. devices that are busy iostat -zh 2 4)

iotop - disk I/O utilization

sar - statistics on CPU, memory, swap, context switching, disk and network

vmstat- statistics on virtual memory