arthas的使用

写在前面

Arthas是阿里爸爸开源出来的一款java监控工具,命令行操作,完全面向开发人员,其专业行令人发指.

安装过程

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

下载完jar包之后需要联网下载相关的jar包,当然这些操作都是arthas-boot.jar自动执行的

相关命令介绍

由于官方文档给的已经很全了我这里就工作中比较常用的几个命令描述下

 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
 ognl         Execute ognl expression.
 dashboard    Overview of target jvm's thread, memory, gc, vm, tomcat info.
 dump         Dump class byte array from JVM
 options      View and change various Arthas options
 cls          Clear the screen
 reset        Reset all the enhanced classes
 version      Display Arthas version
 shutdown     Shutdown Arthas server and exit the console
 session      Display current session information
 sysprop      Display, and change the system properties.
 sysenv       Display the system env.
 redefine     Redefine classes. @see Instrumentation#redefineClasses(ClassDefinition...)
 history      Display command history

执行dashboard后结果页面如下:

trace -e获取方法执行


`arthas trace -e`命令用于跟踪方法调用,可以帮助我们定位应用程序中的性能问题和异常情况。其用法如下: ``` trace -e <class-pattern> <method-pattern> ```

其中,`<class-pattern>`和`<method-pattern>`分别表示类名和方法名的匹配模式,可以使用通配符`*`进行模糊匹配。

例如,要跟踪`com.example.demo.service.UserService`类中的所有方法,可以使用以下命令: ``` trace -e com.example.demo.service.UserService * ```

要跟踪`com.example.demo.service.UserService`类中的`getUserById`方法,可以使用以下命令: ``` trace -e com.example.demo.service.UserService getUserById ```

在执行`trace -e`命令后,Arthas会输出所有匹配的方法调用信息,包括方法的入参和返回值,以及方法的执行时间等信息。

trace获取方法执行时间

 

官方文档

官方文档真的已经很想详细了(阿里爸爸很良心)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值