快速分析线上java应用消耗资源

2016-01-07

最近发现一个很好的useful-shell,用于快速打印线程消耗cpu的top 5;闲话不多说,看看怎么用吧!

$ wget https://raw.githubusercontent.com/iqiancheng/useful-scripts/master/show-busy-java-threads.sh
$ chmod u+x show-busy-java-threads.sh
$ ./show-busy-java-threads.sh
[useful-scripts-root]# ./show-busy-java-threads.sh
[1] Busy(64.7%) thread(30475/0x770b) stack of java process(30469) under user(root):
"GC task thread#3 (ParallelGC)" prio=10 tid=0x00007f5290026800 nid=0x770b runnable

[2] Busy(64.7%) thread(30474/0x770a) stack of java process(30469) under user(root):
"GC task thread#2 (ParallelGC)" prio=10 tid=0x00007f5290024800 nid=0x770a runnable

[3] Busy(64.7%) thread(30473/0x7709) stack of java process(30469) under user(root):
"GC task thread#1 (ParallelGC)" prio=10 tid=0x00007f5290022800 nid=0x7709 runnable

[4] Busy(64.7%) thread(30472/0x7708) stack of java process(30469) under user(root):
"GC task thread#0 (ParallelGC)" prio=10 tid=0x00007f5290020800 nid=0x7708 runnable

[5] Busy(9.7%) thread(30476/0x770c) stack of java process(30469) under user(root):
"VM Thread" prio=10 tid=0x00007f529006a800 nid=0x770c runnable
# ./show-busy-java-threads.sh -p 11060
[1] Busy(0.0%) thread(31686/0x7bc6) stack of java process(11060) under user(root):
"DubboServerHandler-192.168.1.110:10595-thread-200" daemon prio=10 tid=0x00007ff62c143800 nid=0x7bc6 waiting on condition [0x00007ff615fde000]
   java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000000f1c279a8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
        at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
        at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

[2] Busy(0.0%) thread(31679/0x7bbf) stack of java process(11060) under user(root):
"DubboServerHandler-192.168.1.110:10595-thread-199" daemon prio=10 tid=0x00007ff62c141000 nid=0x7bbf waiting on condition [0x00007ff6160df000]
   java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000000f1c279a8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
        at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
        at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

[3] Busy(0.0%) thread(31672/0x7bb8) stack of java process(11060) under user(root):
"DubboServerHandler-192.168.1.110:10595-thread-198" daemon prio=10 tid=0x00007ff62c13f000 nid=0x7bb8 waiting on condition [0x00007ff6161e0000]
   java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000000f1c279a8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
        at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
        at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

[4] Busy(0.0%) thread(31440/0x7ad0) stack of java process(11060) under user(root):
"DubboServerHandler-192.168.1.110:10595-thread-197" daemon prio=10 tid=0x00007ff62c13d000 nid=0x7ad0 waiting on condition [0x00007ff6162e1000]
   java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000000f1c279a8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
        at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
        at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)

[5] Busy(0.0%) thread(31433/0x7ac9) stack of java process(11060) under user(root):
"DubboServerHandler-192.168.1.110:10595-thread-196" daemon prio=10 tid=0x00007ff62c13a800 nid=0x7ac9 waiting on condition [0x00007ff6163e2000]
   java.lang.Thread.State: WAITING (parking)
        at sun.misc.Unsafe.park(Native Method)
        - parking to wait for  <0x00000000f1c279a8> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2043)
        at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442)
        at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1068)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
Comments
Write a Comment