项目总结72:Arthas的常用指令使用

摘要:
项目摘要72:Arthas的常用说明使用START官方文件信息文件信息:https://arthas.aliyun.com/doc/tt.html启动方法1.javajar/usr/lib/arthas-packaging-3.3-bin/arthas-bot。罐子[root@kaihu-mngjsinterface-container-57599c47b8-mdvhmarthas-pa

 项目总结72:Arthas的常用指令使用

START

官方文档信息文档信息:https://arthas.aliyun.com/doc/tt.html

启动方法

1. java -jar /usr/lib/arthas-packaging-3.3.2-bin/arthas-boot.jar

[root@kaihu-mngjsinterface-container-57599c47b8-mdvhm arthas-packaging-3.3.2-bin]# java -jar /usr/lib/arthas-packaging-3.3.2-bin/arthas-boot.jar ## 启动Arthas
[INFO] arthas-boot version: 3.3.2
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 1 noble-metal-assets-statistics.jar
1 ##选择PID
[INFO] arthas home: /usr/lib/arthas-packaging-3.3.2-bin
[INFO] Try to attach process 1
[INFO] Attach process 1 success.
[INFO] arthas-client connect 127.0.0.1 3658
  ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.
/  O   |  .--. ''--.  .--'|  '--'  | /  O   '   .-'
|  .-.  ||  '--'.'   |  |   |  .--.  ||  .-.  |`.  `-.
|  | |  ||  |      |  |   |  |  |  ||  | |  |.-'    |
`--' `--'`--' '--'   `--'   `--'  `--'`--' `--'`-----'
wiki      https://alibaba.github.io/arthas
tutorials https://alibaba.github.io/arthas/arthas-tutorials
version   3.3.2
pid       1
time      2020-09-29 16:32:15

常用命令

    常用指令集合

项目总结72:Arthas的常用指令使用第1张

1. dashboard:查看当前进程的信息

[arthas@1]$ dashboard --help
 USAGE:
   dashboard [-h] [-i <value>] [-n <value>]

 SUMMARY:
   Overview of target jvm's thread, memory, gc, vm, tomcat info.

 EXAMPLES:
   dashboard
   dashboard -n 10
   dashboard -i 2000

 WIKI:
   https://alibaba.github.io/arthas/dashboard

 OPTIONS:
 -h, --help                                               this help
 -i, --interval <value>                                   The interval (in ms) between two executions, default is 5000 ms.
 -n, --number-of-execution <value>                        The number of times this command will be executed.

 项目总结72:Arthas的常用指令使用第2张

    2.thread: 查看当前线程信息,查看线程的堆栈

[arthas@1]$ thread --help
 USAGE:
   thread [-h] [-b] [--lockedMonitors] [--lockedSynchronizers] [-i <value>] [--state <value>] [-n <value>] [id]

 SUMMARY:
   Display thread info, thread stack

 EXAMPLES:
   thread
   thread 51
   thread -n -1
   thread -n 5
   thread -b
   thread -i 2000
   thread --state BLOCKED

 WIKI:
   https://alibaba.github.io/arthas/thread

 OPTIONS:
 -h, --help                                               this help
 -b, --include-blocking-thread                            Find the thread who is holding a lock that blocks the most number of threads.
     --lockedMonitors                                     Find the thread info with lockedMonitors flag, default value is false.
     --lockedSynchronizers                                Find the thread info with lockedSynchronizers flag, default value is false.
 -i, --sample-interval <value>                            Specify the sampling interval (in ms) when calculating cpu usage.
     --state <value>                                      Display the thead filter by the state. NEW, RUNNABLE, TIMED_WAITING, WAITING, BLOCKED, TERMINATED is optional.
 -n, --top-n-threads <value>                              The number of thread(s) to show, ordered by cpu utilization, -1 to show all.
 <id>                                                     Show thread stack

项目总结72:Arthas的常用指令使用第3张

3. jad:反编译class文件

[arthas@1]$ jsd --help
java.lang.IllegalArgumentException: jsd: command not found
[arthas@1]$ jad --help
 USAGE:
   jad [-c <value>] [-h] [--hideUnicode] [-E] [--source-only] class-pattern [method-name]

 SUMMARY:
   Decompile class

 EXAMPLES:
   jad java.lang.String
   jad java.lang.String toString
   jad --source-only java.lang.String
   jad -c 39eb305e org/apache/log4j/Logger
   jad -c 39eb305e -E org\.apache\.*\.StringUtils

 WIKI:
   https://alibaba.github.io/arthas/jad

 OPTIONS:
 -c, --code <value>                                       The hash code of the special class's classLoader
 -h, --help                                               this help
     --hideUnicode                                        hide unicode, default value false
 -E, --regex                                              Enable regular expression to match (wildcard matching by default)
     --source-only                                        Output source code only
 <class-pattern>                                          Class name pattern, use either '.' or '/' as separator
 <method-name>                                            method name pattern, decompile a specific method instead of the whole class

 项目总结72:Arthas的常用指令使用第4张

4. watch   查看函数返回值

[arthas@1]$ watch --help
 USAGE:
   watch [-b] [-e] [-x <value>] [-f] [-h] [-n <value>] [--listenerId <value>] [-E] [-M <value>] [-s] class-pattern method-pattern [express] [condition-express]

 SUMMARY:
   Display the input/output parameter, return object, and thrown exception of specified method invocation
   The express may be one of the following expression (evaluated dynamically):
           target : the object
            clazz : the object's class
           method : the constructor or method
           params : the parameters array of method
     params[0..n] : the element of parameters array
        returnObj : the returned object of method
         throwExp : the throw exception of method
         isReturn : the method ended by return
          isThrow : the method ended by throwing exception
            #cost : the execution time in ms of method invocation
 Examples:
   watch -b org.apache.commons.lang.StringUtils isBlank params
   watch -f org.apache.commons.lang.StringUtils isBlank returnObj
   watch org.apache.commons.lang.StringUtils isBlank '{params, target, returnObj}' -x 2
   watch -bf *StringUtils isBlank params
   watch *StringUtils isBlank params[0]
   watch *StringUtils isBlank params[0] params[0].length==1
   watch *StringUtils isBlank params '#cost>100'
   watch -E -b org.apache.commons.lang.StringUtils isBlank params[0]


 OPTIONS:
 -b, --before                                             Watch before invocation
 -e, --exception                                          Watch after throw exception
 -x, --expand <value>                                     Expand level of object (1 by default)
 -f, --finish                                             Watch after invocation, enable by default
 -h, --help                                               this help
 -n, --limits <value>                                     Threshold of execution times
     --listenerId <value>                                 The special listenerId
 -E, --regex                                              Enable regular expression to match (wildcard matching by default)
 -M, --sizeLimit <value>                                  Upper size limit in bytes for the result (10 * 1024 * 1024 by default)
 -s, --success                                            Watch after successful invocation
 <class-pattern>                                          The full qualified class name you want to watch
 <method-pattern>                                         The method name you want to watch
 <express>                                                the content you want to watch, written by ognl.
                                                          Examples:
                                                            params
                                                            params[0]
                                                            'params[0]+params[1]'
                                                            '{params[0], target, returnObj}'
                                                            returnObj
                                                            throwExp
                                                            target
                                                            clazz
                                                            method

 <condition-express>                                      Conditional expression in ognl style, for example:
                                                            TRUE  : 1==1
                                                            TRUE  : true
                                                            FALSE : false
                                                            TRUE  : 'params.length>=0'
                                                            FALSE : 1==2

项目总结72:Arthas的常用指令使用第5张

5.monitor:监控方法执行次数

[arthas@1]$ monitor --help
 USAGE:
   monitor [-c <value>] [-h] [-n <value>] [--listenerId <value>] [-E <value>] class-pattern method-pattern

 SUMMARY:
   Monitor method execution statistics, e.g. total/success/failure count, average rt, fail rate, etc.

 Examples:
   monitor org.apache.commons.lang.StringUtils isBlank
   monitor org.apache.commons.lang.StringUtils isBlank -c 5
   monitor -E org.apache.commons.lang.StringUtils isBlank

 WIKI:
   https://alibaba.github.io/arthas/monitor

 OPTIONS:
 -c, --cycle <value>                                      The monitor interval (in seconds), 60 seconds by default
 -h, --help                                               this help
 -n, --limits <value>                                     Threshold of execution times
     --listenerId <value>                                 The special listenerId
 -E, --regex <value>                                      Enable regular expression to match (wildcard matching by default)
 <class-pattern>                                          Path and classname of Pattern Matching
 <method-pattern>                                         Method of Pattern Matching

 项目总结72:Arthas的常用指令使用第6张

6.TT: 方法执行数据的时空隧道,记录下指定方法每次调用的入参和返回信息,并能对这些不同的时间下调用进行观测

[arthas@1]$ tt --help
 USAGE:
   tt [-d] [--delete-all] [-x <value>] [-h] [-i <value>] [-n <value>] [-l] [--listenerId <value>] [-p] [-E] [--replay-interval <value>] [--replay-times <value>] [-s <val
 ue>] [-M <value>] [-t] [-w <value>] [class-pattern] [method-pattern] [condition-express]

 SUMMARY:
   Time Tunnel
   The express may be one of the following expression (evaluated dynamically):
           target : the object
            clazz : the object's class
           method : the constructor or method
           params : the parameters array of method
     params[0..n] : the element of parameters array
        returnObj : the returned object of method
         throwExp : the throw exception of method
         isReturn : the method ended by return
          isThrow : the method ended by throwing exception
            #cost : the execution time in ms of method invocation
 EXAMPLES:
   tt -t *StringUtils isEmpty
   tt -t *StringUtils isEmpty params[0].length==1
   tt -l
   tt -i 1000
   tt -i 1000 -w params[0]
   tt -i 1000 -p
   tt -i 1000 -p --replay-times 3 --replay-interval 3000
   tt --delete-all

 WIKI:
   https://alibaba.github.io/arthas/tt

 OPTIONS:
 -d, --delete                                             Delete time fragment specified by index
     --delete-all                                         Delete all the time fragments
 -x, --expand <value>                                     Expand level of object (1 by default)
 -h, --help                                               this help
 -i, --index <value>                                      Display the detailed information from specified time fragment
 -n, --limits <value>                                     Threshold of execution times
 -l, --list                                               List all the time fragments
     --listenerId <value>                                 The special listenerId
 -p, --play                                               Replay the time fragment specified by index
 -E, --regex                                              Enable regular expression to match (wildcard matching by default)
     --replay-interval <value>                            replay interval  for  play tt with option r greater than 1
     --replay-times <value>                               execution times when play tt
 -s, --search-express <value>                             Search-expression, to search the time fragments by ognl express.
                                                          The structure of 'advice' like conditional expression
 -M, --sizeLimit <value>                                  Upper size limit in bytes for the result (10 * 1024 * 1024 by default)
 -t, --time-tunnel                                        Record the method invocation within time fragments
 -w, --watch-express <value>                              watch the time fragment by ognl express.
                                                          Examples:
                                                            params
                                                            params[0]
                                                            'params[0]+params[1]'
                                                            '{params[0], target, returnObj}'
                                                            returnObj
                                                            throwExp
                                                            target
                                                            clazz
                                                            method

 <class-pattern>                                          Path and classname of Pattern Matching
 <method-pattern>                                         Method of Pattern Matching
 <condition-express>                                      Conditional expression in ognl style, for example:
                                                            TRUE  : 1==1
                                                            TRUE  : true
                                                            FALSE : false
                                                            TRUE  : 'params.length>=0'
                                                            FALSE : 1==2

 项目总结72:Arthas的常用指令使用第7张

7.trace:方法内部调用路径,并输出方法路径上的每个节点上耗时

[arthas@1]$ trace --help
 USAGE:
   trace [-h] [-n <value>] [--listenerId <value>] [-p <value>] [-E] [--skipJDKMethod <value>] class-pattern method-pattern [condition-express]

 SUMMARY:
   Trace the execution time of specified method invocation.
   The express may be one of the following expression (evaluated dynamically):
           target : the object
            clazz : the object's class
           method : the constructor or method
           params : the parameters array of method
     params[0..n] : the element of parameters array
        returnObj : the returned object of method
         throwExp : the throw exception of method
         isReturn : the method ended by return
          isThrow : the method ended by throwing exception
            #cost : the execution time in ms of method invocation
 EXAMPLES:
   trace org.apache.commons.lang.StringUtils isBlank
   trace *StringUtils isBlank
   trace *StringUtils isBlank params[0].length==1
   trace *StringUtils isBlank '#cost>100'
   trace -E org\.apache\.commons\.lang\.StringUtils isBlank
   trace -E com.test.ClassA|org.test.ClassB method1|method2|method3
   trace demo.MathGame run -n 5
   trace demo.MathGame run --skipJDKMethod false

 WIKI:
   https://alibaba.github.io/arthas/trace

 OPTIONS:
 -h, --help                                               this help
 -n, --limits <value>                                     Threshold of execution times
     --listenerId <value>                                 The special listenerId
 -p, --path <value>                                       path tracing pattern
 -E, --regex                                              Enable regular expression to match (wildcard matching by default)
     --skipJDKMethod <value>                              skip jdk method trace, default value true.
 <class-pattern>                                          Class name pattern, use either '.' or '/' as separator
 <method-pattern>                                         Method name pattern
 <condition-express>                                      Conditional expression in ognl style, for example:
                                                            TRUE  : 1==1
                                                            TRUE  : true
                                                            FALSE : false
                                                            TRUE  : 'params.length>=0'
                                                            FALSE : 1==2

 项目总结72:Arthas的常用指令使用第8张

8.火焰图

9.连接问题

  如果只是退出当前的连接,可以用quit或者exit命令。Attach到目标进程上的arthas还会继续运行,端口会保持开放,下次连接时可以直接连接上。
  如果想完全退出arthas,可以执行stop命令。
 

END

免责声明:文章转载自《项目总结72:Arthas的常用指令使用》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇js动态生成二维码开源中间件大舞台下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

随便看看

(转)在CentOS中修改中文字符集

本文介绍在linux的shell环境下优化linux中文显示的方法。在CentOS7以前的版本下,默认的字符集的路径一般保存在/etc/sysconfig/i18n文件中。但是在CentOS7版本中,字符集配置文件位于/etc/locale.conf。通过source命令即可使修改生效:[ruby]viewplaincopy#source/etc/local...

TCL基本语法2

TCL基本语法21、format和scan两个基本的函数,和C语言中的sprintf和scanf的作用基本相同。format将不同类型的数据压缩在字符串中,scan将字符串中的数据提取出来。setnameJacksetage100setworker[format"%sis%dyearsold"$name$age]puts$workerscan$worker"...

解决xcode打开时loading假死的问题

出现这个问题就真得崩溃了,有些小伙伴甚至还重装了Xcode,这里给大家推荐一个行之有效的方法。...

MySQL锁详解

MySQL锁详解update语句执行流程MySQL的锁介绍按照锁的粒度来说,MySQL主要包含三种类型(级别)的锁定机制:全局锁:锁的是整个database。由MySQL的SQLlayer层实现的表级锁:锁的是某个table。由MySQL的SQLlayer层实现的行级锁:锁的是某行数据,也可能锁定行之间的间隙。...

Qt中使用定时器(可使用QObject::timerEvent定时执行,QTimer::singleShot可只触发一次)

在Qt中使用定时器有两种方法,一种是使用QObiect类的定时器;一种是使用QTimer类。当定时器触发时,应用程序会发送一个QTimerEvent。与定时器相关的成员函数有:startTimer()、timeEvent()、killTimer()。virtualvoidQObject::timerEvent;虚函数timerEvent()被重载来实现用户的...

"SQLserver 事务日志已满"解决方法

如果不够,备份后换个地方存[注:tempdb你数据库名称。...