play_arthas

介绍

arthas是阿里开源的java监控和调试工具
Arthas 是基于 Greys 进行二次开发的全新在线诊断工具,利用Java6的Instrumentation特性,
动态增强你所指定的类,获取你想要到的信息, 采用命令行交互模式,同时提供丰富的 Tab 自动补全功能,
让你在定位、分析诊断问题时看每一个操作都看起来是强大
doc --> https://alibaba.github.io/arthas/
code --> https://github.com/alibaba/arthas/releases/tag/arthas-all-3.0.5

  • 这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception?
  • 我改的代码为什么没有执行到?难道是我没 commit?分支搞错了?
  • 遇到问题无法在预发 debug 一下,难道只能通过加日志再重新预发布吗?
  • 线上遇到某个用户的数据处理有问题,但线上同样无法 debug,线下无法重现,怎么办?
  • 是否有一个全局视角来查看系统的运行状况? 有什么办法可以监控到容器和中间件的实时运行状态?

安装

arthas 3.0.5
https://github.com/alibaba/arthas/releases/download/arthas-all-3.0.5/arthas-3.0.5-bin.zip

the orginal startup command is not ok for me. So I write my own one.
step1:
extract arthas-3.0.5-bin.zip, and get those files
在这里插入图片描述
step2:

run_demo.bat ( for win)

set JAVA_HOME=C:/Progra~1/Java/jdk1.8.0_66
%JAVA_HOME%/bin/java -jar arthas-demo.jar

run.bat( for win)

set JAVA_HOME=C:/Progra~1/Java/jdk1.8.0_66
%JAVA_HOME%/bin/jps -m

set as_h=.
set as_pid=???
set as_ip=127.0.0.1
set as_telnet_port=13658
set as_http_port=18563

%JAVA_HOME%/bin/java -Dfile.encoding=UTF-8 -Xbootclasspath/a:%JAVA_HOME%\lib\tools.jar -jar arthas-core.jar -pid "%as_pid%"  -target-ip %as_ip% -telnet-port %as_telnet_port% -http-port %as_http_port% -core arthas-core.jar -agent arthas-agent.ja

pause

??? is demo appliation PID, it comes from jps command. See red. it is 2248
if you want remote, please set as_ip as the pc ip, which run run.bat. Here I use 127.0.0, I just use it in local development pc.

在这里插入图片描述

run_demo.sh ( for linux)
? add later

run.sh ( for linux)
? add later

step3:

execute run_demo.bat to start a demo for test

在这里插入图片描述

execute run.bat to attach Arthas to demo PID
在这里插入图片描述

step4:

connect by telnet

I use putty
在这里插入图片描述

final
在这里插入图片描述

connect by web console

http://localhost:18563/

final
在这里插入图片描述

do test based on demo

sc

sc demo*

sc demo*  // search class by name, for example it will be demo.MathGame
sc -d demo.MathGame // it will list all info of this class

在这里插入图片描述

sm

sm -d demo.MathGame // list all methods of this class

trace

trace demo.MathGame * // statck of method call, here it is *, means all methods

在这里插入图片描述

monitor

monitor demo.MathGame * // method calling statistic

it is slow, not show result immediately, wait a while
在这里插入图片描述

watch

watch demo.MathGame primeFactors '{params[0],returnObj}' // params[0] is the first input parameter of this method, returnObj means return value of this method.

在这里插入图片描述

jad

shutdown/quit/exit

do test on springboot

all entry is servlet.service

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值