22
Scott Leberknight jps & jvmtop

jps & jvmtop

Embed Size (px)

DESCRIPTION

Slides accompanying a lightning talk I gave at the Altamira Fall 2013 conference.

Citation preview

Page 1: jps & jvmtop

Scott Leberknight

jps & jvmtop

Page 2: jps & jvmtop

"How you monitor your software is as important as its functionality"

- Nathan Marz, "Your Code is Wrong"

Page 3: jps & jvmtop

jps

Like ps, but lists Java processes

Page 4: jps & jvmtop

jps

Page 5: jps & jvmtop

jps -l(that's a lowercase L)

Page 6: jps & jvmtop

jps -m

Page 7: jps & jvmtop

jps -v

Page 8: jps & jvmtop

jps -lmv(of course you can combine arguments...)

Page 9: jps & jvmtop

monitor remote host

jps foo.bar.com:6666

(a jstatd process must be running on remote host)

Page 10: jps & jvmtop

beware tmpwatch!jps gets info from /tmp/hsperfdata_<username>/<pid>

Page 11: jps & jvmtop

beware tmpwatch! (2)

Page 12: jps & jvmtop

beware tmpwatch! (3)

jps won't see JVMs if process file deleted!

tmpwatch could delete hsperfdata files for long running VMs, e.g. Hadoop NameNode

oops!

Page 13: jps & jvmtop

jps summary

-l: fully-qualified class name

-m: arguments to main()

list process id and class name

options:

-v: VM arguments

-q: suppress class name

-V: VM arguments via flag file

Page 14: jps & jvmtop

jvmtop

Like top, but for Java processes

Page 15: jps & jvmtop

./jvmtop.sh

Page 16: jps & jvmtop

jvmtop columnsPID: process id

MAIN-CLASS: "jvm name"; class with main() method

HPCUR: currently used heap memory

HPMAX: maximum heap memory used

NHCUR: current non-heap memory used (e.g. PermGen)

NHMAX: maximum non-heap memory JVM can allocate

Page 17: jps & jvmtop

jvmtop columns (2)

USERNAME: process owner

#T: number of JVM threads

DL: deadlock indicator (shows !D if deadlock detected)

CPU: the CPU utilization

GC: % of time spent in garbage collection

VM: information about the JVM (S6U31 = Sun 6, update 31)

Page 18: jps & jvmtop

./jvmtop.sh <pid>

Page 19: jps & jvmtop

jvmtop detail columnsTID: thread id

NAME: thread name

STATE: thread state

CPU: the CPU utilization (relative to all processors)

TOTALCPU: CPU utilization since thread started

BLOCKEDBY: thread that is blocking a thread

Page 20: jps & jvmtop

jvmtop profiler

./jvmtop.sh --profile <PID>

Page 21: jps & jvmtop

References

jps:docs.oracle.com/javase/7/docs/technotes/tools/share/jps.html

jvmtop project:code.google.com/p/jvmtop/

Nathan Marz, "Your Code is Wrong":www.slideshare.net/nathanmarz/your-code-is-wronghttp://www.youtube.com/watch?v=QOu4e5y6sg4

jstack:docs.oracle.com/javase/7/docs/technotes/tools/share/jstack.html

jstatd:docs.oracle.com/javase/7/docs/technotes/tools/share/jstatd.html

Page 22: jps & jvmtop

My Info

twitter: sleberknight

www.sleberknight.com/blog

[email protected] @gmail.com

www.altamiracorp.com/blog