惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
博客园_首页
H
Help Net Security
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
B
Blog
I
InfoQ
SecWiki News
SecWiki News
T
Tailwind CSS Blog
Spread Privacy
Spread Privacy
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
N
Netflix TechBlog - Medium
P
Palo Alto Networks Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
K
Kaspersky official blog
M
MIT News - Artificial intelligence
S
Schneier on Security
T
Threat Research - Cisco Blogs
F
Fortinet All Blogs
Cyberwarzone
Cyberwarzone
Scott Helme
Scott Helme
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
The Cloudflare Blog
Recent Announcements
Recent Announcements
Security Latest
Security Latest
G
GRAHAM CLULEY
IT之家
IT之家
Y
Y Combinator Blog
The Last Watchdog
The Last Watchdog
腾讯CDC
Google DeepMind News
Google DeepMind News
V
V2EX
S
Securelist
TaoSecurity Blog
TaoSecurity Blog
B
Blog RSS Feed
S
SegmentFault 最新的问题
博客园 - 叶小钗
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Project Zero
Project Zero
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
F
Full Disclosure

博客园 - kylindai

Spark installation for windows remove all .git files and directories use one command - kylindai Android adb not responsing putty ssh login linux nodejs 实现 http proxy 透明转发 mybatis 处理数组类型及使用Json格式保存数据 JsonTypeHandler and ArrayTypeHandler 一次PostgreSql数据迁移,使用nodejs来完成 nodejs 安装 postgresql module mongodb 安装为windows服务 memcached linux / win32 1.4.13 learning nodejs 2 - connect middleware learning nodejs 1 - stream.pipe javascript的变量、作用域和内存问题 javascript编程的最佳实践推荐 android download host jetty-distribution-7.6.x 部署 Quartz Cron 表达式 ImageMagick 批量处理图片脚本 常用 LINUX 命令
java cpu load - kylindai
kylindai · 2016-09-30 · via 博客园 - kylindai

$ps -Lp 179093 cu | more

USER        PID    LWP %CPU NLWP %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
admin    179093 179093  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05   0:00 java
admin    179093 179097  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05   0:01 java
admin    179093 179100  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05   8:43 java
admin    179093 179101  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05   8:43 java
admin    179093 179102  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05   8:44 java
admin    179093 179103  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05   8:45 java
admin    179093 179104  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05   2:21 java
admin    179093 179105  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05  55:50 java
admin    179093 179106  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05   0:03 java
admin    179093 179107  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05   0:15 java
admin    179093 179108  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05   0:00 java
admin    179093 179109  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05   0:00 java
admin    179093 179110  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05   1:02 java
admin    179093 179111  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05   0:58 java
admin    179093 179112  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05   0:00 java
admin    179093 179113  0.0  383 54.5 5803448 4572012 ?     Sl   Aug05  29:21 java

......

$printf "%x\n" 179105
2bba1


$jstack -l 179093 > jstack.log
$vi jstack.log

search 2bba1

"Reference Handler" daemon prio=10 tid=0x00002aaaab073800 nid=0x2bba2 in Object.wait() [0x00000000405cd000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        at java.lang.Object.wait(Object.java:503)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:133)
        - locked <0x0000000772d40fd8> (a java.lang.ref.Reference$Lock)

   Locked ownable synchronizers:
        - None

"main" prio=10 tid=0x00002aaaab072000 nid=0x2bb99 runnable [0x0000000041e45000]
   java.lang.Thread.State: RUNNABLE
        at java.net.PlainSocketImpl.socketAccept(Native Method)
        at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:398)
        at java.net.ServerSocket.implAccept(ServerSocket.java:530)
        at java.net.ServerSocket.accept(ServerSocket.java:498)
        at org.apache.catalina.core.StandardServer.await(StandardServer.java:466)
        at org.apache.catalina.startup.Catalina.await(Catalina.java:787)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:733)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:320)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:454)

   Locked ownable synchronizers:
        - None

"VM Thread" prio=10 tid=0x00002aaaab10d000 nid=0x2bba1 runnable

"Gang worker#0 (Parallel GC Threads)" prio=10 tid=0x00002aaaab108800 nid=0x2bb9c runnable

"Gang worker#1 (Parallel GC Threads)" prio=10 tid=0x00002aaaab109800 nid=0x2bb9d runnable

"Gang worker#2 (Parallel GC Threads)" prio=10 tid=0x00002aaaab10a000 nid=0x2bb9e runnable

"Gang worker#3 (Parallel GC Threads)" prio=10 tid=0x00002aaaab10a800 nid=0x2bb9f runnable

"Concurrent Mark-Sweep GC Thread" prio=10 tid=0x00002aaaab10c000 nid=0x2bba0 runnable
"VM Periodic Task Thread" prio=10 tid=0x00002aaaab10d800 nid=0x2bba9 waiting on condition

JNI global references: 343

......

here is a script:

#!/bin/sh 
# write by    : oldmanpushcart@gmail.com 
# date        : 2014-01-16 
# version     : 0.07 
typeset top=${1:-10} 
typeset pid=${2:-$(pgrep -u $USER java)} 
typeset tmp_file=/tmp/java_${pid}_$$.trace 

/opt/taobao/java/bin/jstack $pid > $tmp_file 
ps H -eo user,pid,ppid,tid,time,%cpu --sort=%cpu --no-headers\ 
        | tail -$top\ 
        | awk -v "pid=$pid" '$2==pid{print $4"\t"$6}'\ 
        | while read line; 
do 
        typeset nid=$(echo "$line"|awk '{printf("0x%x",$1)}') 
        typeset cpu=$(echo "$line"|awk '{print $2}') 
        awk -v "cpu=$cpu" '/nid='"$nid"'/,/^$/{print $0"\t"(isF++?"":"cpu="cpu"%");}' $tmp_file 
done 

rm -f $tmp_file