Arthas和JDK中的JVM工具、jprofiler一样,可以分析Java进程。
官方文档:https://arthas.aliyun.com/doc/
jprofiler:
官网:https://www.ej-technologies.com/products/jprofiler/overview.html
官方教程:https://www.ej-technologies.com/products/jprofiler/docs
中文简介:https://www.evget.com/product/743/
Arthas安装:
curl -O https://arthas.aliyun.com/arthas-boot.jar可以下载arthas工具包。
java -jar arthas-boot.jar可以执行工具包。 如果提示找不到tools.jar,就在java -jar前加上java.sh或者java.exe所在的bin目录的绝对路径。
Arthas目标:
Arthas 是Alibaba开源的Java诊断工具,深受开发者喜爱。
当你遇到以下类似问题而束手无策时,Arthas可以帮助你解决: 这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception?
我改的代码为什么没有执行到?难道是我没 commit?分支搞错了? 遇到问题无法在线上 debug,难道只能通过加日志再重新发布吗?
线上遇到某个用户的数据处理有问题,但线上同样无法 debug,线下无法重现! 是否有一个全局视角来查看系统的运行状况?
有什么办法可以监控到JVM的实时运行状态? 怎么快速定位应用的热点,生成火焰图? 怎样直接从JVM内查找某个类的实例?
Arthas支持JDK 6+,支持Linux/Mac/Windows,采用命令行交互模式,同时提供丰富的 Tab
自动补全功能,进一步方便进行问题的定位和诊断。 https://arthas.aliyun.com/doc/index.html
Arthas命令:
dashboard可以查看线程、内存、CPU、GC信息。Windows和Mac都是Ctrl+C可以停止实时采集。
thread 1 | grep 'main('可以查看入口类。
jad命令可以反编译类。
quit退出连接。
stop彻底退出。
常用命令:https://arthas.aliyun.com/doc/advanced-use.html
所有命令:https://arthas.aliyun.com/doc/commands.html
火焰图:https://arthas.aliyun.com/doc/profiler.html
Arthas还提供网页方式连接Arthas和输入命令。 https://arthas.aliyun.com/doc/web-console.html
Arthas获取Http的响应。 https://arthas.aliyun.com/doc/http-api.html
安装Arthas的IDEA插件。 https://arthas.aliyun.com/doc/idea-plugin.html
Arthas用户案例。https://github.com/alibaba/arthas/issues?q=label%3Auser-case
Arthas官方教程:https://start.aliyun.com/#guangfang