monitor
方法执行监控,固定周期内统计方法调用次数、成功次数、失败次数、平均响应时间、失败率等
命令选项
命令选项 | 描述 |
---|---|
-b, --before | 在方法执行之前执行ognl条件表达式 |
-c, --cycle <number> | 监控周期(秒),默认60 |
--exclude-class-pattern <pattern> | 排除class模式 |
-n, --limits <number> | 监控执行次数 |
--listenerId <id> | 特殊的监控id |
-E, --regex | 开启正则匹配,默认为通配符匹配 |
-v, --verbose | 打印debug信息 |
-h, --help | 帮助 |
<class-pattern> | 类匹配模式 |
<method-pattern> | 方法匹配模式 |
<condition-express> | ognl条件表达式 |
示例
bash
# 每5秒统计一次primeFactors方法执行
[arthas@13728]$ monitor -c 5 demo.MathGame primeFactors
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 25 ms, listenerId: 22
timestamp class method total success fail avg-rt(ms) fail-rate
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-03-30 15:54:44 demo.MathGame primeFactors 5 2 3 0.14 60.00%
timestamp class method total success fail avg-rt(ms) fail-rate
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-03-30 15:54:49 demo.MathGame primeFactors 5 3 2 0.12 40.00%
timestamp class method total success fail avg-rt(ms) fail-rate
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-03-30 15:54:54 demo.MathGame primeFactors 5 4 1 0.13 20.00%
timestamp class method total success fail avg-rt(ms) fail-rate
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-03-30 15:54:59 demo.MathGame primeFactors 5 2 3 0.05 60.00%
# ognl表达式过滤结果(方法执行之后)
[arthas@13728]$ 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 25 ms, listenerId: 23
timestamp class method total success fail avg-rt(ms) fail-rate
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-03-30 15:56:03 demo.MathGame primeFactors 5 3 2 0.53 40.00%
timestamp class method total success fail avg-rt(ms) fail-rate
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-03-30 15:56:08 demo.MathGame primeFactors 5 1 4 0.04 80.00%
timestamp class method total success fail avg-rt(ms) fail-rate
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-03-30 15:56:13 demo.MathGame primeFactors 5 3 2 0.12 40.00%
timestamp class method total success fail avg-rt(ms) fail-rate
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-03-30 15:56:18 demo.MathGame primeFactors 5 2 3 0.06 60.00%
# ognl表达式过滤结果(方法执行之前)
[arthas@2200]$ monitor -bc 5 demo.MathGame primeFactors "params[0] <= 2"
Press Q or Ctrl+C to abort.
Affect(class count: 1 , method count: 1) cost in 62 ms, listenerId: 1
timestamp class method total success fail avg-rt(ms) fail-rate
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-03-30 15:57:53 demo.MathGame primeFactors 3 0 3 0.03 100.00%
timestamp class method total success fail avg-rt(ms) fail-rate
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-03-30 15:57:59 demo.MathGame primeFactors 2 0 2 0.02 100.00%
timestamp class method total success fail avg-rt(ms) fail-rate
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-03-30 15:58:05 demo.MathGame primeFactors 2 0 2 0.04 100.00%
timestamp class method total success fail avg-rt(ms) fail-rate
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2023-03-30 15:58:09 demo.MathGame primeFactors 3 0 3 0.01 100.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59