• Arthas-monitor命令监控方法调用次数、成功次数、失败次数、平局响应时间和失败率


    monitor 命令是一个非实时返回命令.

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

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

    监控的维度说明

    监控项说明
    timestamp时间戳
    classJava 类
    method方法(构造方法、普通方法)
    total调用次数
    success成功次数
    fail失败次数
    rt平均 RT
    fail-rate失败率

    参数说明

    方法拥有一个命名参数 [c:],意思是统计周期(cycle of output),拥有一个整型的参数值

    参数名称参数说明
    class-pattern类名表达式匹配
    method-pattern方法名表达式匹配
    condition-express条件表达式
    [E]开启正则表达式匹配,默认为通配符匹配
    [c:]统计周期,默认值为 120 秒
    [b]在方法调用之前计算 condition-express

    使用参考

    $ monitor -c 5 demo.MathGame primeFactors
    Press Ctrl+C to abort.
    Affect(class-cnt:1 , method-cnt:1) cost in 94 ms.
     timestamp            class          method        total  success  fail  avg-rt(ms)  fail-rate
    -----------------------------------------------------------------------------------------------
     2018-12-03 19:06:38  demo.MathGame  primeFactors  5      1        4     1.15        80.00%
    
     timestamp            class          method        total  success  fail  avg-rt(ms)  fail-rate
    -----------------------------------------------------------------------------------------------
     2018-12-03 19:06:43  demo.MathGame  primeFactors  5      3        2     42.29       40.00%
    
     timestamp            class          method        total  success  fail  avg-rt(ms)  fail-rate
    -----------------------------------------------------------------------------------------------
     2018-12-03 19:06:48  demo.MathGame  primeFactors  5      3        2     67.92       40.00%
    
     timestamp            class          method        total  success  fail  avg-rt(ms)  fail-rate
    -----------------------------------------------------------------------------------------------
     2018-12-03 19:06:53  demo.MathGame  primeFactors  5      2        3     0.25        60.00%
    
     timestamp            class          method        total  success  fail  avg-rt(ms)  fail-rate
    -----------------------------------------------------------------------------------------------
     2018-12-03 19:06:58  demo.MathGame  primeFactors  1      1        0     0.45        0.00%
    
     timestamp            class          method        total  success  fail  avg-rt(ms)  fail-rate
    -----------------------------------------------------------------------------------------------
     2018-12-03 19:07:03  demo.MathGame  primeFactors  2      2        0     3182.72     0.00%
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    计算条件表达式过滤统计结果(方法执行完毕之后)
    monitor -c 5 demo.MathGame primeFactors "params[0] <= 2"
    Press Q or Ctrl+C to abort.
    Affect(class count: 1 , method count: 1) cost in 19 ms, listenerId: 5
     timestamp            class          method         total  success  fail  avg-rt(ms)  fail-rate
    -----------------------------------------------------------------------------------------------
     2020-09-02 09:42:36  demo.MathGame  primeFactors    5       3       2      0.09       40.00%
    
     timestamp            class          method         total  success  fail  avg-rt(ms)  fail-rate
    ----------------------------------------------------------------------------------------------
     2020-09-02 09:42:41  demo.MathGame  primeFactors    5       2       3      0.11       60.00%
    
     timestamp            class          method         total  success  fail  avg-rt(ms)  fail-rate
    ----------------------------------------------------------------------------------------------
     2020-09-02 09:42:46  demo.MathGame  primeFactors    5       1       4      0.06       80.00%
    
     timestamp            class          method         total  success  fail  avg-rt(ms)  fail-rate
    ----------------------------------------------------------------------------------------------
     2020-09-02 09:42:51  demo.MathGame  primeFactors    5       1       4      0.12       80.00%
    
     timestamp            class          method         total  success  fail  avg-rt(ms)  fail-rate
    ----------------------------------------------------------------------------------------------
     2020-09-02 09:42:56  demo.MathGame  primeFactors    5       3       2      0.15       40.00%
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    计算条件表达式过滤统计结果(方法执行完毕之前)

    monitor -b -c 5 com.test.testes.MathGame primeFactors "params[0] <= 2"
    Press Q or Ctrl+C to abort.
    Affect(class count: 1 , method count: 1) cost in 21 ms, listenerId: 4
     timestamp            class          method         total  success  fail  avg-rt(ms)  fail-rate
    ----------------------------------------------------------------------------------------------
     2020-09-02 09:41:57  demo.MathGame  primeFactors    1       0        1      0.10      100.00%
    
     timestamp            class          method         total  success  fail  avg-rt(ms)  fail-rate
    ----------------------------------------------------------------------------------------------
     2020-09-02 09:42:02  demo.MathGame  primeFactors    3       0        3      0.06      100.00%
    
     timestamp            class          method         total  success  fail  avg-rt(ms)  fail-rate
    ----------------------------------------------------------------------------------------------
     2020-09-02 09:42:07  demo.MathGame  primeFactors    2       0        2      0.06      100.00%
    
     timestamp            class          method         total  success  fail  avg-rt(ms)  fail-rate
    ----------------------------------------------------------------------------------------------
     2020-09-02 09:42:12  demo.MathGame  primeFactors    1       0        1      0.05      100.00%
    
     timestamp            class          method         total  success  fail  avg-rt(ms)  fail-rate
    ----------------------------------------------------------------------------------------------
     2020-09-02 09:42:17  demo.MathGame  primeFactors    2       0        2      0.10      100.00%
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
  • 相关阅读:
    Unity | Cinemachine 2D 设置边界及错误记录
    <leetcode>35.搜索插入位置——二分法
    uniapp中swiper 轮播带左右箭头,点击切换轮播效果demo(整理)
    软件测试(测试用例)编写之俗手、本手、妙手
    Java IO 面试详解
    一招解决MySql Specified key was too long; max key length is 767 bytes
    kafka基础-什么是kafka以及kafka中的一些基本概念
    【论文阅读】基于隐蔽带宽的汽车控制网络鲁棒认证(二)
    [4.9]-AutoSAR零基础学习-(SHE)Secure Hardware Extension规范<1>
    2023考研重要时间节点大致梳理规划
  • 原文地址:https://blog.csdn.net/qq_37279783/article/details/128068556