mirror of
https://github.com/alibaba/arthas.git
synced 2026-11-12 22:41:26 +00:00
update doc
This commit is contained in:
1 parent
30b2a190c6
commit
da5f4a397d
35 files changed
+417
-45
No files matched your search
@@ -26,9 +26,9 @@ http api.
|
||||
```json
|
||||
{
|
||||
"action": "exec",
|
||||
"requestId": "req112"
|
||||
"sessionId": "94766d3c-8b39-42d3-8596-98aee3ccbefb"
|
||||
"consumerId": "955dbd1325334a84972b0f3ac19de4f7_2"
|
||||
"requestId": "req112",
|
||||
"sessionId": "94766d3c-8b39-42d3-8596-98aee3ccbefb",
|
||||
"consumerId": "955dbd1325334a84972b0f3ac19de4f7_2",
|
||||
"command": "version",
|
||||
"execTimeout": "10000"
|
||||
}
|
||||
@@ -614,7 +614,48 @@ receive this `enhancer` result. It may happen that the result of
|
||||
`enhancer` is successful, but there is no hit method. The client can
|
||||
prompt the user according to the result of `enhancer`.
|
||||
|
||||
### Others
|
||||
### Cases
|
||||
|
||||
#### Get classpath of Java application
|
||||
|
||||
Get system properties of the Java application through Http api and
|
||||
extract the value of `java.class.path`.
|
||||
|
||||
```bash
|
||||
json_data=$(curl -Ss -XPOST http://localhost:8563/api -d '
|
||||
{
|
||||
"action":"exec",
|
||||
"command":"sysprop"
|
||||
}')
|
||||
```
|
||||
|
||||
* Extract value with `sed`:
|
||||
|
||||
```bash
|
||||
class_path=$(echo $json_data | tr -d '\n' | sed 's/.*"java.class.path":"\([^"]*\).*/\1/')
|
||||
echo "classpath: $class_path"
|
||||
```
|
||||
|
||||
* Extract value with `json_pp/awk`:
|
||||
|
||||
```bash
|
||||
class_path=$(echo $json_data | tr -d '\n' | json_pp | grep java.class.path | awk -F'"' '{ print $4 }')
|
||||
echo "classpath: $class_path"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```
|
||||
classpath: demo-arthas-spring-boot.jar
|
||||
```
|
||||
|
||||
NOTE:
|
||||
|
||||
* `echo $json_data | tr -d '\n'` : Delete line breaks (the value of
|
||||
`line.separator`) to avoid affecting the processing of `sed`/`json_pp`
|
||||
commands.
|
||||
* `awk -F'"' '{ print $4 }'` : Use double quote as delimiter
|
||||
|
||||
|
||||
<a id="change_watch_value_to_map"></a>
|
||||
#### Make watch command output a map object
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
jad
|
||||
===
|
||||
|
||||
[`jad` online tutorial](https://arthas.aliyun.com/doc/arthas-tutorials?language=en&id=command-jad)
|
||||
|
||||
> Decompile the specified classes.
|
||||
|
||||
`jad` helps to decompile the byte code running in JVM to the source code to assist you to understand the logic behind better.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
logger
|
||||
===
|
||||
|
||||
[`logger` online tutorial](https://arthas.aliyun.com/doc/arthas-tutorials?language=en&id=command-logger)
|
||||
|
||||
> Print the logger information, update the logger level
|
||||
|
||||
### Usage
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
mc
|
||||
===
|
||||
|
||||
[`mc-redefine` online tutorial](https://arthas.aliyun.com/doc/arthas-tutorials?language=en&id=command-mc-redefine)
|
||||
|
||||
> Memory compiler, compiles `.java` files into `.class` files in memory.
|
||||
|
||||
```bash
|
||||
|
||||
@@ -1,12 +1,25 @@
|
||||
profiler
|
||||
===
|
||||
|
||||
[`profiler` online tutorial](https://arthas.aliyun.com/doc/arthas-tutorials.html?language=en&id=command-profiler)
|
||||
|
||||
> Generate a flame graph using [async-profiler](https://github.com/jvm-profiling-tools/async-profiler)
|
||||
|
||||
The `profiler` command supports generate flame graph for application hotspots.
|
||||
|
||||
The basic usage of the `profiler` command is `profiler action [actionArg]`
|
||||
|
||||
### Supported Options
|
||||
|
||||
|Name|Specification|
|
||||
|---:|:---|
|
||||
|*action*|Action to execute|
|
||||
|*actionArg*|Attribute name pattern|
|
||||
|[i:]|sampling interval in ns (default: 10'000'000, i.e. 10 ms)|
|
||||
|[f:]|dump output to specified directory|
|
||||
|[d:]|run profiling for specified seconds|
|
||||
|[e:]|which event to trace (cpu, alloc, lock, cache-misses etc.), default value is cpu|
|
||||
|
||||
### Start profiler
|
||||
|
||||
```
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
redefine
|
||||
========
|
||||
|
||||
[`mc-redefine` online tutorial](https://arthas.aliyun.com/doc/arthas-tutorials?language=en&id=command-mc-redefine)
|
||||
|
||||
> Load the external `*.class` files to re-define the loaded classes in JVM.
|
||||
|
||||
Reference: [Instrumentation#redefineClasses](https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html#redefineClasses-java.lang.instrument.ClassDefinition...-)
|
||||
|
||||
### Frequently asked questions
|
||||
|
||||
* The class of `redefine` cannot modify, add or delete the field and method of the class, including method parameters, method names and return values.
|
||||
|
||||
* If `mc` fails, you can compile the class file in the local development environment, upload it to the target system, and use `redefine` to hot load the class.
|
||||
|
||||
* At present, `redefine` conflicts with `watch / trace / jad / tt` commands. Reimplementing `redefine` function in the future will solve this problem.
|
||||
|
||||
> Notes: Re-defined classes cannot be restored. There are chances that redefining may fail due to some reasons, for example: there's new field introduced in the new version of the class, pls. refer to JDK's documentation for the limitations.
|
||||
|
||||
> The `reset` command is not valid for classes that have been processed by `redefine`. If you want to reset, you need `redefine` the original bytecode.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
sc
|
||||
==
|
||||
|
||||
[`sc` online tutorial](https://arthas.aliyun.com/doc/arthas-tutorials?language=en&id=command-sc)
|
||||
|
||||
> Search classes loaded by JVM.
|
||||
|
||||
`sc` stands for search class. This command can search all possible classes loaded by JVM and show their information. The supported options are: `[d]`、`[E]`、`[f]` and `[x:]`.
|
||||
@@ -15,6 +17,8 @@ sc
|
||||
|`[E]`|turn on regex match, the default behavior is wildcards match|
|
||||
|`[f]`|print the fields info of the current class, MUST be used with `-d` together|
|
||||
|`[x:]`|specify the depth of recursive traverse the static fields, the default value is '0' - equivalent to use `toString` to output|
|
||||
|`[c:]`|The hash code of the special class's classLoader|
|
||||
|`[n:]`|Maximum number of matching classes with details (100 by default)|
|
||||
|
||||
> *class-patten* supports full qualified class name, e.g. com.taobao.test.AAA and com/taobao/test/AAA. It also supports the format of 'com/taobao/test/AAA', so that it is convenient to directly copy class name from the exception stack trace without replacing '/' to '.'. <br/><br/>
|
||||
> `sc` turns on matching sub-class match by default, that is, `sc` will also search the sub classes of the target class too. If exact-match is desired, pls. use `options disable-sub-class true`.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
sm
|
||||
==
|
||||
|
||||
[`sm` online tutorial](https://arthas.aliyun.com/doc/arthas-tutorials?language=en&id=command-sm)
|
||||
|
||||
> Search method from the loaded classes.
|
||||
|
||||
`sm` stands for search method. This command can search and show method information from all loaded classes. `sm` can only view the methods declared on the target class, that is, methods from its parent classes are invisible.
|
||||
@@ -14,6 +16,8 @@ sm
|
||||
|*method-pattern*|pattern for method name|
|
||||
|`[d]`|print the details of the method|
|
||||
|`[E]`|turn on regex matching while the default mode is wildcard matching|
|
||||
|`[c:]`|The hash code of the special class's classLoader|
|
||||
|`[n:]`|Maximum number of matching classes with details (100 by default)|
|
||||
|
||||
### Usage
|
||||
|
||||
|
||||
Reference in new issue
Block a user