日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

arthas使用

發布時間:2023/12/4 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 arthas使用 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

arthas使用

安裝下載

基礎命令
  • 啟動:安裝文件夾下執行
wget https://alibaba.github.io/arthas/arthas-demo.jar java -jar arthas-demo.jar

  • 查看dashboard:輸入dashboard,會展示當前進程信息,按ctrl+c可中斷執行
ID NAME GROUP PRIORITY STATE %CPU TIME INTERRUPTED DAEMON 552 Timer-for-arthas-dashboard-8cbf395a-b670-4c system 10 RUNNABLE 65 0:0 false true 176 sentinel-time-tick-thread main 5 TIMED_WAITING 29 52:56 false true 186 DubboResponseTimeoutScanTimer main 5 TIMED_WAITING 2 3:10 false true 124 New I/O server boss #1 ([id: 0x1be37c6d, /0 main 5 RUNNABLE 1 0:15 false true 33 Abandoned connection cleanup thread main 5 TIMED_WAITING 0 0:6 false true 509 AsyncAppender-Worker-arthas-cache.result.As system 9 WAITING 0 0:0 false true 120 AsyncResolver-bootstrap-0 main 5 TIMED_WAITING 0 0:0 false true 237 AsyncResolver-bootstrap-executor-0 main 5 WAITING 0 0:0 false true 507 Attach Listener system 9 RUNNABLE 0 0:0 false true 107 ClientHouseKeepingService main 5 TIMED_WAITING 0 0:9 false true 435 ClientHouseKeepingService main 5 TIMED_WAITING 0 0:7 false true 29 Curator-ConnectionStateManager-0 main 5 WAITING 0 0:0 false true 84 Curator-ConnectionStateManager-0 main 5 WAITING 0 0:0 false true 32 Curator-Framework-0 main 5 WAITING 0 0:0 false true 87 Curator-Framework-0 main 5 WAITING 0 0:0 false true 67 Curator-TreeCache-0 main 5 WAITING 0 0:0 false true Memory used total max usage GC heap 242M 583M 583M 41.52% gc.parnew.count 563 par_eden_space 161M 245M 245M 65.61% gc.parnew.time(ms) 3692 par_survivor_space 1M 30M 30M 5.06% gc.concurrentmarksweep.count 3 cms_old_gen 79M 307M 307M 25.89% gc.concurrentmarksweep.time(ms) 299 nonheap 179M 183M 744M 24.18% code_cache 60M 61M 240M 25.14% metaspace 107M 109M 256M 41.92% Runtime os.name Linux os.version 3.10.0-862.9.1.el7.x86_64 java.version 1.8.0_191 java.home /usr/java/jdk1.8.0_191/jre systemload.average 1.18 processors 2 uptime 430681s
  • 通過jad反編譯class:
jad com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl
進階命令
class/classloader相關
  • sc-查看jvm已經加載的類信息:Search-Class簡寫,這個能搜索出所有已經加載到jvm的class,支持參數[d],[E],[f],[x:]
    • -d: 輸出當前類的詳細信息
    • -e: 開啟正則表達式匹配,默認為通配符匹配
    • -f: 輸 出當前類的成員變量信息,需要配合-d 一起使用
    • -x : 指定輸出靜態變量時屬性的遍歷深度,默認0
//模糊搜索 $ sc com.zhenai.profile.provider.modules.member.service.impl.* //輸出類詳細信息 $ sc -d com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl //輸出詳細信息基礎上加上fields信息 sc -d -f com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl
  • sm-Search-Method簡寫,這個命令能搜索出已經加載的class信息的方法信息。參數如下
    • -d : 展示每個方法詳細信息
    • -e : 開啟正則默認通配符匹配
//列出所有方法 sm com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl //方法詳細信息 sm -d com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl
  • jad- 將jvm中實際運行的class的byte code反編譯成java代碼。
//反編譯類 jad com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl //反編譯指定函數 jad com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl getAddress
  • mc-Memory Compiler內存編譯器,編譯.java文件生成class文件
mc /temp/test.java
  • monitor-方法執行監控,非實時返回命令,監控緯度如下:
    • timeStamp-時間戳
    • class-java類
    • method-方法
    • total-調用次數
    • success-成功次數
    • fail-失敗次數
    • rt-評價rt
    • fail-tate - 失敗率
//監控getAddress方法,參數-c 統計周期,默認120秒,此處設置5秒 monitor -c 5 com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl getAddress
  • watch- 方法執行數據觀測,參數如下
    • -b: 方法調用之前觀察
    • -e: 方法異常后觀察
    • -s : 方法返回后觀察
    • -f : 方法結束后(正常,異常返回)觀察
    • -E: 開啟正則
    • x: 指定輸出結果的屬性遍歷深度
    • 這里重點要說明的是觀察表達式,觀察表達式的構成主要由 ognl 表達式組成,所以你可以這樣寫"{params,returnObj}",只要是一個合法的 ognl 表達式,都能被正常支持。
//基礎用法 watch com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl getAddress "{params, returnObj}" -x 2 //觀察入參,會發現對比上一個返回值是null watch com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl getAddress "{params, returnObj}" -x 2 -b //同時觀察方法調用前后, 參數里-n 2,表示只執行兩次, 此處第一次輸出是方法調用前的觀察表達式的結果,第二次輸出的是方法返回后的表達式的結果 watch com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl getAddress "{params, returnObj}" -x 2 -b -s -n 2 //跳轉-x值觀察具體方法參數, -x表遍歷深度,可以調整來打印具體的參數和結果內容 watch com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl getAddress "{params, target}" -x 2 //篩選條件對參數篩選 watch com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl getAddress "{params[0],target}" "params[0]>0" //異常情況拋出 watch com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl getAddress "{params[0],thromExp}" -e -x 2//耗時過濾watch com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl getAddress '{params, target}' '#cost>10' -x 2
  • trace- 方法內部調用路徑,并輸出方法路徑上的每一個節點耗時,參數:
    • [E] : 正則匹配
    • [n:] : 命令執行次數
    • ”#cost“ : 方法執行耗時
//同時監控多個方法, -j 表示過濾JDK函數trace -E com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl getAddress|getExpect//耗時篩選,此處1 指方法中某個步驟超過1毫秒,并非總執行時間trace -E -j com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl getAddress|getExpect '#cost>1'
  • stack- 輸出當前方法被調用的調用路徑
//參數 -n表示執行次數,表示下兩個請求將被監控, params[0]>0 參數過濾 stack com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl getAddress 'params[0]>0' -n 2 //耗時篩選 stack com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl getAddress '#cost>5'
  • tt -方法執行的時空隧道,記錄指定方法每次調用入參以及返回值,
//基本使用 -n參數指定監控次數,不指定無限制,會將jvm內存耗盡 tt -t com.zhenai.profile.provider.modules.member.service.impl.AppointmentServiceImpl getAddress -n 3

返回如下:

//篩選指定方法名字調用 tt -s 'method.name=="getAddress"' //查看指定編號對應詳細信息 tt -i 1001 //重做指定編號請求 tt -i 1004 -p

參考文獻

總結

以上是生活随笔為你收集整理的arthas使用的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。