美文网首页
arthas 简单笔记

arthas 简单笔记

作者: 阿福德 | 来源:发表于2019-08-07 12:10 被阅读0次

    下载 wget https://alibaba.github.io/arthas/arthas-boot.jar
    找到想要关注的进程号
    运行启动arthas
    java -jar arthas-boot.jar

    [rest@bms-billimport002 tmp]$ java -jar arthas-boot.jar 
    [INFO] arthas-boot version: 3.1.1
    [INFO] Found existing java process, please choose one and hit RETURN.
    * [1]: 31298 org.apache.catalina.startup.Bootstrap
      [2]: 12581 org.apache.catalina.startup.Bootstrap
      [3]: 5477 org.apache.catalina.startup.Bootstrap
    

    选择进程号

    dashboard命令查询线程情况

    $ dashboard
    

    sc命令搜索类

    $sc *DispatcherServlet*
    

    sm命令搜索方法

    $sm org.springframework.web.servlet.DispatcherServlet
    

    watch 命令查看方法参数与方法返回数据, -x 表示指定打印参数或返回值的层级

    $ watch org.springframework.web.servlet.DispatcherServlet noHandlerFound params
    $ watch org.springframework.web.servlet.DispatcherServlet noHandlerFound returnObj 
    $ watch org.springframework.web.servlet.DispatcherServlet noHandlerFound {params,returnObj} -x 2
    

    通过thread命令查看线程

    $ thread
    Threads Total: 89, NEW: 0, RUNNABLE: 25, BLOCKED: 0, WAITING: 40, TIMED_WAITING: 24, TERMINATED: 0                                                                                             
    ID              NAME                                            GROUP                           PRIORITY       STATE           %CPU            TIME            INTERRUPTED     DAEMON          
    1313            as-command-execute-daemon                       system                          10             RUNNABLE        58              0:0             false           true            
    19              localhost-startStop-1-SendThread(10.168.155.25: main                            5              RUNNABLE        19              0:20            false           true            
    105             DubboResponseTimeoutScanTimer                   main                            5              TIMED_WAITING   9               4:0             false           true            
    90              http-nio-7071-ClientPoller-1                    main                            5              RUNNABLE        4               0:12            false           true            
    31              Hashed wheel timer #1                           main                            5              TIMED_WAITING   3               1:40            false           false           
    32              New I/O boss #4                                 main                            5              RUNNABLE        2               0:20            false           true            
    

    查看当前最繁忙的几个线程

    $ thread -n 2
    "as-command-execute-daemon" Id=1316 cpuUsage=59% RUNNABLE
        at sun.management.ThreadImpl.dumpThreads0(Native Method)
        at sun.management.ThreadImpl.getThreadInfo(ThreadImpl.java:440)
        at com.taobao.arthas.core.command.monitor200.ThreadCommand.processTopBusyThreads(ThreadCommand.java:133)
        at com.taobao.arthas.core.command.monitor200.ThreadCommand.process(ThreadCommand.java:79)
        at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.process(AnnotatedCommandImpl.java:82)
        at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl.access$100(AnnotatedCommandImpl.java:18)
        at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:111)
        at com.taobao.arthas.core.shell.command.impl.AnnotatedCommandImpl$ProcessHandler.handle(AnnotatedCommandImpl.java:108)
        at com.taobao.arthas.core.shell.system.impl.ProcessImpl$CommandProcessTask.run(ProcessImpl.java:370)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
    
        Number of locked synchronizers = 1
        - java.util.concurrent.ThreadPoolExecutor$Worker@2bb3a482
    
    
    "DubboResponseTimeoutScanTimer" Id=105 cpuUsage=12% TIMED_WAITING
        at java.lang.Thread.sleep(Native Method)
        at com.alibaba.dubbo.remoting.exchange.support.DefaultFuture$RemotingInvocationTimeoutScan.run(DefaultFuture.java:300)
        at java.lang.Thread.run(Thread.java:745)
    
    

    通过jad名反编译类

    $ jad org.springframework.web.servlet.DispatcherServlet
    
    ClassLoader:                                                                                                                                                                                   
    +-WebappClassLoader                                                                                                                                                                            
        context:                                                                                                                                                                                   
        delegate: false                                                                                                                                                                            
        repositories:                                                                                                                                                                              
          /WEB-INF/classes/                                                                                                                                                                        
      ----------> Parent Classloader:                                                                                                                                                              
      java.net.URLClassLoader@1100c7e4                                                                                                                                                             
                                                                                                                                                                                                   
      +-java.net.URLClassLoader@1100c7e4                                                                                                                                                           
        +-sun.misc.Launcher$AppClassLoader@5bdf59bd                                                                                                                                                
          +-sun.misc.Launcher$ExtClassLoader@247cb66a
    .....
    

    其他命令, trace, stack
    参考文档:https://alibaba.github.io/arthas/index.html
    exit 退出

    相关文章

      网友评论

          本文标题:arthas 简单笔记

          本文链接:https://www.haomeiwen.com/subject/iihodctx.html