mirror of
https://github.com/alibaba/arthas.git
synced 2026-11-21 15:07:19 +00:00
update doc
This commit is contained in:
1 parent
30b2a190c6
commit
da5f4a397d
35 files changed
+417
-45
No files matched your search
@@ -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)|
|
||||
|
||||
### 使用参考
|
||||
|
||||
|
||||
Reference in new issue
Block a user