Performance monitoring of the basic fault processing tools

  In the JDK bin directory, there are a variety of small tools to support debugging, monitoring, compile and run other functions.

root@root:/usr/lib/jvm/java-8-openjdk-amd64/bin# ls
appletviewer  hsdb  jarsigner  javadoc  java-rmi.cgi  jdb    jinfo  jps         jstack  keytool       pack200     rmid         serialver   unpack200  xjc
clhsdb        idlj  java       javah    jcmd          jdeps  jjs    jrunscript  jstat   native2ascii  policytool  rmiregistry  servertool  wsgen
extcheck      jar   javac      javap    jconsole      jhat   jmap   jsadebugd   jstatd  orbd          rmic        schemagen    tnameserv   wsimport

1.jps: VM process status tool

  You can list the virtual machines running processes and displays the virtual machine executes the main class (Main Class, main () function where the class) as well as the name of a local virtual machine these processes unique ID (LVMID.Local Virtual Machine Identifier)

root@root:~$ jps -help
usage: jps [-help]
       jps [-q] [-mlvV] [<hostid>]

Definitions:
    <hostid>:      <hostname>[:<port>]

  root@root:/home/dev# jps -l
  1505 *.jar
  1507 *.jar

jps option parameters: 
-q: output only LVMID, omitted the name of the main class of
-m: passed to the main class main output virtual machine process starts () function parameters
-l: full name of the output of the master class, if the process is executed Jar package, JAR path output
JVM parameters output virtual machine process starts: -v

2.jmap: Java memory imaging tools

   For raw heap dump snapshot.

The Usage: 
    the jmap [Option] <PID> 

Option:
  -dump: green heap dump snapshot -dump: [Live,] = the format B, File = <filename> <PID>
-heap: java heap show details

  root@dev03:/home/dev# jmap -dump:format=b,file=heapDump 30138
  Dumping heap to /home/wuh151/heapDump ...
   Heap dump file created

  root@root:/home/dev# jmap -heap 30138
  Attaching to process ID 30138, please wait...
  Debugger attached successfully.
  Server compiler detected.
  JVM version is 25.242-b08

  using thread-local object allocation.
  Parallel GC with 8 thread(s)

  Heap Configuration:  

  MinHeapFreeRatio = 0 ## corresponds jvm startup parameters -XX: MinHeapFreeRatio minimum idle setting JVM stack ratio (default 40)
  MaxHeapFreeRatio ## = 100 corresponding to the start jvm parameters -XX: MaxHeapFreeRatio JVM stack disposed maximum idle ratio (default 70)
  maxHeapSize = 1073741824 ( 1024.0MB) ## corresponding to the start jvm parameters -XX: maxHeapSize = set the maximum size of the JVM heap
  NewSize = 178782208 (170.5MB) ## corresponding to the start jvm parameters -XX: NewSize = disposed JVM stack 'new generation' default size
  MaxNewSize = 357564416 (341.0MB) ## corresponding to the start jvm parameters -XX: MaxNewSize = disposed JVM stack 'new generation' maximum size
  OldSize = 358088704 (341.5MB) ## corresponding to the start jvm parameters -XX: OldSize = <value>: set JVM heap 'Older Generation' size
  NewRatio = 2 ## corresponding to the start jvm parameters -XX: NewRatio =: 'new generation' and 'Older Generation' size ratio
  SurvivorRatio = 8 ## corresponding to the start jvm parameters -XX: SurvivorRatio = Eden disposed in the young generation area size area ratio Survivor
  MetaspaceSize = 1073741824 (1024.0MB)
  CompressedClassSpaceSize = 268435456 (256.0MB)
  MaxMetaspaceSize = 2147483648 (2048.0MB)
  G1HeapRegionSize = 0 (0.0MB)

 

 

3.jstack: Java stack trace tool

       Time for the current thread to generate a snapshot of the virtual machine. Thread is a snapshot of the current method of virtual machines each executing thread stack collection, generation thread snapshot aim is usually to locate the thread appears long pause.

  

Count the number of threads to use: 
root @ dev03: / Home / dev # 2791 jstack the -l | grep 'java.lang.Thread.State' | WC the -l 48

Deadlock Detection:

  Step one: View occupy high cpu process
  top
  Step two: Check occupy high cpu threading
  top -H -p 17850
  Step Three: Convert the thread ID
  printf "the X-% \ the n-" 17880
  45d8
  Step Four: Locate the cpu usage thread
  jstack 17850 | grep 45d8 -A 30

 

4.jstat: Virtual Machine Statistics Monitoring Tool

  Various operating status monitor virtual machines.

Usage: jstat -help | -options 
       jstat - <the Option> [-t] [-h <Lines>] <vmid> [<interval The> [<COUNT>]] 

Parameters interval count represents the number of times the query interval and, if the argument is omitted, Description only check once
the Option:
  the -class monitor class loading, unloading quantity, total class load space and the time spent
-gc monitoring java heap status
-gcutil -gc with basically the same, the output of the main concerns has been used and what percentage of the total space
. ..

  root@root:/home/dev# jstat -gcutil 25791
  S0    S1   E     O     M     CCS   YGC YGCT   FGC FGCT  GCT
  97.84 0.00 61.84 77.63 97.22 95.68 338 58.808 2   1.787 60.595

  S0: 0 surviving area currently used ratio

  S1: area currently used in a proportion surviving 1

  E: Eden area using a proportional

  O: the proportion of older years

  M: using metadata area ratio

  CCS: Use compression ratio

  YGC: the number of the young generation garbage recycling

  YGCT: the young generation garbage collection time

  FGC: the number of years the old garbage collection

  FGCT: old time's garbage collection

  GCT: Total garbage collection time

 

       

Guess you like

Origin www.cnblogs.com/ryjJava/p/12618566.html