arthas(阿爾薩斯)使用實踐----查看慢方法 /方法耗時等


初次使用時的一些問題

[ERROR] Target process 116477 is not the process using port 3658, you will connect to an unexpected process.

[ERROR] 1. Try to restart arthas-boot, select process 90686, shutdown it first with running the 'stop' command.

[ERROR] 2. Or try to use different telnet port, for example: java -jar arthas-boot.jar --telnet-port 9998 --http-port -1

這個問題初用者必出,原因為 arthas 選擇一個應用進行診斷時弄了一個 session,可以使用 arthas-client web arthas client 進行登錄,這個提示告訴你要先關閉以前的 arthas-boot ,或者重新選擇一個端口

你可以這么做,在 ~/.arthas/lib/3.1.7/arthas 下有一個 arthas-client.jar 使用 java -jararthas-client.jar 可以進入上次的 session shutdown 后就可以選擇其它的進程進行診斷了,或者你可以繼續診斷當前應用

 

退出art has:shutdown

 

 

github項目地址:https://github.com/alibaba/arthas

 進入要監控的那個服務所在的機器上,切換到deploy 用戶

 

下載並運行:

wget https://alibaba.github.io/arthas/arthas-boot.jar

java -jar arthas-boot.jar

 

 

查看慢方法 

命令:trace 類路徑 類方法名

示例: trace  com.xxx.helper.impl.xxxxImpl useExchangeVoucher

                        

查看方法耗時

命令 :tt -t 類路徑 類方法名

示例:tt -t com.xxxx.helper.impl.xxxxImpl useExchangeVoucher

 

 

查看線程狀態

命令: thread 

查看所有線程狀態

 

 

 

命名: thread [threadId]

 

 

thread -b 查看阻塞的線程

thread -n [number]查看占用cpu最高的前number個線程

 

 

arthas常見的操作實例

1.替代dev環境下用LogUtils.COMMON.debug進行調試。

查看接口入參和返回值

命令:watch com.xxxiface.xxxIface couponList "{params,returnObj}" -x 2 

 

 

2.Exception 異常排查。

tt -t {interface} {method} 

tt -i {id} -w 'throwExp'

 

 

【此圖來源於網絡】

也可以通過 watch {interface} {method} "throwExp" -x 2    查看異常

 

 

更多【https://github.com/alibaba/arthas/issues?utf8=%E2%9C%93&q=label%3Auser-case+

 

https://juejin.im/post/5b6b986c6fb9a04fd1603f4a#heading-30 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM