mirror of
https://github.com/alibaba/arthas.git
synced 2024-04-21 10:21:39 +00:00
update doc
This commit is contained in:
@@ -20,9 +20,9 @@ Http API接口地址为:`http://ip:port/api`,必须使用POST方式提交请
|
||||
```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"
|
||||
}
|
||||
@@ -537,7 +537,47 @@ curl -Ss -XPOST http://localhost:8563/api -d '''
|
||||
|
||||
`trace/watch/jad/tt`等命令需要对类进行增强,会接收到这个`enhancer`结果。可能出现`enhancer`结果成功,但没有命中方法的情况,客户端可以根据`enhancer`结果提示用户。
|
||||
|
||||
### 其它
|
||||
### 案例
|
||||
|
||||
#### 获取Java应用的Classpath
|
||||
|
||||
通过Http api查询Java应用的System properties,提取`java.class.path`的值。
|
||||
|
||||
|
||||
```bash
|
||||
json_data=$(curl -Ss -XPOST http://localhost:8563/api -d '
|
||||
{
|
||||
"action":"exec",
|
||||
"command":"sysprop"
|
||||
}')
|
||||
```
|
||||
|
||||
* 使用`sed`提取值:
|
||||
|
||||
```bash
|
||||
class_path=$(echo $json_data | tr -d '\n' | sed 's/.*"java.class.path":"\([^"]*\).*/\1/')
|
||||
echo "classpath: $class_path"
|
||||
```
|
||||
|
||||
* 使用`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"
|
||||
```
|
||||
|
||||
输出内容:
|
||||
|
||||
```
|
||||
classpath: demo-arthas-spring-boot.jar
|
||||
```
|
||||
|
||||
注意:
|
||||
|
||||
* `echo $json_data | tr -d '\n'` : 删除换行符(`line.separator`的值),避免影响`sed`/`json_pp`命令处理。
|
||||
* `awk -F'"' '{ print $4 }'` : 使用双引号作为分隔符号
|
||||
|
||||
|
||||
|
||||
<a id="change_watch_value_to_map"></a>
|
||||
#### watch命令输出map对象
|
||||
@@ -629,4 +669,6 @@ Http api 执行结果:
|
||||
}
|
||||
```
|
||||
|
||||
可以看到watch结果的value变成map对象,程序可以通过key读取结果。
|
||||
可以看到watch结果的value变成map对象,程序可以通过key读取结果。
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
jad
|
||||
===
|
||||
|
||||
[`jad`在线教程](https://arthas.aliyun.com/doc/arthas-tutorials?language=cn&id=command-jad)
|
||||
|
||||
> 反编译指定已加载类的源码
|
||||
|
||||
`jad` 命令将 JVM 中实际运行的 class 的 byte code 反编译成 java 代码,便于你理解业务逻辑;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
logger
|
||||
===
|
||||
|
||||
[`logger`在线教程](https://arthas.aliyun.com/doc/arthas-tutorials?language=cn&id=command-logger)
|
||||
|
||||
> 查看logger信息,更新logger level
|
||||
|
||||
### 使用参考
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
mc
|
||||
===
|
||||
|
||||
[`mc-redefine`在线教程](https://arthas.aliyun.com/doc/arthas-tutorials?language=cn&id=command-mc-redefine)
|
||||
|
||||
> Memory Compiler/内存编译器,编译`.java`文件生成`.class`。
|
||||
|
||||
```bash
|
||||
|
||||
@@ -1,12 +1,25 @@
|
||||
profiler
|
||||
===
|
||||
|
||||
[`profiler`在线教程](https://arthas.aliyun.com/doc/arthas-tutorials.html?language=cn&id=command-profiler)
|
||||
|
||||
> 使用[async-profiler](https://github.com/jvm-profiling-tools/async-profiler)生成火焰图
|
||||
|
||||
`profiler` 命令支持生成应用热点的火焰图。本质上是通过不断的采样,然后把收集到的采样结果生成火焰图。
|
||||
|
||||
`profiler` 命令基本运行结构是 `profiler action [actionArg]`
|
||||
|
||||
### 参数说明
|
||||
|
||||
|参数名称|参数说明|
|
||||
|---:|:---|
|
||||
|*action*|要执行的操作|
|
||||
|*actionArg*|属性名模式|
|
||||
|[i:]|采样间隔(单位:ns)(默认值:10'000'000,即10 ms)|
|
||||
|[f:]|将输出转储到指定路径|
|
||||
|[d:]|运行评测指定秒|
|
||||
|[e:]|要跟踪哪个事件(cpu, alloc, lock, cache-misses等),默认是cpu|
|
||||
|
||||
### 启动profiler
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
redefine
|
||||
===
|
||||
|
||||
[`mc-redefine`在线教程](https://arthas.aliyun.com/doc/arthas-tutorials?language=cn&id=command-mc-redefine)
|
||||
|
||||
> 加载外部的`.class`文件,redefine jvm已加载的类。
|
||||
|
||||
参考:[Instrumentation#redefineClasses](https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html#redefineClasses-java.lang.instrument.ClassDefinition...-)
|
||||
|
||||
### 常见问题
|
||||
|
||||
* redefine的class不能修改、添加、删除类的field和method,包括方法参数、方法名称及返回值
|
||||
|
||||
* 如果mc失败,可以在本地开发环境编译好class文件,上传到目标系统,使用redefine热加载class
|
||||
|
||||
* 目前redefine 和watch/trace/jad/tt等命令冲突,以后重新实现redefine功能会解决此问题
|
||||
|
||||
> 注意, redefine后的原来的类不能恢复,redefine有可能失败(比如增加了新的field),参考jdk本身的文档。
|
||||
|
||||
> `reset`命令对`redefine`的类无效。如果想重置,需要`redefine`原始的字节码。
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
sc
|
||||
===
|
||||
|
||||
[`sc`在线教程](https://arthas.aliyun.com/doc/arthas-tutorials?language=cn&id=command-sc)
|
||||
|
||||
> 查看JVM已加载的类信息
|
||||
|
||||
“Search-Class” 的简写,这个命令能搜索出所有已经加载到 JVM 中的 Class 信息,这个命令支持的参数有 `[d]`、`[E]`、`[f]` 和 `[x:]`。
|
||||
@@ -18,6 +20,8 @@ sc
|
||||
|[E]|开启正则表达式匹配,默认为通配符匹配|
|
||||
|[f]|输出当前类的成员变量信息(需要配合参数-d一起使用)|
|
||||
|[x:]|指定输出静态变量时属性的遍历深度,默认为 0,即直接使用 `toString` 输出|
|
||||
|`[c:]`|指定class的 ClassLoader 的 hashcode|
|
||||
|`[n:]`|具有详细信息的匹配类的最大数量(默认为100)|
|
||||
|
||||
> class-pattern支持全限定名,如com.taobao.test.AAA,也支持com/taobao/test/AAA这样的格式,这样,我们从异常堆栈里面把类名拷贝过来的时候,不需要在手动把`/`替换为`.`啦。
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
sm
|
||||
===
|
||||
|
||||
[`sm`在线教程](https://arthas.aliyun.com/doc/arthas-tutorials?language=cn&id=command-sm)
|
||||
|
||||
> 查看已加载类的方法信息
|
||||
|
||||
“Search-Method” 的简写,这个命令能搜索出所有已经加载了 Class 信息的方法信息。
|
||||
@@ -15,6 +17,8 @@ sm
|
||||
|*method-pattern*|方法名表达式匹配|
|
||||
|[d]|展示每个方法的详细信息|
|
||||
|[E]|开启正则表达式匹配,默认为通配符匹配|
|
||||
|`[c:]`|指定class的 ClassLoader 的 hashcode|
|
||||
|`[n:]`|具有详细信息的匹配类的最大数量(默认为100)|
|
||||
|
||||
### 使用参考
|
||||
|
||||
|
||||
@@ -689,6 +689,18 @@
|
||||
cn: "command-tt-cn",
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "command-profiler",
|
||||
type: "COMMAND-ENHANCED",
|
||||
names: {
|
||||
en: "profiler",
|
||||
cn: "profiler",
|
||||
},
|
||||
ids: {
|
||||
en: "command-profiler-en",
|
||||
cn: "command-profiler-cn",
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "case-web-console",
|
||||
type: "USERCASE",
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
+40
-6
@@ -126,7 +126,8 @@
|
||||
<li class="toctree-l3"><a class="reference internal" href="#enhancer">enhancer</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#others">Others</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#cases">Cases</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#get-classpath-of-java-application">Get classpath of Java application</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#make-watch-command-output-a-map-object">Make watch command output a map object</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -229,9 +230,9 @@ http api.</p>
|
||||
<h3>Request data format<a class="headerlink" href="#request-data-format" title="Permalink to this headline">¶</a></h3>
|
||||
<div class="highlight-json notranslate"><div class="highlight hljs"><pre class="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"
|
||||
}</pre></div>
|
||||
@@ -754,9 +755,42 @@ receive this <code class="docutils literal notranslate"><span class="pre">enhanc
|
||||
prompt the user according to the result of <code class="docutils literal notranslate"><span class="pre">enhancer</span></code>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="others">
|
||||
<h2>Others<a class="headerlink" href="#others" title="Permalink to this headline">¶</a></h2>
|
||||
<div class="section" id="cases">
|
||||
<h2>Cases<a class="headerlink" href="#cases" title="Permalink to this headline">¶</a></h2>
|
||||
<div class="section" id="get-classpath-of-java-application">
|
||||
<h3>Get classpath of Java application<a class="headerlink" href="#get-classpath-of-java-application" title="Permalink to this headline">¶</a></h3>
|
||||
<p>Get system properties of the Java application through Http api and
|
||||
extract the value of <code class="docutils literal notranslate"><span class="pre">java.class.path</span></code>.</p>
|
||||
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">json_data=$(curl -Ss -XPOST http://localhost:8563/api -d '
|
||||
{
|
||||
"action":"exec",
|
||||
"command":"sysprop"
|
||||
}')</pre></div>
|
||||
</div>
|
||||
<ul class="simple">
|
||||
<li><p>Extract value with <code class="docutils literal notranslate"><span class="pre">sed</span></code>:</p></li>
|
||||
</ul>
|
||||
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">class_path=$(echo $json_data | tr -d '\n' | sed 's/.*"java.class.path":"\([^"]*\).*/\1/')
|
||||
echo "classpath: $class_path"</pre></div>
|
||||
</div>
|
||||
<ul class="simple">
|
||||
<li><p>Extract value with <code class="docutils literal notranslate"><span class="pre">json_pp/awk</span></code>:</p></li>
|
||||
</ul>
|
||||
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">class_path=$(echo $json_data | tr -d '\n' | json_pp | grep java.class.path | awk -F'"' '{ print $4 }')
|
||||
echo "classpath: $class_path"</pre></div>
|
||||
</div>
|
||||
<p>Output:</p>
|
||||
<div class="highlight-default notranslate"><pre class="literal-block">classpath: demo-arthas-spring-boot.jar</pre>
|
||||
</div>
|
||||
<p>NOTE:</p>
|
||||
<ul class="simple">
|
||||
<li><p><code class="docutils literal notranslate"><span class="pre">echo</span> <span class="pre">$json_data</span> <span class="pre">|</span> <span class="pre">tr</span> <span class="pre">-d</span> <span class="pre">'\n'</span></code> : Delete line breaks (the value of
|
||||
<code class="docutils literal notranslate"><span class="pre">line.separator</span></code>) to avoid affecting the processing of <code class="docutils literal notranslate"><span class="pre">sed</span></code>/<code class="docutils literal notranslate"><span class="pre">json_pp</span></code>
|
||||
commands.</p></li>
|
||||
<li><p><code class="docutils literal notranslate"><span class="pre">awk</span> <span class="pre">-F'"'</span> <span class="pre">'{</span> <span class="pre">print</span> <span class="pre">$4</span> <span class="pre">}'</span></code> : Use double quote as delimiter</p></li>
|
||||
</ul>
|
||||
<p><a id="change_watch_value_to_map"></a></p>
|
||||
</div>
|
||||
<div class="section" id="make-watch-command-output-a-map-object">
|
||||
<h3>Make watch command output a map object<a class="headerlink" href="#make-watch-command-output-a-map-object" title="Permalink to this headline">¶</a></h3>
|
||||
<p>The result value of <code class="docutils literal notranslate"><span class="pre">watch</span></code> is generated by calculating the
|
||||
|
||||
@@ -224,6 +224,7 @@
|
||||
|
||||
<div class="section" id="jad">
|
||||
<h1>jad<a class="headerlink" href="#jad" title="Permalink to this headline">¶</a></h1>
|
||||
<p><a class="reference external" href="https://arthas.aliyun.com/doc/arthas-tutorials?language=en&id=command-jad"><code class="docutils literal notranslate"><span class="pre">jad</span></code> online tutorial</a></p>
|
||||
<blockquote>
|
||||
<div><p>Decompile the specified classes.</p>
|
||||
</div></blockquote>
|
||||
|
||||
@@ -225,6 +225,7 @@
|
||||
|
||||
<div class="section" id="logger">
|
||||
<h1>logger<a class="headerlink" href="#logger" title="Permalink to this headline">¶</a></h1>
|
||||
<p><a class="reference external" href="https://arthas.aliyun.com/doc/arthas-tutorials?language=en&id=command-logger"><code class="docutils literal notranslate"><span class="pre">logger</span></code> online tutorial</a></p>
|
||||
<blockquote>
|
||||
<div><p>Print the logger information, update the logger level</p>
|
||||
</div></blockquote>
|
||||
|
||||
@@ -214,6 +214,7 @@
|
||||
|
||||
<div class="section" id="mc">
|
||||
<h1>mc<a class="headerlink" href="#mc" title="Permalink to this headline">¶</a></h1>
|
||||
<p><a class="reference external" href="https://arthas.aliyun.com/doc/arthas-tutorials?language=en&id=command-mc-redefine"><code class="docutils literal notranslate"><span class="pre">mc-redefine</span></code> online tutorial</a></p>
|
||||
<blockquote>
|
||||
<div><p>Memory compiler, compiles <code class="docutils literal notranslate"><span class="pre">.java</span></code> files into <code class="docutils literal notranslate"><span class="pre">.class</span></code> files in memory.</p>
|
||||
</div></blockquote>
|
||||
|
||||
@@ -124,6 +124,7 @@
|
||||
<li class="toctree-l2"><a class="reference internal" href="stack.html">stack</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="tt.html">tt</a></li>
|
||||
<li class="toctree-l2 current"><a class="current reference internal" href="#">profiler</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#supported-options">Supported Options</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#start-profiler">Start profiler</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#get-the-number-of-samples-collected">Get the number of samples collected</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#view-profiler-status">View profiler status</a></li>
|
||||
@@ -230,11 +231,48 @@
|
||||
|
||||
<div class="section" id="profiler">
|
||||
<h1>profiler<a class="headerlink" href="#profiler" title="Permalink to this headline">¶</a></h1>
|
||||
<p><a class="reference external" href="https://arthas.aliyun.com/doc/arthas-tutorials.html?language=en&id=command-profiler"><code class="docutils literal notranslate"><span class="pre">profiler</span></code> online tutorial</a></p>
|
||||
<blockquote>
|
||||
<div><p>Generate a flame graph using <a class="reference external" href="https://github.com/jvm-profiling-tools/async-profiler">async-profiler</a></p>
|
||||
</div></blockquote>
|
||||
<p>The <code class="docutils literal notranslate"><span class="pre">profiler</span></code> command supports generate flame graph for application hotspots.</p>
|
||||
<p>The basic usage of the <code class="docutils literal notranslate"><span class="pre">profiler</span></code> command is <code class="docutils literal notranslate"><span class="pre">profiler</span> <span class="pre">action</span> <span class="pre">[actionArg]</span></code></p>
|
||||
<div class="section" id="supported-options">
|
||||
<h2>Supported Options<a class="headerlink" href="#supported-options" title="Permalink to this headline">¶</a></h2>
|
||||
<table border="1" class="docutils">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="right">Name</th>
|
||||
<th align="left">Specification</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="right"><em>action</em></td>
|
||||
<td align="left">Action to execute</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><em>actionArg</em></td>
|
||||
<td align="left">Attribute name pattern</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">[i:]</td>
|
||||
<td align="left">sampling interval in ns (default: 10'000'000, i.e. 10 ms)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">[f:]</td>
|
||||
<td align="left">dump output to specified directory</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">[d:]</td>
|
||||
<td align="left">run profiling for specified seconds</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">[e:]</td>
|
||||
<td align="left">which event to trace (cpu, alloc, lock, cache-misses etc.), default value is cpu</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<div class="section" id="start-profiler">
|
||||
<h2>Start profiler<a class="headerlink" href="#start-profiler" title="Permalink to this headline">¶</a></h2>
|
||||
<div class="highlight-default notranslate"><pre class="literal-block">$ profiler start
|
||||
|
||||
@@ -118,6 +118,7 @@
|
||||
<li class="toctree-l2"><a class="reference internal" href="classloader.html">classloader</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="mc.html">mc</a></li>
|
||||
<li class="toctree-l2 current"><a class="current reference internal" href="#">redefine</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#frequently-asked-questions">Frequently asked questions</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#options">Options</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#usage">Usage</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#use-with-the-jad-mc-command">Use with the jad/mc command</a></li>
|
||||
@@ -221,10 +222,18 @@
|
||||
|
||||
<div class="section" id="redefine">
|
||||
<h1>redefine<a class="headerlink" href="#redefine" title="Permalink to this headline">¶</a></h1>
|
||||
<p><a class="reference external" href="https://arthas.aliyun.com/doc/arthas-tutorials?language=en&id=command-mc-redefine"><code class="docutils literal notranslate"><span class="pre">mc-redefine</span></code> online tutorial</a></p>
|
||||
<blockquote>
|
||||
<div><p>Load the external <code class="docutils literal notranslate"><span class="pre">*.class</span></code> files to re-define the loaded classes in JVM.</p>
|
||||
</div></blockquote>
|
||||
<p>Reference: <a class="reference external" href="https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html#redefineClasses-java.lang.instrument.ClassDefinition...-">Instrumentation#redefineClasses</a></p>
|
||||
<div class="section" id="frequently-asked-questions">
|
||||
<h2>Frequently asked questions<a class="headerlink" href="#frequently-asked-questions" title="Permalink to this headline">¶</a></h2>
|
||||
<ul class="simple">
|
||||
<li><p>The class of <code class="docutils literal notranslate"><span class="pre">redefine</span></code> cannot modify, add or delete the field and method of the class, including method parameters, method names and return values.</p></li>
|
||||
<li><p>If <code class="docutils literal notranslate"><span class="pre">mc</span></code> fails, you can compile the class file in the local development environment, upload it to the target system, and use <code class="docutils literal notranslate"><span class="pre">redefine</span></code> to hot load the class.</p></li>
|
||||
<li><p>At present, <code class="docutils literal notranslate"><span class="pre">redefine</span></code> conflicts with <code class="docutils literal notranslate"><span class="pre">watch</span> <span class="pre">/</span> <span class="pre">trace</span> <span class="pre">/</span> <span class="pre">jad</span> <span class="pre">/</span> <span class="pre">tt</span></code> commands. Reimplementing <code class="docutils literal notranslate"><span class="pre">redefine</span></code> function in the future will solve this problem.</p></li>
|
||||
</ul>
|
||||
<blockquote>
|
||||
<div><p>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.</p>
|
||||
</div></blockquote>
|
||||
@@ -235,6 +244,7 @@
|
||||
<div><p>The <code class="docutils literal notranslate"><span class="pre">redefine</span></code> command will conflict with the <code class="docutils literal notranslate"><span class="pre">jad</span></code>/<code class="docutils literal notranslate"><span class="pre">watch</span></code>/<code class="docutils literal notranslate"><span class="pre">trace</span></code>/<code class="docutils literal notranslate"><span class="pre">monitor</span></code>/<code class="docutils literal notranslate"><span class="pre">tt</span></code> commands. After executing <code class="docutils literal notranslate"><span class="pre">redefine</span></code>, if you execute the above mentioned command, the bytecode of the class will be reset.
|
||||
The reason is that in the JDK <code class="docutils literal notranslate"><span class="pre">redefine</span></code> and <code class="docutils literal notranslate"><span class="pre">retransform</span></code> are different mechanisms. When two mechanisms are both used to update the bytecode, only the last modified will take effect.</p>
|
||||
</div></blockquote>
|
||||
</div>
|
||||
<div class="section" id="options">
|
||||
<h2>Options<a class="headerlink" href="#options" title="Permalink to this headline">¶</a></h2>
|
||||
<table border="1" class="docutils">
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
|
||||
<div class="section" id="sc">
|
||||
<h1>sc<a class="headerlink" href="#sc" title="Permalink to this headline">¶</a></h1>
|
||||
<p><a class="reference external" href="https://arthas.aliyun.com/doc/arthas-tutorials?language=en&id=command-sc"><code class="docutils literal notranslate"><span class="pre">sc</span></code> online tutorial</a></p>
|
||||
<blockquote>
|
||||
<div><p>Search classes loaded by JVM.</p>
|
||||
</div></blockquote>
|
||||
@@ -256,6 +257,14 @@
|
||||
<td align="right"><code>[x:]</code></td>
|
||||
<td align="left">specify the depth of recursive traverse the static fields, the default value is '0' - equivalent to use <code>toString</code> to output</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><code>[c:]</code></td>
|
||||
<td align="left">The hash code of the special class's classLoader</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><code>[n:]</code></td>
|
||||
<td align="left">Maximum number of matching classes with details (100 by default)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table><blockquote>
|
||||
<div><p><em>class-patten</em> 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/>
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -218,6 +218,7 @@
|
||||
|
||||
<div class="section" id="sm">
|
||||
<h1>sm<a class="headerlink" href="#sm" title="Permalink to this headline">¶</a></h1>
|
||||
<p><a class="reference external" href="https://arthas.aliyun.com/doc/arthas-tutorials?language=en&id=command-sm"><code class="docutils literal notranslate"><span class="pre">sm</span></code> online tutorial</a></p>
|
||||
<blockquote>
|
||||
<div><p>Search method from the loaded classes.</p>
|
||||
</div></blockquote>
|
||||
@@ -248,6 +249,14 @@
|
||||
<td align="right"><code>[E]</code></td>
|
||||
<td align="left">turn on regex matching while the default mode is wildcard matching</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><code>[c:]</code></td>
|
||||
<td align="left">The hash code of the special class's classLoader</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><code>[n:]</code></td>
|
||||
<td align="left">Maximum number of matching classes with details (100 by default)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<div class="section" id="usage">
|
||||
|
||||
+36
-5
@@ -129,7 +129,8 @@
|
||||
<li class="toctree-l3"><a class="reference internal" href="#enhancer">enhancer</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#id14">其它</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="#id14">案例</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#javaclasspath">获取Java应用的Classpath</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#watchmap">watch命令输出map对象</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -227,9 +228,9 @@ API可以提供结构化的数据,支持更复杂的交互功能,比如特
|
||||
<h3>请求数据格式<a class="headerlink" href="#id3" title="永久链接至标题">¶</a></h3>
|
||||
<div class="highlight-json notranslate"><div class="highlight hljs"><pre class="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"
|
||||
}</pre></div>
|
||||
@@ -693,8 +694,38 @@ API可以提供结构化的数据,支持更复杂的交互功能,比如特
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="id14">
|
||||
<h2>其它<a class="headerlink" href="#id14" title="永久链接至标题">¶</a></h2>
|
||||
<h2>案例<a class="headerlink" href="#id14" title="永久链接至标题">¶</a></h2>
|
||||
<div class="section" id="javaclasspath">
|
||||
<h3>获取Java应用的Classpath<a class="headerlink" href="#javaclasspath" title="永久链接至标题">¶</a></h3>
|
||||
<p>通过Http api查询Java应用的System properties,提取<code class="docutils literal notranslate"><span class="pre">java.class.path</span></code>的值。</p>
|
||||
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">json_data=$(curl -Ss -XPOST http://localhost:8563/api -d '
|
||||
{
|
||||
"action":"exec",
|
||||
"command":"sysprop"
|
||||
}')</pre></div>
|
||||
</div>
|
||||
<ul class="simple">
|
||||
<li><p>使用<code class="docutils literal notranslate"><span class="pre">sed</span></code>提取值:</p></li>
|
||||
</ul>
|
||||
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">class_path=$(echo $json_data | tr -d '\n' | sed 's/.*"java.class.path":"\([^"]*\).*/\1/')
|
||||
echo "classpath: $class_path"</pre></div>
|
||||
</div>
|
||||
<ul class="simple">
|
||||
<li><p>使用<code class="docutils literal notranslate"><span class="pre">json_pp/awk</span></code>提取值</p></li>
|
||||
</ul>
|
||||
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">class_path=$(echo $json_data | tr -d '\n' | json_pp | grep java.class.path | awk -F'"' '{ print $4 }')
|
||||
echo "classpath: $class_path"</pre></div>
|
||||
</div>
|
||||
<p>输出内容:</p>
|
||||
<div class="highlight-default notranslate"><pre class="literal-block">classpath: demo-arthas-spring-boot.jar</pre>
|
||||
</div>
|
||||
<p>注意:</p>
|
||||
<ul class="simple">
|
||||
<li><p><code class="docutils literal notranslate"><span class="pre">echo</span> <span class="pre">$json_data</span> <span class="pre">|</span> <span class="pre">tr</span> <span class="pre">-d</span> <span class="pre">'\n'</span></code> : 删除换行符(<code class="docutils literal notranslate"><span class="pre">line.separator</span></code>的值),避免影响<code class="docutils literal notranslate"><span class="pre">sed</span></code>/<code class="docutils literal notranslate"><span class="pre">json_pp</span></code>命令处理。</p></li>
|
||||
<li><p><code class="docutils literal notranslate"><span class="pre">awk</span> <span class="pre">-F'"'</span> <span class="pre">'{</span> <span class="pre">print</span> <span class="pre">$4</span> <span class="pre">}'</span></code> : 使用双引号作为分隔符号</p></li>
|
||||
</ul>
|
||||
<p><a id="change_watch_value_to_map"></a></p>
|
||||
</div>
|
||||
<div class="section" id="watchmap">
|
||||
<h3>watch命令输出map对象<a class="headerlink" href="#watchmap" title="永久链接至标题">¶</a></h3>
|
||||
<p>watch的结果值由计算<code class="docutils literal notranslate"><span class="pre">watch-express</span></code> ognl表达式产生,可以通过改变ognl表达式来生成想要的值,请参考<a class="reference external" href="https://commons.apache.org/proper/commons-ognl/language-guide.html">OGNL文档</a>。</p>
|
||||
|
||||
@@ -227,6 +227,7 @@
|
||||
|
||||
<div class="section" id="jad">
|
||||
<h1>jad<a class="headerlink" href="#jad" title="永久链接至标题">¶</a></h1>
|
||||
<p><a class="reference external" href="https://arthas.aliyun.com/doc/arthas-tutorials?language=cn&id=command-jad"><code class="docutils literal notranslate"><span class="pre">jad</span></code>在线教程</a></p>
|
||||
<blockquote>
|
||||
<div><p>反编译指定已加载类的源码</p>
|
||||
</div></blockquote>
|
||||
|
||||
@@ -228,6 +228,7 @@
|
||||
|
||||
<div class="section" id="logger">
|
||||
<h1>logger<a class="headerlink" href="#logger" title="永久链接至标题">¶</a></h1>
|
||||
<p><a class="reference external" href="https://arthas.aliyun.com/doc/arthas-tutorials?language=cn&id=command-logger"><code class="docutils literal notranslate"><span class="pre">logger</span></code>在线教程</a></p>
|
||||
<blockquote>
|
||||
<div><p>查看logger信息,更新logger level</p>
|
||||
</div></blockquote>
|
||||
|
||||
@@ -217,6 +217,7 @@
|
||||
|
||||
<div class="section" id="mc">
|
||||
<h1>mc<a class="headerlink" href="#mc" title="永久链接至标题">¶</a></h1>
|
||||
<p><a class="reference external" href="https://arthas.aliyun.com/doc/arthas-tutorials?language=cn&id=command-mc-redefine"><code class="docutils literal notranslate"><span class="pre">mc-redefine</span></code>在线教程</a></p>
|
||||
<blockquote>
|
||||
<div><p>Memory Compiler/内存编译器,编译<code class="docutils literal notranslate"><span class="pre">.java</span></code>文件生成<code class="docutils literal notranslate"><span class="pre">.class</span></code>。</p>
|
||||
</div></blockquote>
|
||||
|
||||
+52
-14
@@ -127,20 +127,21 @@
|
||||
<li class="toctree-l2"><a class="reference internal" href="stack.html">stack</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="tt.html">tt</a></li>
|
||||
<li class="toctree-l2 current"><a class="current reference internal" href="#">profiler</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id1">启动profiler</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id1">参数说明</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id2">启动profiler</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#sample">获取已采集的sample的数量</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id2">查看profiler状态</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id3">停止profiler</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id3">查看profiler状态</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id4">停止profiler</a><ul>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#svg">生成svg格式结果</a></li>
|
||||
<li class="toctree-l4"><a class="reference internal" href="#html">生成html格式结果</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#arthas-outputprofiler">通过浏览器查看arthas-output下面的profiler结果</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#profilerevents">profiler支持的events</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id4">恢复采样</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id5">恢复采样</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#execute">使用<code class="docutils literal notranslate"><span class="pre">execute</span></code>来执行复杂的命令</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#action">查看所有支持的action</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id5">查看版本</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id6">查看版本</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="cat.html">cat</a></li>
|
||||
@@ -233,13 +234,50 @@
|
||||
|
||||
<div class="section" id="profiler">
|
||||
<h1>profiler<a class="headerlink" href="#profiler" title="永久链接至标题">¶</a></h1>
|
||||
<p><a class="reference external" href="https://arthas.aliyun.com/doc/arthas-tutorials.html?language=cn&id=command-profiler"><code class="docutils literal notranslate"><span class="pre">profiler</span></code>在线教程</a></p>
|
||||
<blockquote>
|
||||
<div><p>使用<a class="reference external" href="https://github.com/jvm-profiling-tools/async-profiler">async-profiler</a>生成火焰图</p>
|
||||
</div></blockquote>
|
||||
<p><code class="docutils literal notranslate"><span class="pre">profiler</span></code> 命令支持生成应用热点的火焰图。本质上是通过不断的采样,然后把收集到的采样结果生成火焰图。</p>
|
||||
<p><code class="docutils literal notranslate"><span class="pre">profiler</span></code> 命令基本运行结构是 <code class="docutils literal notranslate"><span class="pre">profiler</span> <span class="pre">action</span> <span class="pre">[actionArg]</span></code></p>
|
||||
<div class="section" id="id1">
|
||||
<h2>启动profiler<a class="headerlink" href="#id1" title="永久链接至标题">¶</a></h2>
|
||||
<h2>参数说明<a class="headerlink" href="#id1" title="永久链接至标题">¶</a></h2>
|
||||
<table border="1" class="docutils">
|
||||
<thead>
|
||||
<tr>
|
||||
<th align="right">参数名称</th>
|
||||
<th align="left">参数说明</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="right"><em>action</em></td>
|
||||
<td align="left">要执行的操作</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><em>actionArg</em></td>
|
||||
<td align="left">属性名模式</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">[i:]</td>
|
||||
<td align="left">采样间隔(单位:ns)(默认值:10'000'000,即10 ms)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">[f:]</td>
|
||||
<td align="left">将输出转储到指定路径</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">[d:]</td>
|
||||
<td align="left">运行评测指定秒</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right">[e:]</td>
|
||||
<td align="left">要跟踪哪个事件(cpu, alloc, lock, cache-misses等),默认是cpu</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<div class="section" id="id2">
|
||||
<h2>启动profiler<a class="headerlink" href="#id2" title="永久链接至标题">¶</a></h2>
|
||||
<div class="highlight-default notranslate"><pre class="literal-block">$ profiler start
|
||||
Started [cpu] profiling</pre>
|
||||
</div>
|
||||
@@ -253,15 +291,15 @@ Started [cpu] profiling</pre>
|
||||
23</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="id2">
|
||||
<h2>查看profiler状态<a class="headerlink" href="#id2" title="永久链接至标题">¶</a></h2>
|
||||
<div class="section" id="id3">
|
||||
<h2>查看profiler状态<a class="headerlink" href="#id3" title="永久链接至标题">¶</a></h2>
|
||||
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ profiler status
|
||||
[cpu] profiling is running for 4 seconds</pre></div>
|
||||
</div>
|
||||
<p>可以查看当前profiler在采样哪种<code class="docutils literal notranslate"><span class="pre">event</span></code>和采样时间。</p>
|
||||
</div>
|
||||
<div class="section" id="id3">
|
||||
<h2>停止profiler<a class="headerlink" href="#id3" title="永久链接至标题">¶</a></h2>
|
||||
<div class="section" id="id4">
|
||||
<h2>停止profiler<a class="headerlink" href="#id4" title="永久链接至标题">¶</a></h2>
|
||||
<div class="section" id="svg">
|
||||
<h3>生成svg格式结果<a class="headerlink" href="#svg" title="永久链接至标题">¶</a></h3>
|
||||
<div class="highlight-default notranslate"><pre class="literal-block">$ profiler stop
|
||||
@@ -334,8 +372,8 @@ Perf events:
|
||||
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ profiler start --event alloc</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="id4">
|
||||
<h2>恢复采样<a class="headerlink" href="#id4" title="永久链接至标题">¶</a></h2>
|
||||
<div class="section" id="id5">
|
||||
<h2>恢复采样<a class="headerlink" href="#id5" title="永久链接至标题">¶</a></h2>
|
||||
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ profiler resume
|
||||
Started [cpu] profiling</pre></div>
|
||||
</div>
|
||||
@@ -358,8 +396,8 @@ Started [cpu] profiling</pre></div>
|
||||
Supported Actions: [resume, dumpCollapsed, getSamples, start, list, execute, version, stop, load, dumpFlat, actions, dumpTraces, status]</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="id5">
|
||||
<h2>查看版本<a class="headerlink" href="#id5" title="永久链接至标题">¶</a></h2>
|
||||
<div class="section" id="id6">
|
||||
<h2>查看版本<a class="headerlink" href="#id6" title="永久链接至标题">¶</a></h2>
|
||||
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">$ profiler version
|
||||
Async-profiler 1.6 built on Sep 9 2019
|
||||
Copyright 2019 Andrei Pangin</pre></div>
|
||||
|
||||
+19
-9
@@ -121,11 +121,12 @@
|
||||
<li class="toctree-l2"><a class="reference internal" href="classloader.html">classloader</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="mc.html">mc</a></li>
|
||||
<li class="toctree-l2 current"><a class="current reference internal" href="#">redefine</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id1">参数说明</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id2">使用参考</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id1">常见问题</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id2">参数说明</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id3">使用参考</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#jad-mc">结合 jad/mc 命令使用</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#class">上传 .class 文件到服务器的技巧</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id3">redefine的限制</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="#id4">redefine的限制</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="monitor.html">monitor</a></li>
|
||||
@@ -224,10 +225,18 @@
|
||||
|
||||
<div class="section" id="redefine">
|
||||
<h1>redefine<a class="headerlink" href="#redefine" title="永久链接至标题">¶</a></h1>
|
||||
<p><a class="reference external" href="https://arthas.aliyun.com/doc/arthas-tutorials?language=cn&id=command-mc-redefine"><code class="docutils literal notranslate"><span class="pre">mc-redefine</span></code>在线教程</a></p>
|
||||
<blockquote>
|
||||
<div><p>加载外部的<code class="docutils literal notranslate"><span class="pre">.class</span></code>文件,redefine jvm已加载的类。</p>
|
||||
</div></blockquote>
|
||||
<p>参考:<a class="reference external" href="https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/Instrumentation.html#redefineClasses-java.lang.instrument.ClassDefinition...-">Instrumentation#redefineClasses</a></p>
|
||||
<div class="section" id="id1">
|
||||
<h2>常见问题<a class="headerlink" href="#id1" title="永久链接至标题">¶</a></h2>
|
||||
<ul class="simple">
|
||||
<li><p>redefine的class不能修改、添加、删除类的field和method,包括方法参数、方法名称及返回值</p></li>
|
||||
<li><p>如果mc失败,可以在本地开发环境编译好class文件,上传到目标系统,使用redefine热加载class</p></li>
|
||||
<li><p>目前redefine 和watch/trace/jad/tt等命令冲突,以后重新实现redefine功能会解决此问题</p></li>
|
||||
</ul>
|
||||
<blockquote>
|
||||
<div><p>注意, redefine后的原来的类不能恢复,redefine有可能失败(比如增加了新的field),参考jdk本身的文档。</p>
|
||||
</div></blockquote>
|
||||
@@ -238,8 +247,9 @@
|
||||
<div><p><code class="docutils literal notranslate"><span class="pre">redefine</span></code>命令和<code class="docutils literal notranslate"><span class="pre">jad</span></code>/<code class="docutils literal notranslate"><span class="pre">watch</span></code>/<code class="docutils literal notranslate"><span class="pre">trace</span></code>/<code class="docutils literal notranslate"><span class="pre">monitor</span></code>/<code class="docutils literal notranslate"><span class="pre">tt</span></code>等命令会冲突。执行完<code class="docutils literal notranslate"><span class="pre">redefine</span></code>之后,如果再执行上面提到的命令,则会把<code class="docutils literal notranslate"><span class="pre">redefine</span></code>的字节码重置。
|
||||
原因是jdk本身redefine和Retransform是不同的机制,同时使用两种机制来更新字节码,只有最后修改的会生效。</p>
|
||||
</div></blockquote>
|
||||
<div class="section" id="id1">
|
||||
<h2>参数说明<a class="headerlink" href="#id1" title="永久链接至标题">¶</a></h2>
|
||||
</div>
|
||||
<div class="section" id="id2">
|
||||
<h2>参数说明<a class="headerlink" href="#id2" title="永久链接至标题">¶</a></h2>
|
||||
<table border="1" class="docutils">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -258,8 +268,8 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<div class="section" id="id2">
|
||||
<h2>使用参考<a class="headerlink" href="#id2" title="永久链接至标题">¶</a></h2>
|
||||
<div class="section" id="id3">
|
||||
<h2>使用参考<a class="headerlink" href="#id3" title="永久链接至标题">¶</a></h2>
|
||||
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash"> redefine /tmp/Test.class
|
||||
redefine -c 327a647b /tmp/Test.class /tmp/Test\$Inner.class</pre></div>
|
||||
</div>
|
||||
@@ -294,8 +304,8 @@ redefine /tmp/com/example/demo/arthas/user/UserController.class</pre></div>
|
||||
<li><p>用md5命令计算哈希值,校验是否一致</p></li>
|
||||
</ol>
|
||||
</div>
|
||||
<div class="section" id="id3">
|
||||
<h2>redefine的限制<a class="headerlink" href="#id3" title="永久链接至标题">¶</a></h2>
|
||||
<div class="section" id="id4">
|
||||
<h2>redefine的限制<a class="headerlink" href="#id4" title="永久链接至标题">¶</a></h2>
|
||||
<ul>
|
||||
<li><p>不允许新增加field/method</p></li>
|
||||
<li><p>正在跑的函数,没有退出不能生效,比如下面新增加的<code class="docutils literal notranslate"><span class="pre">System.out.println</span></code>,只有<code class="docutils literal notranslate"><span class="pre">run()</span></code>函数里的会生效</p>
|
||||
|
||||
@@ -224,6 +224,7 @@
|
||||
|
||||
<div class="section" id="sc">
|
||||
<h1>sc<a class="headerlink" href="#sc" title="永久链接至标题">¶</a></h1>
|
||||
<p><a class="reference external" href="https://arthas.aliyun.com/doc/arthas-tutorials?language=cn&id=command-sc"><code class="docutils literal notranslate"><span class="pre">sc</span></code>在线教程</a></p>
|
||||
<blockquote>
|
||||
<div><p>查看JVM已加载的类信息</p>
|
||||
</div></blockquote>
|
||||
@@ -264,6 +265,14 @@
|
||||
<td align="right">[x:]</td>
|
||||
<td align="left">指定输出静态变量时属性的遍历深度,默认为 0,即直接使用 <code>toString</code> 输出</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><code>[c:]</code></td>
|
||||
<td align="left">指定class的 ClassLoader 的 hashcode</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><code>[n:]</code></td>
|
||||
<td align="left">具有详细信息的匹配类的最大数量(默认为100)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table><blockquote>
|
||||
<div><p>class-pattern支持全限定名,如com.taobao.test.AAA,也支持com/taobao/test/AAA这样的格式,这样,我们从异常堆栈里面把类名拷贝过来的时候,不需要在手动把<code class="docutils literal notranslate"><span class="pre">/</span></code>替换为<code class="docutils literal notranslate"><span class="pre">.</span></code>啦。</p>
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -221,6 +221,7 @@
|
||||
|
||||
<div class="section" id="sm">
|
||||
<h1>sm<a class="headerlink" href="#sm" title="永久链接至标题">¶</a></h1>
|
||||
<p><a class="reference external" href="https://arthas.aliyun.com/doc/arthas-tutorials?language=cn&id=command-sm"><code class="docutils literal notranslate"><span class="pre">sm</span></code>在线教程</a></p>
|
||||
<blockquote>
|
||||
<div><p>查看已加载类的方法信息</p>
|
||||
</div></blockquote>
|
||||
@@ -252,6 +253,14 @@
|
||||
<td align="right">[E]</td>
|
||||
<td align="left">开启正则表达式匹配,默认为通配符匹配</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><code>[c:]</code></td>
|
||||
<td align="left">指定class的 ClassLoader 的 hashcode</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right"><code>[n:]</code></td>
|
||||
<td align="left">具有详细信息的匹配类的最大数量(默认为100)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table></div>
|
||||
<div class="section" id="id2">
|
||||
|
||||
Reference in New Issue
Block a user