Alibaba开源Java诊断工具Arthas简单介绍


Alibaba开源Java诊断工具Arthas简单介绍

文章插图
 
?Alibaba开源JAVA诊断工具Arthas
Alibaba开源Java诊断工具Arthas简单介绍

文章插图
 
Arthas 是Alibaba开源的Java诊断工具,深受开发者喜爱 。在线排查问题,无需重启;动态跟踪Java代码;实时监控JVM状态 。
当你遇到以下类似问题而束手无策时,Arthas可以帮助你解决:
1)这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception?
2)我改的代码为什么没有执行到?难道是我没 commit?分支搞错了?
3)遇到问题无法在线上 debug,难道只能通过加日志再重新发布吗?
4)线上遇到某个用户的数据处理有问题,但线上同样无法 debug,线下无法重现!
5)是否有一个全局视角来查看系统的运行状况?
6)有什么办法可以监控到JVM的实时运行状态?
7)怎么快速定位应用的热点,生成火焰图?
Arthas支持JDK 6+,支持linux/mac/Winodws,采用命令行交互模式,同时提供丰富的 Tab 自动补全功能,进一步方便进行问题的定位和诊断 。
Github: https://github.com/alibaba/arthas
文档: https://alibaba.github.io/arthas/
下面介绍arthas的安装以及简单使用1、下载arthas在线方式快速安装curl -O https://alibaba.github.io/arthas/arthas-boot.jarjava -jar arthas-boot.jar离线的方式https://github.com/alibaba/arthas/releases/tag/arthas-all-3.3.6
下载arthas-bin.ziprz上传到服务器某个目录,例如/homemkdir arthasunzip arthas-bin.zip -d arthascd arthassh install-local.sh
Alibaba开源Java诊断工具Arthas简单介绍

文章插图
 

Alibaba开源Java诊断工具Arthas简单介绍

文章插图
 

Alibaba开源Java诊断工具Arthas简单介绍

文章插图
 
2、启动arthas1)用as.sh启动
【Alibaba开源Java诊断工具Arthas简单介绍】./as.sh
Alibaba开源Java诊断工具Arthas简单介绍

文章插图
 
2)用arthas-boot启动
java -jar arthas-boot.jar
选择应用java进程
例如kafka进程是第1个,输入1回车,Arthas会attach到目标进程上
Alibaba开源Java诊断工具Arthas简单介绍

文章插图
 
3、help命令查看命令帮助[arthas@10528]$ help NAME         DESCRIPTION                                                                                                                                                       help         Display Arthas Help                                                                                                                                               keymap       Display all the available keymap for the specified connection.                                                                                                    sc           Search all the classes loaded by JVM                                                                                                                              sm           Search the method of classes loaded by JVM                                                                                                                        classloader  Show classloader info                                                                                                                                             jad          Decompile class                                                                                                                                                   getstatic    Show the static field of a class                                                                                                                                  monitor      Monitor method execution statistics, e.g. total/success/failure count, average rt, fail rate, etc.                                                                stack        Display the stack trace for the specified class and method                                                                                                        thread       Display thread info, thread stack                                                                                                                                 trace        Trace the execution time of specified method invocation.                                                                                                          watch        Display the input/output parameter, return object, and thrown exception of specified method invocation                                                            tt           Time Tunnel                                                                                                                                                       jvm          Display the target JVM information                                                                                                                                perfcounter  Display the perf counter infornation.                                                                                                                             ognl         Execute ognl expression.                                                                                                                                          mc           Memory compiler, compiles java files into bytecode and class files in memory.                                                                                     redefine     Redefine classes. @see Instrumentation#redefineClasses(ClassDefinition...)                                                                                        dashboard    Overview of target jvm's thread, memory, gc, vm, Tomcat info.                                                                                                     dump         Dump class byte array from JVM                                                                                                                                    heapdump     Heap dump                                                                                                                                                         options      View and change various Arthas options                                                                                                                            cls          Clear the screen                                                                                                                                                  reset        Reset all the enhanced classes                                                                                                                                    version      Display Arthas version                                                                                                                                            session      Display current session information                                                                                                                               sysprop      Display, and change the system properties.                                                                                                                        sysenv       Display the system env.                                                                                                                                           vmoption     Display, and update the vm diagnostic options.                                                                                                                    logger       Print logger info, and update the logger level                                                                                                                    history      Display command history                                                                                                                                           cat          Concatenate and print files                                                                                                                                       echo         write arguments to the standard output                                                                                                                            pwd          Return working directory name                                                                                                                                     mbean        Display the mbean information                                                                                                                                     grep         grep command for pipes.                                                                                                                                           tee          tee command for pipes.                                                                                                                                            profiler     Async Profiler. https://github.com/jvm-profiling-tools/async-profiler                                                                                             stop         Stop/Shutdown Arthas server and exit the console.                                                                                                                [arthas@10528]$ 


推荐阅读