官網地址:https://gitee.com/arthas/arthas
命令 | 介紹 |
---|---|
dashboard | 當前系統的實時數據面板 |
thread | 查看當前 JVM 的線程堆棧信息 |
watch | 方法執行數據觀測 |
trace | 方法內部調用路徑,並輸出方法路徑上的每個節點上耗時 |
stack | 輸出當前方法被調用的調用路徑 |
tt | 方法執行數據的時空隧道,記錄下指定方法每次調用的入參和返回信息,並能對這些不同的時間下調用進行觀測 |
monitor | 方法執行監控 |
jvm | 查看當前 JVM 信息 |
vmoption | 查看,更新 JVM 診斷相關的參數 |
sc | 查看 JVM 已加載的類信息 |
sm | 查看已加載類的方法信息 |
jad | 反編譯指定已加載類的源碼 |
classloader | 查看 classloader 的繼承樹,urls,類加載信息 |
heapdump | 類似 jmap 命令的 heap dump 功能 |
wget https://alibaba.github.io/arthas/arthas-boot.jar
java -jar arthas-boot.jar [pid]
利用watch命令,監聽指定的方法,-x 參數可以指定打印入參和返回值的深度,第四個參數是條件表達式,過濾數據
watch com.baidu.xxxclass xxxMethod {params,returnObj} params[1]==77777 -x 3
通過jad來反編譯Main Class
jad demo.MathGame
sc查找類
sc *Math*
sm查找方法
sm demo.MathGame*
使用 trace 命令可以跟蹤統計方法耗時
trace com.UserController getUser
使用 ognl 命令,ognl 表達式可以輕鬆操作想要的信息:例如查看累的static屬性,還可以操作
ognl '@com.Arthas@hashSet'
ognl '@[email protected]()'
ognl '@[email protected]("test")'
ognl '@com.Arthas@hashSet' | grep test
使用 thread查看所有線程信息,同時會列出每個線程的 CPU
使用率,可以看到圖裏 ID 爲12 的線程 CPU 使用100%。
thread
thread [id]
#尋找 CPU 使用較高的線程
thread -n [顯示的線程個數]
#查看線程池裏線程信息
thread | grep pool
#查看直接定位到死鎖信息
thread -b