java ee / jvm analysis tools / Arthas

s

Arthas - Java 线上问题定位处理的终极利器

https://blog.csdn.net/u013735734/article/details/102930307

https://my.oschina.net/u/4357854/blog/3566198

软件简介

Arthas(阿尔萨斯)是阿里巴巴开源的 Java 诊断工具,深受开发者喜爱。

当你遇到以下类似问题而束手无策时,Arthas 可以帮助你解决:

  1. 这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception?

  2. 我改的代码为什么没有执行到?难道是我没 commit?分支搞错了?

  3. 遇到问题无法在线上 debug,难道只能通过加日志再重新发布吗?

  4. 线上遇到某个用户的数据处理有问题,但线上同样无法 debug,线下无法重现!

  5. 是否有一个全局视角来查看系统的运行状况?

  6. 有什么办法可以监控到JVM的实时运行状态?

Arthas 采用命令行交互模式,同时提供丰富的 Tab 自动补全功能,进一步方便进行问题的定位和诊断。

截图展示

Dashboard

Web Console

下载&启动

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

启动

java -jar arthas-boot.jar

查看日志

cat ~/logs/arthas/arthas.log

Web控制台

http://127.0.0.1:8563

查看帮助

java -jar arthas-boot.jar -h

快速开始

下载demo并启动

wget https://alibaba.github.io/arthas/arthas-demo.jar
java -jar arthas-demo.jar

启动arthas

查看dashboard

通过thread命令来获取到arthas-demo进程的Main Class

通过jad来反编译Main Class

退出arthas

如果只是退出当前的连接,可以用quit或者exit命令

如果想完全退出arthas,可以执行shutdown命令

文档

https://github.com/alibaba/arthas

https://alibaba.github.io/arthas/index.html

https://alibaba.github.io/arthas/install-detail.html

https://alibaba.github.io/arthas/quick-start.html

https://alibaba.github.io/arthas/advanced-use.html

https://alibaba.github.io/arthas/commands.html

实战演练

# 查看占CPU资源最多的前3个线程
thread -n 3

# 观察方法执行的时候哪个子调用比较慢
trace com.xxx.cms.story.controller.product.ProductController list

# 监控某个特殊方法的调用统计数据,包括总调用次数,平均rt,成功率等信息,每隔5秒输出一次
monitor -c 5 com.xxx.cms.story.controller.product.ProductController list

end

原文地址:https://www.cnblogs.com/lindows/p/14713190.html