Java OpenResty Spring Spring Boot MySQL Redis MongoDB PostgreSQL Linux Android Nginx 面试 小程序 Arthas JVM AQS juc Kubernetes Docker 诊断工具


Arthas 使用 monitor 在指定时间段内统计方法的调用次数、平均返回时间等

Arthas Java 诊断工具 大约 2092 字

monitor 命令

-c:指定时间段,默认120秒。

-c 10表示统计在指定的10秒内,方法执行了多少次、平均返回时间等信息。

monitor com.example.arthas.controller.Test111Controller test1 -c 10

输出:

[arthas@21776]$ monitor com.example.arthas.controller.Test111Controller test1 -c 10
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 37 ms, listenerId: 38
 timestamp                 class                                 method                                 total        success     fail         avg-rt(ms)   fail-rate
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 2021-02-12 20:21:12       com.example.arthas.controller.Test11  test1                                  18           18          0            0.39         0.00%
                           1Controller

 timestamp                 class                                 method                                 total        success     fail         avg-rt(ms)   fail-rate
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 2021-02-12 20:21:22       com.example.arthas.controller.Test11  test1                                  0            0           0            0.00         0.00%
                           1Controller

 timestamp                 class                                 method                                 total        success     fail         avg-rt(ms)   fail-rate
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 2021-02-12 20:21:32       com.example.arthas.controller.Test11  test1                                  0            0           0            0.00         0.00%
                           1Controller

更多用法

10秒内统计,第一个参数传入方法时小于等于2的情况。

monitor com.example.arthas.controller.Test111Controller test1 "params[0] <= 2" -c 10 -b

参考

https://arthas.aliyun.com/doc/monitor.html

阅读 4567 · 发布于 2021-04-27

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb

扫描下方二维码关注公众号和小程序↓↓↓

扫描二维码关注我
昵称:
随便看看 换一批