通過java命令查看線程信息

內(nèi)容源于工作中的總結(jié)和網(wǎng)絡(luò)搜索飘痛。

  1. 命令找到j(luò)ava線程pid:jps勃教,下面pid是6
root@5pcng:/# jps
6 jar
889 Jps
  1. 命令查看pid進(jìn)程下的線程:ps -T -p pid
root@5pcng:/# ps -T -p 6
  PID  SPID TTY          TIME CMD
    6     6 ?        00:00:00 java
    6    37 ?        00:00:00 Service Thread
    6    38 ?        00:00:26 VM Periodic Tas
    6    40 ?        00:00:00 logback-1
    6    42 ?        00:00:01 mysql-cj-abando
    6    47 ?        00:00:01 redisson-netty-
    6    80 ?        00:00:03 quartzScheduler
    6   112 ?        00:00:00 MyHikariCP hous
    6   254 ?        00:00:02 pool-3-thread-1
    6   292 ?        00:00:02 pool-3-thread-2
    6   299 ?        00:00:01 pool-3-thread-3
    6   316 ?        00:00:01 pool-3-thread-4
    6   323 ?        00:00:01 pool-3-thread-5
    6   330 ?        00:00:01 pool-3-thread-6
    6   347 ?        00:00:01 pool-3-thread-7
    6   354 ?        00:00:00 pool-3-thread-8
    6   361 ?        00:00:01 pool-3-thread-9

只查看線程數(shù)可用:ps -T -p ${pid}| wc -l

root@5pcng:/# ps -T -p 6| wc -l
124

3.查看線程詳細(xì)信息:jstack -l pid

root@5pcng:/# jstack -l 6
"C1 CompilerThread8" #13 daemon prio=9 os_prio=0 tid=0x00007fd90c2d0000 nid=0x21 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread7" #12 daemon prio=9 os_prio=0 tid=0x00007fd90c2ce000 nid=0x20 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread6" #11 daemon prio=9 os_prio=0 tid=0x00007fd90c2cc000 nid=0x1f waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread5" #10 daemon prio=9 os_prio=0 tid=0x00007fd90c2c9800 nid=0x1e waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread4" #9 daemon prio=9 os_prio=0 tid=0x00007fd90c2c7800 nid=0x1d waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread3" #8 daemon prio=9 os_prio=0 tid=0x00007fd90c2bd800 nid=0x1c waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE
"VM Periodic Task Thread" os_prio=0 tid=0x00007fd90c2ee800 nid=0x26 waiting on condition 

JNI global references: 1955

4.查看jvm內(nèi)存占用及垃圾回收情況:jstat -gcutil pid intervalTime(ms)

root@5pcng:/# jstat -gcutil 6 3000
  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT   
  0.00  99.01  16.04   8.97  94.88      -     15    0.334     3    0.279    0.613
  0.00  99.01  16.04   8.97  94.88      -     15    0.334     3    0.279    0.613
  0.00  99.01  16.04   8.97  94.88      -     15    0.334     3    0.279    0.613
  0.00  99.01  16.04   8.97  94.88      -     15    0.334     3    0.279    0.613

指標(biāo)說明

S0 : 新生代中Survivor space 0區(qū)已使用空間的百分比
S1: 新生代中Survivor space 1區(qū)已使用空間的百分比
E: 新生代已使用空間的百分比
O: 老年代已使用空間的百分比
M: 元數(shù)據(jù)區(qū)使用比例

CCS:壓縮使用比例
YGC: 從應(yīng)用程序啟動(dòng)到當(dāng)前佛南,發(fā)生Yang GC 的次數(shù)
YGCT: 從應(yīng)用程序啟動(dòng)到當(dāng)前武鲁,Yang GC所用的時(shí)間【單位秒】
FGC: 從應(yīng)用程序啟動(dòng)到當(dāng)前,發(fā)生Full GC的次數(shù)
FGCT: 從應(yīng)用程序啟動(dòng)到當(dāng)前头滔,F(xiàn)ull GC所用的時(shí)間
GCT: 從應(yīng)用程序啟動(dòng)到當(dāng)前怖亭,用于垃圾回收的總時(shí)間【單位秒】

jstat 選項(xiàng)

class:類加載統(tǒng)計(jì)(Displays statistics about the behavior of the class loader.)
compiler:編譯統(tǒng)計(jì)(Displays statistics about the behavior of the Java HotSpot VM Just-in-Time compiler.)
gc:垃圾回收統(tǒng)計(jì)(Displays statistics about the behavior of the garbage collected heap.)
gccapacity:堆內(nèi)存統(tǒng)計(jì)(Displays statistics about the capacities of the generations and their corresponding spaces.
gccause:垃圾回收原因(Displays a summary about garbage collection statistics (same as -gcutil), with the cause of the last and current (when applicable) garbage collection events.)
gcnew:新生代垃圾回收統(tǒng)計(jì)(Displays statistics of the behavior of the new generation.)
gcnewcapacity:新生代內(nèi)存統(tǒng)計(jì)(Displays statistics about the sizes of the new generations and its corresponding spaces.)
gcold:老年代垃圾回收統(tǒng)計(jì)(Displays statistics about the behavior of the old generation and metaspace statistics.)
gcoldcapacity:老年代內(nèi)存統(tǒng)計(jì)(Displays statistics about the sizes of the old generation.)
gcmetacapacity:元數(shù)據(jù)空間統(tǒng)計(jì)(Displays statistics about the sizes of the metaspace.)
gcutil:總結(jié)垃圾回收統(tǒng)計(jì)(Displays a summary about garbage collection statistics.)
printcompilation:JVM編譯方法統(tǒng)計(jì)(Displays Java HotSpot VM compilation method statistics.)

gccause (推薦使用)
gcutil擁有的輸出列g(shù)ccause也都擁有,還額外多了最后一次GC原因和當(dāng)前GC原因拙毫。

指標(biāo)說明:
LGCC:最后一次GC原因(Cause of last garbage collection)
GCC:當(dāng)前GC原因(Cause of current garbage collection)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末依许,一起剝皮案震驚了整個(gè)濱河市棺禾,隨后出現(xiàn)的幾起案子缀蹄,更是在濱河造成了極大的恐慌,老刑警劉巖膘婶,帶你破解...
    沈念sama閱讀 221,198評(píng)論 6 514
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件缺前,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡悬襟,警方通過查閱死者的電腦和手機(jī)衅码,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,334評(píng)論 3 398
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來脊岳,“玉大人逝段,你說我怎么就攤上這事「钔保” “怎么了奶躯?”我有些...
    開封第一講書人閱讀 167,643評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長亿驾。 經(jīng)常有香客問我嘹黔,道長,這世上最難降的妖魔是什么莫瞬? 我笑而不...
    開封第一講書人閱讀 59,495評(píng)論 1 296
  • 正文 為了忘掉前任儡蔓,我火速辦了婚禮郭蕉,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘喂江。我一直安慰自己召锈,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,502評(píng)論 6 397
  • 文/花漫 我一把揭開白布开呐。 她就那樣靜靜地躺著烟勋,像睡著了一般。 火紅的嫁衣襯著肌膚如雪筐付。 梳的紋絲不亂的頭發(fā)上卵惦,一...
    開封第一講書人閱讀 52,156評(píng)論 1 308
  • 那天,我揣著相機(jī)與錄音瓦戚,去河邊找鬼沮尿。 笑死,一個(gè)胖子當(dāng)著我的面吹牛较解,可吹牛的內(nèi)容都是我干的畜疾。 我是一名探鬼主播,決...
    沈念sama閱讀 40,743評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼印衔,長吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼啡捶!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起奸焙,我...
    開封第一講書人閱讀 39,659評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤瞎暑,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后与帆,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體了赌,經(jīng)...
    沈念sama閱讀 46,200評(píng)論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,282評(píng)論 3 340
  • 正文 我和宋清朗相戀三年玄糟,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了勿她。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,424評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡阵翎,死狀恐怖逢并,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情郭卫,我是刑警寧澤砍聊,帶...
    沈念sama閱讀 36,107評(píng)論 5 349
  • 正文 年R本政府宣布,位于F島的核電站箱沦,受9級(jí)特大地震影響辩恼,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,789評(píng)論 3 333
  • 文/蒙蒙 一灶伊、第九天 我趴在偏房一處隱蔽的房頂上張望疆前。 院中可真熱鬧,春花似錦聘萨、人聲如沸竹椒。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,264評(píng)論 0 23
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽胸完。三九已至,卻和暖如春翘贮,著一層夾襖步出監(jiān)牢的瞬間赊窥,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 33,390評(píng)論 1 271
  • 我被黑心中介騙來泰國打工狸页, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留锨能,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,798評(píng)論 3 376
  • 正文 我出身青樓芍耘,卻偏偏與公主長得像址遇,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子斋竞,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,435評(píng)論 2 359

推薦閱讀更多精彩內(nèi)容