arthas教程4

2019-10-25 09:33:02 浏览数 (2)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/weixin_39800144/article/details/100526338

本文介绍:monitor的使用。

8.monitor

monitor可以对匹配的目标类或者目标方法进行持续监控,直到用户中止为止。monitor 命令是一个非实时返回命令.

实时返回命令是输入之后立即返回,而非实时返回的命令,则是不断的等待目标 Java 进程返回信息,直到用户输入 Ctrl C 为止。

服务端是以任务的形式在后台跑任务,植入的代码随着任务的中止而不会被执行,所以任务关闭后,不会对原有性能产生太大影响,而且原则上,任何Arthas命令不会引起原有业务逻辑的改变。

monitor命令有一个参数c,是统计周期,值是个整数类型,就是每间隔几秒统计一次的意思。

我们这里做个测试,每间隔2秒对com.runlion.fsp.credit.service.impl.CreditServiceImpl 的listCreditAndUserOnCondition方法进行一次监控:

代码语言:javascript复制
$ monitor -c 2 com.runlion.fsp.credit.service.impl.CreditServiceImpl listCreditAndUserOnCondition

注意,第一次触发监控需要手动的触发一下,之后会按照指定周期,直到ctrl c退出。

代码语言:javascript复制
$ monitor -c 2 com.runlion.fsp.credit.service.impl.CreditServiceImpl listCreditAndUserOnCondition
Press Q or Ctrl C to abort.
Affect(class-cnt:2 , method-cnt:2) cost in 201 ms.
 timestamp            class                                                                                   method                        total  success  fail  avg-rt(ms)  fail-rate   
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
 2019-09-03 20:00:58  com.runlion.fsp.credit.service.impl.CreditServiceImpl$$EnhancerBySpringCGLIB$$9fa88222  listCreditAndUserOnCondition  1      1        0     322.64      0.00%       
 2019-09-03 20:00:58  com.runlion.fsp.credit.service.impl.CreditServiceImpl                                   listCreditAndUserOnCondition  1      1        0     322.57      0.00%       

 timestamp            class                                                                                   method                        total  success  fail  avg-rt(ms)  fail-rate   
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
 2019-09-03 20:01:00  com.runlion.fsp.credit.service.impl.CreditServiceImpl$$EnhancerBySpringCGLIB$$9fa88222  listCreditAndUserOnCondition  0      0        0     0.00        0.00%       
 2019-09-03 20:01:00  com.runlion.fsp.credit.service.impl.CreditServiceImpl                                   listCreditAndUserOnCondition  0      0        0     0.00        0.00%       

 timestamp            class                                                                                   method                        total  success  fail  avg-rt(ms)  fail-rate   
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
 2019-09-03 20:01:02  com.runlion.fsp.credit.service.impl.CreditServiceImpl$$EnhancerBySpringCGLIB$$9fa88222  listCreditAndUserOnCondition  0      0        0     0.00        0.00%       
 2019-09-03 20:01:02  com.runlion.fsp.credit.service.impl.CreditServiceImpl                                   listCreditAndUserOnCondition  0      0        0     0.00        0.00%       

 timestamp            class                                                                                   method                        total  success  fail  avg-rt(ms)  fail-rate   
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
 2019-09-03 20:01:04  com.runlion.fsp.credit.service.impl.CreditServiceImpl$$EnhancerBySpringCGLIB$$9fa88222  listCreditAndUserOnCondition  0      0        0     0.00        0.00%       
 2019-09-03 20:01:04  com.runlion.fsp.credit.service.impl.CreditServiceImpl                                   listCreditAndUserOnCondition  0      0        0     0.00        0.00% 

监控维度说明:

0 人点赞