mirror of https://github.com/alibaba/arthas.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
127 lines
7.3 KiB
Markdown
127 lines
7.3 KiB
Markdown
3 years ago
|
# monitor
|
||
7 years ago
|
|
||
5 years ago
|
[`monitor` online tutorial](https://arthas.aliyun.com/doc/arthas-tutorials.html?language=en&id=command-monitor)
|
||
5 years ago
|
|
||
3 years ago
|
::: tip
|
||
|
Monitor method invocation.
|
||
|
:::
|
||
7 years ago
|
|
||
5 years ago
|
Monitor invocation for the method matched with `class-pattern` and `method-pattern` and filter by `condition-expression`.
|
||
7 years ago
|
|
||
6 years ago
|
`monitor` is not a command returning immediately.
|
||
7 years ago
|
|
||
6 years ago
|
A command returning immediately is a command immediately returns with the result after the command is input, while a non-immediate returning command will keep outputting the information from the target JVM process until user presses `Ctrl+C`.
|
||
7 years ago
|
|
||
6 years ago
|
On Arthas's server side, the command is running as a background job, but the weaved code will not take further effect once the job is terminated, therefore, it will not impact the performance after the job quits. Furthermore, Arthas is designed to have no side effect to the business logic.
|
||
|
|
||
|
### Items to monitor
|
||
|
|
||
3 years ago
|
| Item | Specification |
|
||
|
| --------: | :--------------------------------------- |
|
||
|
| timestamp | timestamp |
|
||
|
| class | Java class |
|
||
|
| method | method (constructor and regular methods) |
|
||
|
| total | calling times |
|
||
|
| success | success count |
|
||
|
| fail | failure count |
|
||
|
| rt | average RT |
|
||
|
| fail-rate | failure ratio |
|
||
7 years ago
|
|
||
|
### Parameters
|
||
|
|
||
6 years ago
|
Parameter `[c:]` stands for cycles of statistics. Its value is an integer value in seconds.
|
||
|
|
||
3 years ago
|
| Name | Specification |
|
||
|
| ---------------------: | :------------------------------------------------------------ |
|
||
|
| _class-pattern_ | pattern for the class name |
|
||
|
| _method-pattern_ | pattern for the method name |
|
||
|
| _condition-expression_ | condition expression for filtering method calls |
|
||
|
| `[E]` | turn on regex matching while the default is wildcard matching |
|
||
|
| `[c:]` | cycle of statistics, the default value: `120`s |
|
||
|
| `[b]` | evaluate the condition-expression before method invoke |
|
||
7 years ago
|
|
||
|
### Usage
|
||
|
|
||
6 years ago
|
```bash
|
||
|
$ monitor -c 5 demo.MathGame primeFactors
|
||
7 years ago
|
Press Ctrl+C to abort.
|
||
6 years ago
|
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%
|
||
7 years ago
|
```
|
||
5 years ago
|
|
||
|
#### Evaluate condition-express to filter method (after method call)
|
||
|
|
||
|
```bash
|
||
|
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
|
||
3 years ago
|
timestamp class method total success fail avg-rt(ms) fail-rate
|
||
5 years ago
|
-----------------------------------------------------------------------------------------------
|
||
3 years ago
|
2020-09-02 09:42:36 demo.MathGame primeFactors 5 3 2 0.09 40.00%
|
||
5 years ago
|
|
||
3 years ago
|
timestamp class method total success fail avg-rt(ms) fail-rate
|
||
5 years ago
|
----------------------------------------------------------------------------------------------
|
||
3 years ago
|
2020-09-02 09:42:41 demo.MathGame primeFactors 5 2 3 0.11 60.00%
|
||
5 years ago
|
|
||
3 years ago
|
timestamp class method total success fail avg-rt(ms) fail-rate
|
||
5 years ago
|
----------------------------------------------------------------------------------------------
|
||
3 years ago
|
2020-09-02 09:42:46 demo.MathGame primeFactors 5 1 4 0.06 80.00%
|
||
5 years ago
|
|
||
3 years ago
|
timestamp class method total success fail avg-rt(ms) fail-rate
|
||
5 years ago
|
----------------------------------------------------------------------------------------------
|
||
3 years ago
|
2020-09-02 09:42:51 demo.MathGame primeFactors 5 1 4 0.12 80.00%
|
||
5 years ago
|
|
||
3 years ago
|
timestamp class method total success fail avg-rt(ms) fail-rate
|
||
5 years ago
|
----------------------------------------------------------------------------------------------
|
||
3 years ago
|
2020-09-02 09:42:56 demo.MathGame primeFactors 5 3 2 0.15 40.00%
|
||
5 years ago
|
```
|
||
|
|
||
|
#### Evaluate condition-express to filter method (before method call)
|
||
|
|
||
|
```bash
|
||
|
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
|
||
3 years ago
|
timestamp class method total success fail avg-rt(ms) fail-rate
|
||
5 years ago
|
----------------------------------------------------------------------------------------------
|
||
3 years ago
|
2020-09-02 09:41:57 demo.MathGame primeFactors 1 0 1 0.10 100.00%
|
||
5 years ago
|
|
||
3 years ago
|
timestamp class method total success fail avg-rt(ms) fail-rate
|
||
5 years ago
|
----------------------------------------------------------------------------------------------
|
||
3 years ago
|
2020-09-02 09:42:02 demo.MathGame primeFactors 3 0 3 0.06 100.00%
|
||
5 years ago
|
|
||
3 years ago
|
timestamp class method total success fail avg-rt(ms) fail-rate
|
||
5 years ago
|
----------------------------------------------------------------------------------------------
|
||
3 years ago
|
2020-09-02 09:42:07 demo.MathGame primeFactors 2 0 2 0.06 100.00%
|
||
5 years ago
|
|
||
3 years ago
|
timestamp class method total success fail avg-rt(ms) fail-rate
|
||
5 years ago
|
----------------------------------------------------------------------------------------------
|
||
3 years ago
|
2020-09-02 09:42:12 demo.MathGame primeFactors 1 0 1 0.05 100.00%
|
||
5 years ago
|
|
||
3 years ago
|
timestamp class method total success fail avg-rt(ms) fail-rate
|
||
5 years ago
|
----------------------------------------------------------------------------------------------
|
||
3 years ago
|
2020-09-02 09:42:17 demo.MathGame primeFactors 2 0 2 0.10 100.00%
|
||
5 years ago
|
```
|