jstat - monitor JVM statistics
jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]
Options you will use
-gcutil- Percent used of S0 S1 Eden Old Metaspace CCS, plus GC counts and times.
-gc- Capacities and usage in KB.
-gccause- Like -gcutil plus the last and current GC cause.
-t- Timestamp column (seconds since JVM start).
-gcnew- Young generation statistics.
-gcold- Old generation and Metaspace statistics.
-class- Class loader statistics.
-h N- Repeat the column header every N samples.
Examples
$ sudo -u appuser jstat -gcutil 1210 1000 10Ten samples one second apart.
$ jstat -gccause 1210 1sUntil Ctrl+C.
Gotchas
- Columns: YGC/YGCT young collections and total seconds, FGC/FGCT full, CGC/CGCT concurrent (G1), GCT all. If FGC climbs every sample and O stays near 100, the JVM is thrashing: that is your "high CPU".
- jstat reads /tmp/hsperfdata_<user>/<pid>; for another user it just says "<pid> not found".
Taught in
Try jstat in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.