Java 诊断工具Arthas初识、安装及试用

功能

  • 监控jvm运行状态
  • 定位应用热点,生成火焰图
  • 具体jar包来源等

使用方式

  • win10本地方式
  • linux本地方式
  • docker镜像方式
  • idea插件方式

使用实例

  • windows10本地环境测试运行效果
    • 下载 — Arthas 3.5.1 文档
    • 下载解压
    • 打开cmd命令行
    • 进入解压目录
    • 运行jps查看端口
    • 运行java -jar arthas-boot.jar 端口
      命令
    • 命令行查看效果: [arthas@28628]$ dashboard
    • 浏览器查看效果:打开 http://localhost:3658/ 输入dashboard回车查看效果
    • 测试如下:
Microsoft Windows [版本 10.0.19042.985]
(c) Microsoft Corporation。保留所有权利。

D:\>jps
31008 Application
28628 math-game.jar
5668
3624
16108
30268 Jps
7724 RemoteMavenServer36

D:\>java -jar arthas-boot.jar 28628
[INFO] arthas-boot version: 3.5.1
[INFO] Process 28628 already using port 3658
[INFO] Process 28628 already using port 8563
[INFO] arthas home: C:\Users\hanxs\.arthas\lib\3.5.1\arthas
[INFO] The target process already listen port 3658, skip attach.
[INFO] arthas-client connect 127.0.0.1 3658
  ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.  
 /  O  \ |  .--. ''--.  .--'|  '--'  | /  O  \ '   .-' 
|  .-.  ||  '--'.'   |  |   |  .--.  ||  .-.  |`.  `-. 
|  | |  ||  |\  \    |  |   |  |  |  ||  | |  |.-'    |
`--' `--'`--' '--'   `--'   `--'  `--'`--' `--'`-----' 
                                                       

wiki       https://arthas.aliyun.com/doc
tutorials  https://arthas.aliyun.com/doc/arthas-tutorials.html
version    3.5.1
main_class
pid        28628
time       2021-05-27 16:33:26

[arthas@28628]$ watch
The argument 'class-pattern' is required, description: The full qualified class name you want to watch
[arthas@28628]$ dashboard
ID       NAME                                               GROUP                     PRIORITY         STATE            %CPU             DELTA_TIME        TIME             INTERRUPTED      DAEMON           
1        main                                               main                      5                TIMED_WAITING    0.0              0.000             0:2.484          false            false           
-1       C2 CompilerThread0                                 -                         -1               -                0.0              0.000             0:1.390          false            true
-1       C2 CompilerThread2                                 -                         -1               -                0.0              0.000             0:0.875          false            true
-1       C2 CompilerThread3                                 -                         -1               -                0.0              0.000             0:0.421          false            true
-1       C2 CompilerThread4                                 -                         -1               -                0.0              0.000             0:0.296          false            true
-1       VM Periodic Task Thread                            -                         -1               -                0.0              0.000             0:0.281          false            true
-1       C1 CompilerThread9                                 -                         -1               -                0.0              0.000             0:0.218          false            true
-1       C1 CompilerThread8                                 -                         -1               -                0.0              0.000             0:0.218          false            true
-1       C1 CompilerThread11                                -                         -1               -                0.0              0.000             0:0.218          false            true
-1       C2 CompilerThread1                                 -                         -1               -                0.0              0.000             0:0.218          false            true
55       arthas-NettyHttpTelnetBootstrap-3-15               system                    5                RUNNABLE         0.0              0.000             0:0.171          false            true
Memory                                      used           total          max           usage          GC                                                                                                     
heap                                        63M            161M           3499M         1.81%          gc.ps_scavenge.count                                4                                                  
ps_eden_space                               43M            62M            1292M         3.40%          gc.ps_scavenge.time(ms)                             58
ps_survivor_space                           0K             10240K         10240K        0.00%          gc.ps_marksweep.count                               1                                                  
ps_old_gen                                  19M            89M            2624M         0.74%          gc.ps_marksweep.time(ms)                            78
nonheap                                     36M            37M            -1            97.66%         
code_cache                                  9M             9M             240M          3.78%
metaspace                                   24M            25M            -1            97.48%
compressed_class_space                      2M             3M             1024M         0.29%
direct                                      0K             0K             -             0.00%
Runtime                                                                                                                                                                                                       
os.name                                                                                                Windows 10
os.version                                                                                             10.0
java.version                                                                                           1.8.0_292
java.home                                                                                              D:\d_work_soft\AdoptOpenJDK\jdk-8.0.292.10-hotspot\jre
systemload.average                                                                                     -1.00
processors                                                                                             16
timestamp/uptime                                                                                       Thu May 27 16:45:46 CST 2021/87932s
[arthas@28628]$ thread -n 3
"Reference Handler" Id=2 cpuUsage=0.0% deltaTime=0ms time=15ms WAITING on java.lang.ref.Reference$Lock@3ad4e1b2
    at java.lang.Object.wait(Native Method)
    -  waiting on java.lang.ref.Reference$Lock@3ad4e1b2
    at java.lang.Object.wait(Object.java:502)
    at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)


"Finalizer" Id=3 cpuUsage=0.0% deltaTime=0ms time=0ms WAITING on java.lang.ref.ReferenceQueue$Lock@4ed60171
    at java.lang.Object.wait(Native Method)
    -  waiting on java.lang.ref.ReferenceQueue$Lock@4ed60171
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:144)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:165)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:216)


"Signal Dispatcher" Id=4 cpuUsage=0.0% deltaTime=0ms time=0ms RUNNABLE


[arthas@28628]$ quit

D:\>


参考

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值