Arthas Ali online troubleshooting tool

table of Contents

What can Arthas do for you?

Arthas a sneak peek

watch print input parameters and return value

The order and execution of the trace printing method

ttStatic method field value call

monitor method execution time

Connect arthas through a browser


Web address: https://arthas.aliyun.com/doc/index.html 

What can Arthas do for you?

_images/arthas.png

Arthas It is Alibaba's open source Java diagnostic tool, which is deeply loved by developers.

When you encounter the following similar problems and are at a loss, it Arthascan help you solve them:

  1. Which jar package is this class loaded from? Why are various types of related Exception reported?

  2. Why is the code I changed not executed? Could it be that I didn't commit? Wrong branch?

  3. I can’t debug online if I encounter a problem, can I only republish it by adding a log?

  4. I encountered a user's data processing problem online, but the online debugging is also impossible, and the offline cannot be reproduced!

  5. Is there a global perspective to view the health of the system?

  6. Is there any way to monitor the real-time running status of the JVM?

  7. How to quickly locate application hot spots and generate flame graphs?

ArthasSupport JDK 6+, support Linux/Mac/Windows, adopt the command line interactive mode, and provide rich  Tab auto-completion functions to further facilitate problem location and diagnosis.

Arthas a sneak peek

The premise is to install Arthas, refer to the domestic gitee address: https://gitee.com/arthas/arthas

watch print input parameters and return value

[arthas@18656]$ watch com.forestar.redis.RedisDistributedLock tryGetDistributedLock "{params,returnObj}" -x 2 -b -s -n 10
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 81 ms, listenerId: 7
method=com.forestar.redis.RedisDistributedLock.tryGetDistributedLock location=AtEnter
ts=2021-03-03 09:15:33; [cost=0.038707ms] result=@ArrayList[
    @Object[][
        @String[xht:application:hly-id-lock],
        @String[71f3965f-9429-4104-a475-03eacfd48dec],
        @Integer[5000],
    ],
    null,
]
method=com.forestar.redis.RedisDistributedLock.tryGetDistributedLock location=AtExit
ts=2021-03-03 09:15:33; [cost=2.3058954671954437E10ms] result=@ArrayList[
    @Object[][
        @String[xht:application:hly-id-lock],
        @String[71f3965f-9429-4104-a475-03eacfd48dec],
        @Integer[5000],
    ],
    @Boolean[true],
]
method=com.forestar.redis.RedisDistributedLock.tryGetDistributedLock location=AtEnter
ts=2021-03-03 09:15:43; [cost=0.016312ms] result=@ArrayList[
    @Object[][
        @String[xht:application:hly-id-lock],
        @String[7471d14f-4a60-4011-9623-d42b11e6d78c],
        @Integer[5000],
    ],
    null,
]
method=com.forestar.redis.RedisDistributedLock.tryGetDistributedLock location=AtExit
ts=2021-03-03 09:15:43; [cost=2.3058964472276306E10ms] result=@ArrayList[
    @Object[][
        @String[xht:application:hly-id-lock],
        @String[7471d14f-4a60-4011-9623-d42b11e6d78c],
        @Integer[5000],
    ],
    @Boolean[true],
]
method=com.forestar.redis.RedisDistributedLock.tryGetDistributedLock location=AtEnter
ts=2021-03-03 09:15:46; [cost=0.016448ms] result=@ArrayList[
    @Object[][
        @String[xht:application:hly-id-lock],
        @String[9132dcb6-b999-4fdc-902e-f834acd6a029],
        @Integer[5000],
    ],
    null,
]
method=com.forestar.redis.RedisDistributedLock.tryGetDistributedLock location=AtExit
ts=2021-03-03 09:15:46; [cost=2.3058967163121655E10ms] result=@ArrayList[
    @Object[][
        @String[xht:application:hly-id-lock],
        @String[9132dcb6-b999-4fdc-902e-f834acd6a029],
        @Integer[5000],
    ],
    @Boolean[false],
]
method=com.forestar.redis.RedisDistributedLock.tryGetDistributedLock location=AtEnter
ts=2021-03-03 09:15:51; [cost=0.011194ms] result=@ArrayList[
    @Object[][
        @String[xht:application:hly-id-lock],
        @String[9132dcb6-b999-4fdc-902e-f834acd6a029],
        @Integer[5],
    ],
    null,
]

The order and execution of the trace printing method

[arthas@18656]$ trace com.forestar.xht.hly.XHRYCtrl hly_add 
Press Q or Ctrl+C to abort.
Affect(class count: 2 , method count: 2) cost in 319 ms, listenerId: 10
`---ts=2021-03-03 09:33:07;thread_name=http-nio-8081-exec-7;id=27;is_daemon=true;priority=5;TCCL=org.apache.catalina.loader.WebappClassLoader@432cd66e
    `---[2.241784ms] com.forestar.xht.hly.XHRYCtrl$$EnhancerByCGLIB$$9eca3052:hly_add()
        `---[2.068124ms] net.sf.cglib.proxy.MethodInterceptor:intercept() #95
            `---[1.930108ms] com.forestar.xht.hly.XHRYCtrl:hly_add()
                +---[0.036573ms] data.common.util.StringUtils:IsNullOrEmpty() #183
                +---[0.01407ms] com.forestar.xht.util.Utils:getWorkSpace() #189
                +---[0.044448ms] com.forestar.xht.util.Utils:getMetadataWorkspace() #192
                +---[0.017292ms] data.metadata.IMetadataWorkspace:OpenTable() #95
                +---[0.00912ms] com.forestar.xht.util.Utils:getBaseDataService() #193
                +---[0.183323ms] com.alibaba.fastjson.JSONObject:parseObject() #196
                +---[0.011264ms] data.general.RowBase:<init>() #198
                +---[0.010371ms] data.general.RowBase:setCurrentObjects() #199
                +---[0.008256ms] com.forestar.core.session.SessionFactory:getSession() #201
                +---[0.010008ms] com.forestar.core.session.ISession:getTableSuffix() #95
                +---[0.037512ms] data.general.RowBase:getCurrentObjects() #202
                +---[0.010109ms] com.forestar.syscore.encrypt.MD5:<init>() #203
                +---[0.006698ms] data.general.RowBase:getCurrentObjects() #204
                +---[0.034949ms] com.forestar.syscore.encrypt.MD5:getMD5() #95
                +---[0.008434ms] data.general.RowBase:getCurrentObjects() #206
                +---[0.007273ms] data.general.QueryFilter:<init>() #207
                +---[0.024029ms] data.general.QueryFilter:setWhereString() #208
                `---[0.77195ms] com.forestar.redis.RedisDistributedLock:tryGetDistributedLockByBlocking() #215
 
`---ts=2021-03-03 09:33:16;thread_name=http-nio-8081-exec-35;id=52;is_daemon=true;priority=5;TCCL=org.apache.catalina.loader.WebappClassLoader@432cd66e
    `---[1.0833ms] com.forestar.xht.hly.XHRYCtrl$$EnhancerByCGLIB$$9eca3052:hly_add()
        `---[1.019633ms] net.sf.cglib.proxy.MethodInterceptor:intercept() #95
            `---[0.954022ms] com.forestar.xht.hly.XHRYCtrl:hly_add()
                +---[0.007426ms] data.common.util.StringUtils:IsNullOrEmpty() #183
                +---[0.038057ms] com.forestar.xht.util.Utils:getWorkSpace() #189
                +---[0.00616ms] com.forestar.xht.util.Utils:getMetadataWorkspace() #192
                +---[0.007478ms] data.metadata.IMetadataWorkspace:OpenTable() #95
                +---[0.007375ms] com.forestar.xht.util.Utils:getBaseDataService() #193
                +---[0.038762ms] com.alibaba.fastjson.JSONObject:parseObject() #196
                +---[0.005113ms] data.general.RowBase:<init>() #198
                +---[0.006275ms] data.general.RowBase:setCurrentObjects() #199
                +---[0.006229ms] com.forestar.core.session.SessionFactory:getSession() #201
                +---[0.006964ms] com.forestar.core.session.ISession:getTableSuffix() #95
                +---[0.004853ms] data.general.RowBase:getCurrentObjects() #202
                +---[0.005499ms] com.forestar.syscore.encrypt.MD5:<init>() #203
                +---[0.004376ms] data.general.RowBase:getCurrentObjects() #204
                +---[0.019182ms] com.forestar.syscore.encrypt.MD5:getMD5() #95
                +---[0.004806ms] data.general.RowBase:getCurrentObjects() #206
                +---[0.005104ms] data.general.QueryFilter:<init>() #207
                +---[0.004758ms] data.general.QueryFilter:setWhereString() #208
                `---[0.511894ms] com.forestar.redis.RedisDistributedLock:tryGetDistributedLockByBlocking() #215
 
`---ts=2021-03-03 09:33:25;thread_name=http-nio-8081-exec-15;id=2f;is_daemon=true;priority=5;TCCL=org.apache.catalina.loader.WebappClassLoader@432cd66e
    `---[0.95822ms] com.forestar.xht.hly.XHRYCtrl$$EnhancerByCGLIB$$9eca3052:hly_add()
        `---[0.920732ms] net.sf.cglib.proxy.MethodInterceptor:intercept() #95
            `---[0.866213ms] com.forestar.xht.hly.XHRYCtrl:hly_add()
                +---[0.007652ms] data.common.util.StringUtils:IsNullOrEmpty() #183
                +---[0.011245ms] com.forestar.xht.util.Utils:getWorkSpace() #189
                +---[0.005283ms] com.forestar.xht.util.Utils:getMetadataWorkspace() #192
                +---[0.007431ms] data.metadata.IMetadataWorkspace:OpenTable() #95
                +---[0.007284ms] com.forestar.xht.util.Utils:getBaseDataService() #193
                +---[0.039893ms] com.alibaba.fastjson.JSONObject:parseObject() #196
                +---[0.005045ms] data.general.RowBase:<init>() #198
                +---[0.004925ms] data.general.RowBase:setCurrentObjects() #199
                +---[0.005901ms] com.forestar.core.session.SessionFactory:getSession() #201
                +---[0.008045ms] com.forestar.core.session.ISession:getTableSuffix() #95
                +---[0.00491ms] data.general.RowBase:getCurrentObjects() #202
                +---[0.005447ms] com.forestar.syscore.encrypt.MD5:<init>() #203
                +---[0.004425ms] data.general.RowBase:getCurrentObjects() #204
                +---[0.017348ms] com.forestar.syscore.encrypt.MD5:getMD5() #95
                +---[0.004585ms] data.general.RowBase:getCurrentObjects() #206
                +---[0.004571ms] data.general.QueryFilter:<init>() #207
                +---[0.004564ms] data.general.QueryFilter:setWhereString() #208
                `---[0.431266ms] com.forestar.redis.RedisDistributedLock:tryGetDistributedLockByBlocking() #215

ttStatic method field value call

Get the static fields of the class and call the static methods of the class: https://arthas.aliyun.com/doc/tt.html

monitor method execution time

Connect arthas through a browser

Arthas currently supports Web Console. After successfully attaching, users can directly visit: http://127.0.0.1:3658/ .

You can fill in the IP to connect to arthas on other machines remotely.

_images/web-console-local.png

By default, arthas only listens to 127.0.0.1, so if you want to connect remotely, you can use the --target-ipparameter to specify the IP of the listener  , and refer to -hthe help instructions for more. Note that there will be security risks, consider the following tunnel server solution.

 

Guess you like

Origin blog.csdn.net/boonya/article/details/114314081