arthas使用详解

之前写过一篇java程序造成linux服务器cpu使用率非常高的排除方法_leonnew的博客-CSDN博客

里面提到过arthas程序的简单用法。今天再详细说下几个特殊功能

运行一个demo:wget https://arthas.aliyun.com/math-game.jar

java -jar math-game.jar

如何获得arthas:wget https://arthas.aliyun.com/arthas-boot.jar

如何启动:java -jar arthas-boot.jar

arthas-boot is the launcher for Arthas. It lists all the Java processes, and the user can select the target process to be diagnosed.

Select the first process, type 1 ,then type Enter

After the Attach is successful, Arthas LOGO is printed. Enter help for more help.

Dashboard

1、The dashboard command allows you to view the real-time data panel of the current system.

Thread

2、The thread 1 command prints the stack of thread ID 1.

Arthas supports pipes, and you can find main class with thread 1 | grep 'main('.

You can see that main class is demo.MathGame:

打印线程的栈,可以看到main class是demo.MathGame

$ thread 1 | grep 'main('
    at demo.MathGame.main(MathGame.java:17)

Sc

3、The sc command can be used to find the loaded classes in the JVM:

sc -d *MathGame

用来查询jvm加载的类

Jad

4、The jad command can be used to decompile the byte code:

jad demo.MathGame

用来反编译代码,可以看到MathGame的main类的代码内容

通过--source-only参数可以只打印出在反编译的源代码

jad --source-only com.example.demo.arthas.user.UserController

 Watch

The watch command can view the parameter/return value/exception of the method.

watch demo.MathGame primeFactors returnObj

可以查看函数的参数/返回值/异常信息。

 Vmtool

The vmtool command can search object in JVM.

vmtool --action getInstances --className java.lang.String --limit 10

bash $ vmtool --action getInstances --className java.lang.String --limit 10 @String[][ @String[com/taobao/arthas/core/shell/session/Session], @String[com.taobao.arthas.core.shell.session.Session], @String[com/taobao/arthas/core/shell/session/Session], @String[com/taobao/arthas/core/shell/session/Session], @String[com/taobao/arthas/core/shell/session/Session.class], @String[com/taobao/arthas/core/shell/session/Session.class], @String[com/taobao/arthas/core/shell/session/Session.class], @String[com/], @String[java/util/concurrent/ConcurrentHashMap$ValueIterator], @String[java/util/concurrent/locks/LockSupport], ]

可以看到jvm虚拟机运行机制

 Arthas can be exited with the exit or quit command.

exit和quit可以退出arthas

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值