JVM相关信息查看

1. jps,查看jvm实例

[root@test_back-1~]# jps -help
usage: jps [-help]
       jps [-q] [-mlvV] []

Definitions:
    :      [:]
[root@test_back-1~]# jps -q
30262
28666
20794
30109
[root@test_back-1~]# jps -m
20806 Jps -m
30262 Bootstrap start
28666 jar
30109 Bootstrap start

2. jstat,jvm统计信息,包含内存信息及GC信息

[root@test_back-1~]# jstat -help
Usage: jstat -help|-options
       jstat -

3. jmap,查看JVM内存相关信息

[root@test_back-1~]# jmap -help
Usage:
    jmap [option] 
        (to connect to running process)
    jmap [option] 
        (to connect to a core file)
    jmap [option] [server_id@]
        (to connect to remote debug server)

where 

4. jstack,查看java栈及本地方法栈信息

[root@test_back-1~]# jstack -help
Usage:
    jstack [-l] 
        (to connect to running process)
    jstack -F [-m] [-l] 
        (to connect to a hung process)
    jstack [-m] [-l]  
        (to connect to a core file)
    jstack [-m] [-l] [server_id@]
        (to connect to a remote debug server)

Options:
    -F  to force a thread dump. Use when jstack  does not respond (process is hung)
    -m  to print both java and native frames (mixed mode)
    -l  long listing. Prints additional information about locks
    -h or -help to print this help message
[root@test_back-1~]# jstack -l 30109
"Reference Handler" #2 daemon prio=10 os_prio=0 tid=0x00007f1e80120000 nid=0x75a5 in Object.wait() [0x00007f1e84a61000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at java.lang.Object.wait(Object.java:502)
    at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
    - locked <0x00000000ca967f48> (a java.lang.ref.Reference$Lock)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)

   Locked ownable synchronizers:
    - None

"main" #1 prio=5 os_prio=0 tid=0x00007f1e8000a000 nid=0x759f runnable [0x00007f1e87d70000]
   java.lang.Thread.State: RUNNABLE
    at java.net.PlainSocketImpl.socketAccept(Native Method)
    at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409)
    at java.net.ServerSocket.implAccept(ServerSocket.java:545)
    at java.net.ServerSocket.accept(ServerSocket.java:513)
    at org.apache.catalina.core.StandardServer.await(StandardServer.java:466)
    at org.apache.catalina.startup.Catalina.await(Catalina.java:743)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:689)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495)

   Locked ownable synchronizers:
    - None

"VM Thread" os_prio=0 tid=0x00007f1e80118800 nid=0x75a4 runnable 

"Gang worker#0 (Parallel GC Threads)" os_prio=0 tid=0x00007f1e8001b000 nid=0x75a0 runnable 

"Gang worker#1 (Parallel GC Threads)" os_prio=0 tid=0x00007f1e8001c800 nid=0x75a1 runnable 

"Concurrent Mark-Sweep GC Thread" os_prio=0 tid=0x00007f1e8004a000 nid=0x75a2 runnable 

"VM Periodic Task Thread" os_prio=0 tid=0x00007f1e80756000 nid=0x75b6 waiting on condition 

JNI global references: 689

5. jinfo,查看jvm配置信息

[root@test_back-1~]# jinfo -help
Usage:
    jinfo [option] 
        (to connect to running process)
    jinfo [option] 
        (to connect to a core file)
    jinfo [option] [server_id@]
        (to connect to remote debug server)

where 

示例:查看指定进程栈信息

[root@test_back-1 ~]# top -Hp 30109   #查看这个JVM进程里面的进程运行情况
top - 15:01:01 up 123 days,  8:43,  3 users,  load average: 0.20, 0.13, 0.05
Tasks: 246 total,   0 running, 246 sleeping,   0 stopped,   0 zombie
Cpu(s):  1.5%us,  0.7%sy,  0.0%ni, 97.0%id,  0.8%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   3924700k total,  3654884k used,   269816k free,   160024k buffers
Swap:  3989496k total,   120700k used,  3868796k free,  1181444k cached
 Unknown command - try 'h' for help 
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                                                  
30126 root      20   0 3980m 762m  15m S  0.7 19.9   0:59.70 java                                                                                                                                                      
...                                                                                                                                                  
[root@test_back-1 ~]# printf "%x \n" 30126   #转换进程id为16进制
75ae 
[root@test_back-1 ~]# jstack 30109|grep 75ae --color -C 5  #查看进程里面的栈信息
    at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

"DataCarrier.DEFAULT.Consumser.0.Thread" #10 daemon prio=5 os_prio=0 tid=0x00007f1e8070f000 nid=0x75ae sleeping[0x00007f1e84295000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
    at java.lang.Thread.sleep(Native Method)
    at org.apache.skywalking.apm.commons.datacarrier.consumer.ConsumerThread.run(ConsumerThread.java:72)

"Thread-3" #9 daemon prio=5 os_prio=0 tid=0x00007f1e8026e000 nid=0x75aa waiting on condition [0x00007f1e84413000]

每一个使用之前都下查看帮助信息(-help)

你可能感兴趣的:(JVM相关信息查看)