Skip to content

Instantly share code, notes, and snippets.

@dcapwell
Last active June 22, 2020 23:47
Show Gist options
  • Save dcapwell/3b2d3edb68514b828f94 to your computer and use it in GitHub Desktop.
Save dcapwell/3b2d3edb68514b828f94 to your computer and use it in GitHub Desktop.
Java JVM monitor
# https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jstat.html
# eden (free), old (free), young GC time, # full GC, full GC time, total GC time
jstat -gc -h10 $(jps -m | grep <process name here> | awk '{print $1}') 1000 0 | awk '/^[0-9]/ {printf "%-10s %-10s %-10s %-10s %-10s %-10s\n", int((100*$6)/$5), int((100*$8)/$7), $(NF-3), $(NF-2), $(NF-1), $NF}'
# OR
pid=42
jstat -gc -h10 $pid 1000 0 | awk '/^ [0-9]/ {printf "%-10s %-10s %-10s %-10s %-10s %-10s\n", int((100*$6)/$5), int((100*$8)/$7), $(NF-3), $(NF-2), $(NF-1), $NF}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment