update doc

pull/483/head
hengyunabc 6 years ago
parent ac10e3bf71
commit 89fa8a4c84

@ -19,7 +19,7 @@ Arthas 3.0开始支持管道, 率先提供了`grep`,`wc`,`plaintext`的支持。
groovy表达式在arthas2.0中大量使用例如watch表达式 groovy表达式在arthas2.0中大量使用例如watch表达式
```sh ```bash
watch com.alibaba.sample.petstore.web.store.module.screen.ItemList add "params + ' ' + returnObj" params.size()==2 watch com.alibaba.sample.petstore.web.store.module.screen.ItemList add "params + ' ' + returnObj" params.size()==2
``` ```

@ -16,7 +16,7 @@ Arthas 3.0最重要的特性通过Arthas在线诊断平台无需再登陆
Arthas 3.0开始支持管道, 率先提供了`grep`,`wc`,`plaintext`的支持。 Arthas 3.0开始支持管道, 率先提供了`grep`,`wc`,`plaintext`的支持。
```sh ```bash
java.vendor.url http://java.oracle.com/ java.vendor.url http://java.oracle.com/
java.vm.vendor Oracle Corporation java.vm.vendor Oracle Corporation
java.runtime.name Java(TM) SE Runtime Environment java.runtime.name Java(TM) SE Runtime Environment
@ -55,7 +55,7 @@ To solve this, choose one of the following command:
groovy表达式在arthas2.0中大量使用例如watch表达式 groovy表达式在arthas2.0中大量使用例如watch表达式
```sh ```bash
watch com.alibaba.sample.petstore.web.store.module.screen.ItemList add "params + ' ' + returnObj" params.size()==2 watch com.alibaba.sample.petstore.web.store.module.screen.ItemList add "params + ' ' + returnObj" params.size()==2
``` ```

@ -6,14 +6,14 @@ arthas中的异步调用使用了仿linux系统任务相关的命令。[linux
## 1. 使用&在后台执行任务 ## 1. 使用&在后台执行任务
比如希望执行后台执行trace命令那么调用下面命令 比如希望执行后台执行trace命令那么调用下面命令
```sh ```bash
trace Test t & trace Test t &
``` ```
这时命令在后台执行可以在console中继续执行其他命令。 这时命令在后台执行可以在console中继续执行其他命令。
## 2. 通过jobs查看任务 ## 2. 通过jobs查看任务
如果希望查看当前有哪些arthas任务在执行可以执行jobs命令执行结果如下 如果希望查看当前有哪些arthas任务在执行可以执行jobs命令执行结果如下
```sh ```bash
$ jobs $ jobs
[10]* [10]*
Stopped watch com.taobao.container.Test test "params[0].{? #this.name == null }" -x 2 Stopped watch com.taobao.container.Test test "params[0].{? #this.name == null }" -x 2
@ -43,13 +43,13 @@ $ jobs
## 5. 任务输出重定向 ## 5. 任务输出重定向
可通过`>`或者`>>`将任务输出结果输出到指定的文件中,可以和`&`一起使用实现arthas命令的异步调用。比如 可通过`>`或者`>>`将任务输出结果输出到指定的文件中,可以和`&`一起使用实现arthas命令的异步调用。比如
```sh ```bash
$ trace Test t >> test.out & $ trace Test t >> test.out &
``` ```
这时trace命令会在后台执行并且把结果输出到~/logs/arthas-cache/test.out。可继续执行其他命令。并可查看文件中的命令执行结果。 这时trace命令会在后台执行并且把结果输出到~/logs/arthas-cache/test.out。可继续执行其他命令。并可查看文件中的命令执行结果。
当连接到远程的arthas server时可能无法查看远程机器的文件arthas同时支持了自动重定向到本地缓存路径。使用方法如下 当连接到远程的arthas server时可能无法查看远程机器的文件arthas同时支持了自动重定向到本地缓存路径。使用方法如下
```sh ```bash
$ trace Test t >> & $ trace Test t >> &
job id : 2 job id : 2
cache location : /Users/gehui/logs/arthas-cache/28198/2 cache location : /Users/gehui/logs/arthas-cache/28198/2

@ -28,12 +28,12 @@ sc -d org.apache.commons.lang.StringUtils
通过`-b`开启批处理模式, `-f`执行脚本文件, 批处理脚本默认会输出到标准输出中,可以将结果重定向到文件中。 通过`-b`开启批处理模式, `-f`执行脚本文件, 批处理脚本默认会输出到标准输出中,可以将结果重定向到文件中。
```sh ```bash
./as.sh -b -f /var/tmp/test.as 56328 > test.out ./as.sh -b -f /var/tmp/test.as 56328 > test.out
``` ```
#### 第三步: 查看运行结果 #### 第三步: 查看运行结果
```sh ```bash
cat test.out cat test.out
``` ```

@ -41,7 +41,7 @@ Affect(row-cnt:11) cost in 66 ms.
* 按类加载实例查看统计信息 * 按类加载实例查看统计信息
```sh ```bash
$ classloader -l $ classloader -l
name loadedCount hash parent name loadedCount hash parent
BootstrapClassLoader 3711 null null BootstrapClassLoader 3711 null null

@ -119,7 +119,7 @@ Affect(row-cnt:1) cost in 190 ms.
反编译指定的方法: 反编译指定的方法:
```sh ```bash
$ jad com.taobao.container.web.arthas.rest.MetricsController directMetrics $ jad com.taobao.container.web.arthas.rest.MetricsController directMetrics
ClassLoader: ClassLoader:

@ -5,7 +5,7 @@
* 默认情况下,该功能是关闭的,如果需要开启,请执行以下命令: * 默认情况下,该功能是关闭的,如果需要开启,请执行以下命令:
```sh ```bash
$ options save-result true $ options save-result true
NAME BEFORE-VALUE AFTER-VALUE NAME BEFORE-VALUE AFTER-VALUE
---------------------------------------- ----------------------------------------
@ -21,7 +21,7 @@ Affect(row-cnt:1) cost in 3 ms.
### 使用新版本Arthas的异步后台任务将结果存日志文件 ### 使用新版本Arthas的异步后台任务将结果存日志文件
```sh ```bash
$ trace Test t >> & $ trace Test t >> &
job id : 2 job id : 2
cache location : /Users/zhuyong/logs/arthas-cache/28198/2 cache location : /Users/zhuyong/logs/arthas-cache/28198/2

@ -60,7 +60,7 @@ org.apache.catalina.connector.Connector->getMaxCookieCount
``` ```
```sh ```bash
$ sm org.apache.catalina.connector.Connector -d $ sm org.apache.catalina.connector.Connector -d
declaring-class org.apache.catalina.connector.Connector declaring-class org.apache.catalina.connector.Connector
constructor-name <init> constructor-name <init>

@ -7,7 +7,7 @@
./as.sh ./as.sh
``` ```
```sh ```bash
➜ bin git:(develop) ✗ ./as.sh ➜ bin git:(develop) ✗ ./as.sh
Found existing java process, please choose one and hit RETURN. Found existing java process, please choose one and hit RETURN.
[1]: 3088 org.jetbrains.idea.maven.server.RemoteMavenServer [1]: 3088 org.jetbrains.idea.maven.server.RemoteMavenServer

@ -99,7 +99,7 @@ $ thread 1
有时候我们发现应用卡住了, 通常是由于某个线程拿住了某个锁, 并且其他线程都在等待这把锁造成的。 为了排查这类问题, arthas提供了`thread -b` 一键找出那个罪魁祸首。 有时候我们发现应用卡住了, 通常是由于某个线程拿住了某个锁, 并且其他线程都在等待这把锁造成的。 为了排查这类问题, arthas提供了`thread -b` 一键找出那个罪魁祸首。
```sh ```bash
$ thread -b $ thread -b
"http-bio-8080-exec-4" Id=27 TIMED_WAITING "http-bio-8080-exec-4" Id=27 TIMED_WAITING
at java.lang.Thread.sleep(Native Method) at java.lang.Thread.sleep(Native Method)
@ -143,7 +143,7 @@ $ thread -b
#### thread -i, 指定采样时间间隔 #### thread -i, 指定采样时间间隔
```sh ```bash
$ thread -n 3 -i 1000 $ thread -n 3 -i 1000
"as-command-execute-daemon" Id=4759 cpuUsage=23% RUNNABLE "as-command-execute-daemon" Id=4759 cpuUsage=23% RUNNABLE
at sun.management.ThreadImpl.dumpThreads0(Native Method) at sun.management.ThreadImpl.dumpThreads0(Native Method)

@ -185,7 +185,7 @@
<div class="section" id="groovy"> <div class="section" id="groovy">
<span id="groovy"></span><h1>去groovy依赖<a class="headerlink" href="#groovy" title="永久链接至标题"></a></h1> <span id="groovy"></span><h1>去groovy依赖<a class="headerlink" href="#groovy" title="永久链接至标题"></a></h1>
<p>groovy表达式在arthas2.0中大量使用例如watch表达式</p> <p>groovy表达式在arthas2.0中大量使用例如watch表达式</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>watch com.alibaba.sample.petstore.web.store.module.screen.ItemList add <span class="s2">&quot;params + &#39; &#39; + returnObj&quot;</span> params.size<span class="o">()==</span><span class="m">2</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>watch com.alibaba.sample.petstore.web.store.module.screen.ItemList add <span class="s2">&quot;params + &#39; &#39; + returnObj&quot;</span> params.size<span class="o">()==</span><span class="m">2</span>
</pre></div> </pre></div>
</div> </div>
<p>其中<code class="docutils literal notranslate"><span class="pre">&quot;params</span> <span class="pre">+</span> <span class="pre">'</span> <span class="pre">'</span> <span class="pre">+</span> <span class="pre">returnObj&quot;</span></code>以及<code class="docutils literal notranslate"><span class="pre">params.size()==2</span></code>背后其实都使用了groovy来进行表达式求值如果反复大量的运行这些表达式groovy会创建大量的classloader打满perm区从而触发FGC。</p> <p>其中<code class="docutils literal notranslate"><span class="pre">&quot;params</span> <span class="pre">+</span> <span class="pre">'</span> <span class="pre">'</span> <span class="pre">+</span> <span class="pre">returnObj&quot;</span></code>以及<code class="docutils literal notranslate"><span class="pre">params.size()==2</span></code>背后其实都使用了groovy来进行表达式求值如果反复大量的运行这些表达式groovy会创建大量的classloader打满perm区从而触发FGC。</p>

@ -175,7 +175,7 @@
<div class="section" id=""> <div class="section" id="">
<span id="id2"></span><h2>管道支持<a class="headerlink" href="#" title="永久链接至标题"></a></h2> <span id="id2"></span><h2>管道支持<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>Arthas 3.0开始支持管道, 率先提供了<code class="docutils literal notranslate"><span class="pre">grep</span></code>,<code class="docutils literal notranslate"><span class="pre">wc</span></code>,<code class="docutils literal notranslate"><span class="pre">plaintext</span></code>的支持。</p> <p>Arthas 3.0开始支持管道, 率先提供了<code class="docutils literal notranslate"><span class="pre">grep</span></code>,<code class="docutils literal notranslate"><span class="pre">wc</span></code>,<code class="docutils literal notranslate"><span class="pre">plaintext</span></code>的支持。</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span> java.vendor.url http://java.oracle.com/ <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span> java.vendor.url http://java.oracle.com/
java.vm.vendor Oracle Corporation java.vm.vendor Oracle Corporation
java.runtime.name Java<span class="o">(</span>TM<span class="o">)</span> SE Runtime Environment java.runtime.name Java<span class="o">(</span>TM<span class="o">)</span> SE Runtime Environment
sun.java.command org.apache.catalina.startup.Bootstrap start sun.java.command org.apache.catalina.startup.Bootstrap start
@ -210,7 +210,7 @@ To solve this, choose one of the following command:
<div class="section" id="groovy"> <div class="section" id="groovy">
<span id="groovy"></span><h2>去groovy依赖<a class="headerlink" href="#groovy" title="永久链接至标题"></a></h2> <span id="groovy"></span><h2>去groovy依赖<a class="headerlink" href="#groovy" title="永久链接至标题"></a></h2>
<p>groovy表达式在arthas2.0中大量使用例如watch表达式</p> <p>groovy表达式在arthas2.0中大量使用例如watch表达式</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>watch com.alibaba.sample.petstore.web.store.module.screen.ItemList add <span class="s2">&quot;params + &#39; &#39; + returnObj&quot;</span> params.size<span class="o">()==</span><span class="m">2</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>watch com.alibaba.sample.petstore.web.store.module.screen.ItemList add <span class="s2">&quot;params + &#39; &#39; + returnObj&quot;</span> params.size<span class="o">()==</span><span class="m">2</span>
</pre></div> </pre></div>
</div> </div>
<p>其中<code class="docutils literal notranslate"><span class="pre">&quot;params</span> <span class="pre">+</span> <span class="pre">'</span> <span class="pre">'</span> <span class="pre">+</span> <span class="pre">returnObj&quot;</span></code>以及<code class="docutils literal notranslate"><span class="pre">params.size()==2</span></code>背后其实都使用了groovy来进行表达式求值如果反复大量的运行这些表达式groovy会创建大量的classloader打满perm区从而触发FGC。</p> <p>其中<code class="docutils literal notranslate"><span class="pre">&quot;params</span> <span class="pre">+</span> <span class="pre">'</span> <span class="pre">'</span> <span class="pre">+</span> <span class="pre">returnObj&quot;</span></code>以及<code class="docutils literal notranslate"><span class="pre">params.size()==2</span></code>背后其实都使用了groovy来进行表达式求值如果反复大量的运行这些表达式groovy会创建大量的classloader打满perm区从而触发FGC。</p>

@ -199,7 +199,7 @@
<div class="section" id=""> <div class="section" id="">
<span id="id1"></span><h2>1. 使用&amp;在后台执行任务<a class="headerlink" href="#" title="永久链接至标题"></a></h2> <span id="id1"></span><h2>1. 使用&amp;在后台执行任务<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>比如希望执行后台执行trace命令那么调用下面命令</p> <p>比如希望执行后台执行trace命令那么调用下面命令</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>trace Test t <span class="p">&amp;</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>trace Test t <span class="p">&amp;</span>
</pre></div> </pre></div>
</div> </div>
<p>这时命令在后台执行可以在console中继续执行其他命令。</p> <p>这时命令在后台执行可以在console中继续执行其他命令。</p>
@ -207,7 +207,7 @@
<div class="section" id="jobs"> <div class="section" id="jobs">
<span id="jobs"></span><h2>2. 通过jobs查看任务<a class="headerlink" href="#jobs" title="永久链接至标题"></a></h2> <span id="jobs"></span><h2>2. 通过jobs查看任务<a class="headerlink" href="#jobs" title="永久链接至标题"></a></h2>
<p>如果希望查看当前有哪些arthas任务在执行可以执行jobs命令执行结果如下</p> <p>如果希望查看当前有哪些arthas任务在执行可以执行jobs命令执行结果如下</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ <span class="nb">jobs</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ <span class="nb">jobs</span>
<span class="o">[</span><span class="m">10</span><span class="o">]</span>* <span class="o">[</span><span class="m">10</span><span class="o">]</span>*
Stopped watch com.taobao.container.Test <span class="nb">test</span> <span class="s2">&quot;params[0].{? #this.name == null }&quot;</span> -x <span class="m">2</span> Stopped watch com.taobao.container.Test <span class="nb">test</span> <span class="s2">&quot;params[0].{? #this.name == null }&quot;</span> -x <span class="m">2</span>
execution count : <span class="m">19</span> execution count : <span class="m">19</span>
@ -244,12 +244,12 @@
<div class="section" id=""> <div class="section" id="">
<span id="id3"></span><h2>5. 任务输出重定向<a class="headerlink" href="#" title="永久链接至标题"></a></h2> <span id="id3"></span><h2>5. 任务输出重定向<a class="headerlink" href="#" title="永久链接至标题"></a></h2>
<p>可通过<code class="docutils literal notranslate"><span class="pre">&gt;</span></code>或者<code class="docutils literal notranslate"><span class="pre">&gt;&gt;</span></code>将任务输出结果输出到指定的文件中,可以和<code class="docutils literal notranslate"><span class="pre">&amp;</span></code>一起使用实现arthas命令的异步调用。比如</p> <p>可通过<code class="docutils literal notranslate"><span class="pre">&gt;</span></code>或者<code class="docutils literal notranslate"><span class="pre">&gt;&gt;</span></code>将任务输出结果输出到指定的文件中,可以和<code class="docutils literal notranslate"><span class="pre">&amp;</span></code>一起使用实现arthas命令的异步调用。比如</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ trace Test t &gt;&gt; test.out <span class="p">&amp;</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ trace Test t &gt;&gt; test.out <span class="p">&amp;</span>
</pre></div> </pre></div>
</div> </div>
<p>这时trace命令会在后台执行并且把结果输出到~/logs/arthas-cache/test.out。可继续执行其他命令。并可查看文件中的命令执行结果。</p> <p>这时trace命令会在后台执行并且把结果输出到~/logs/arthas-cache/test.out。可继续执行其他命令。并可查看文件中的命令执行结果。</p>
<p>当连接到远程的arthas server时可能无法查看远程机器的文件arthas同时支持了自动重定向到本地缓存路径。使用方法如下</p> <p>当连接到远程的arthas server时可能无法查看远程机器的文件arthas同时支持了自动重定向到本地缓存路径。使用方法如下</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ trace Test t &gt;&gt; <span class="p">&amp;</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ trace Test t &gt;&gt; <span class="p">&amp;</span>
job id : <span class="m">2</span> job id : <span class="m">2</span>
cache location : /Users/gehui/logs/arthas-cache/28198/2 cache location : /Users/gehui/logs/arthas-cache/28198/2
</pre></div> </pre></div>

@ -217,13 +217,13 @@ sc -d org.apache.commons.lang.StringUtils
<div class="section" id=""> <div class="section" id="">
<span id="id4"></span><h3>第二步: 运行你的批处理脚本<a class="headerlink" href="#" title="永久链接至标题"></a></h3> <span id="id4"></span><h3>第二步: 运行你的批处理脚本<a class="headerlink" href="#" title="永久链接至标题"></a></h3>
<p>通过<code class="docutils literal notranslate"><span class="pre">-b</span></code>开启批处理模式, <code class="docutils literal notranslate"><span class="pre">-f</span></code>执行脚本文件, 批处理脚本默认会输出到标准输出中,可以将结果重定向到文件中。</p> <p>通过<code class="docutils literal notranslate"><span class="pre">-b</span></code>开启批处理模式, <code class="docutils literal notranslate"><span class="pre">-f</span></code>执行脚本文件, 批处理脚本默认会输出到标准输出中,可以将结果重定向到文件中。</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>./as.sh -b -f /var/tmp/test.as <span class="m">56328</span> &gt; test.out <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>./as.sh -b -f /var/tmp/test.as <span class="m">56328</span> &gt; test.out
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id=""> <div class="section" id="">
<span id="id5"></span><h3>第三步: 查看运行结果<a class="headerlink" href="#" title="永久链接至标题"></a></h3> <span id="id5"></span><h3>第三步: 查看运行结果<a class="headerlink" href="#" title="永久链接至标题"></a></h3>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>cat test.out <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>cat test.out
</pre></div> </pre></div>
</div> </div>
</div> </div>

@ -253,7 +253,7 @@ Affect<span class="p">(</span><span class="kp">row</span><span class="o">-</span
<ul class="simple"> <ul class="simple">
<li>按类加载实例查看统计信息</li> <li>按类加载实例查看统计信息</li>
</ul> </ul>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ classloader -l <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ classloader -l
name loadedCount hash parent name loadedCount hash parent
BootstrapClassLoader 3711 null null BootstrapClassLoader 3711 null null
com.alibaba.fastjson.util.ASMClassLoader@3bbaa1b8 2 3bbaa1b8 monitor&#39;s ModuleClassLoader com.alibaba.fastjson.util.ASMClassLoader@3bbaa1b8 2 3bbaa1b8 monitor&#39;s ModuleClassLoader

@ -8,7 +8,7 @@ Asynchronous jobs in arthas, using commands related to linux jobs.[linux man job
For example, execute the trace command in the background: For example, execute the trace command in the background:
```sh ```bash
trace Test t & trace Test t &
``` ```
@ -17,7 +17,7 @@ trace Test t &
If you want to list all background jobs, you can execute the `jobs` command and the results are as follows: If you want to list all background jobs, you can execute the `jobs` command and the results are as follows:
```sh ```bash
$ jobs $ jobs
[10]* [10]*
Stopped watch com.taobao.container.Test test "params[0].{? #this.name == null }" -x 2 Stopped watch com.taobao.container.Test test "params[0].{? #this.name == null }" -x 2
@ -54,7 +54,7 @@ When the job is executing in the foreground, such as directly calling the comman
The job output can be redirect to the specified file by `>` or `>>`, and can be used together with `&` to implement the asynchronous job of the arthas command. such as: The job output can be redirect to the specified file by `>` or `>>`, and can be used together with `&` to implement the asynchronous job of the arthas command. such as:
```sh ```bash
$ trace Test t >> test.out & $ trace Test t >> test.out &
``` ```
@ -63,7 +63,7 @@ The trace command will be executed in the background and the output will be redi
When connecting to a remote arthas server, you may not be able to view the files of the remote machine. Arthas also supports automatic redirection to the local cache file. Examples are as follows: When connecting to a remote arthas server, you may not be able to view the files of the remote machine. Arthas also supports automatic redirection to the local cache file. Examples are as follows:
```sh ```bash
$ trace Test t >> & $ trace Test t >> &
job id : 2 job id : 2
cache location : /Users/gehui/logs/arthas-cache/28198/2 cache location : /Users/gehui/logs/arthas-cache/28198/2

@ -28,12 +28,12 @@ Attention:
Using `-b` to turn on script mode, and `-f` to run it and you can also *redirect* the output as: Using `-b` to turn on script mode, and `-f` to run it and you can also *redirect* the output as:
```sh ```bash
./as.sh -b -f /var/tmp/test.as 56328 > test.out ./as.sh -b -f /var/tmp/test.as 56328 > test.out
``` ```
#### Step-3: Check the outputs #### Step-3: Check the outputs
```sh ```bash
cat test.out cat test.out
``` ```

@ -19,7 +19,7 @@ It can be a great help for `ResourceNotFoundException` when you can use command
* Categorised by class loader * Categorised by class loader
```sh ```bash
$ classloader $ classloader
name numberOfInstances loadedCountTotal name numberOfInstances loadedCountTotal
com.taobao.pandora.service.loader.ModuleClassLoader 29 11659 com.taobao.pandora.service.loader.ModuleClassLoader 29 11659
@ -38,7 +38,7 @@ Affect(row-cnt:11) cost in 66 ms.
* Categorized by class loader instance * Categorized by class loader instance
```sh ```bash
$ classloader -l $ classloader -l
name loadedCount hash parent name loadedCount hash parent
BootstrapClassLoader 3711 null null BootstrapClassLoader 3711 null null

@ -5,32 +5,32 @@ Arthas Documentation
![arthas](arthas.png) ![arthas](arthas.png)
`Arthas` is an Java Diagnostic tool open sourced by Alibaba. `Arthas` is a Java Diagnostic tool open sourced by Alibaba.
Arthas can help developer trouble-shooting production issues for Java applications without modifying your code or restating your server. Arthas help developers in trouble-shooting production issues for Java applications without modifying code or restarting servers.
### Background ### Background
In production system, sometimes the networks is unreachable from local development environment. If you encounter some issues in production system, it is impossible to use IDE to debug the application remotely. More importantly, debugging in production is unacceptable, because it will suspend all the threads, which leads to business unavailability. Often times, the production system network is inaccessible from local development environment. If issues are encountered in production systems, it is impossible to use IDE to debug the application remotely. More importantly, debugging in production environment is unacceptable, as it will suspend all the threads, which leads to blocking of business services.
Some may think of reproducing the same issue on the test/staging environment, however, some tricky issue either can hardly be reproduced on a different environment, or even disappeared once restarted. Developers could always try to reproduce the same issue on the test/staging environment. However, this is tricky as some issues cannot be be reproduced easily on a different environment, or even disappear once restarted.
Thinking of adding some logs to your code? You have to go through test, staging, and then on to production. Time is money! That is a lot inefficient! Besides, the issue may not be reproducible once restart your JVM, as described above. And if you're thinking of adding some logs to your code to help trouble-shoot the issue, you will have to go through the following lifecycle; test, staging, and then to production. Time is money! This approach is inefficient! Besides, the issue may not be reproducible once the JVM is restarted, as described above.
Arthas is born to solve these issues. You can trouble-shoot your production issue on-the-fly. No JVM restart, no additional code changes. Arthas works as an observer, which will never suspend your existing threads. Arthas was built to solve these issues. A developer can trouble-shoot your production issues on-the-fly. No JVM restart, no additional code changes. Arthas works as an observer, which will never suspend your existing threads.
### Key features ### Key features
* Check whether a class is loaded? And whether is class loaded from? (Useful for trouble-shooting jar file conflicts) * Check whether a class is loaded? Or where the class is loaded from? (Useful for trouble-shooting jar file conflicts)
* Decompile a class to ensure the code is running as expected. * Decompile a class to ensure the code is running as expected.
* View classloader statistics, e.g. how may classloaders are there? how many class is loaded per classloader? What is the classloader hierarchy? Is there possible classloader leaks? * View classloader statistics, e.g. the number of classloaders, the number of classes loaded per classloader, the classloader hierarchy, possible classloader leaks, etc.
* View the method invocation details, e.g. method parameter, return object, thrown exception, and etc. * View the method invocation details, e.g. method parameter, return object, thrown exception, and etc.
* Check the stack trace of specified method invocation. This is useful when you would like to know who is calling your method? * Check the stack trace of specified method invocation. This is useful when a developers wants to know the caller of the said method.
* Trace the method invocation to find slow sub-invocations. * Trace the method invocation to find slow sub-invocations.
* Monitor method invcation statistics, e.g. qps, rt, success rate and etc. * Monitor method invocation statistics, e.g. qps, rt, success rate and etc.
* Monitoring your system metrics, thread states and cpu usage, gc statistics, and etc. * Monitor system metrics, thread states and cpu usage, gc statistics, and etc.
* Support command line interactive mode, with auto completed feature enabled. * Supports command line interactive mode, with auto-complete feature enabled.
* Support telnet and websocket, which enables both local and remote diagnostics with command line and browsers. * Supports telnet and websocket, which enables both local and remote diagnostics with command line and browsers.
Contents Contents

@ -122,7 +122,7 @@ Affect(row-cnt:1) cost in 190 ms.
De-compile the specified method: De-compile the specified method:
```sh ```bash
$ jad com.taobao.container.web.arthas.rest.MetricsController directMetrics $ jad com.taobao.container.web.arthas.rest.MetricsController directMetrics
ClassLoader: ClassLoader:

@ -5,7 +5,7 @@ Log command outputs for later analysis, turned off by default.
To turn it on, using [options](options.md) as: To turn it on, using [options](options.md) as:
```sh ```bash
$ options save-result true $ options save-result true
NAME BEFORE-VALUE AFTER-VALUE NAME BEFORE-VALUE AFTER-VALUE
---------------------------------------- ----------------------------------------
@ -23,7 +23,7 @@ F.Y.I
:notes: :notes: :notes: :notes:
With the latest Arthas, you can log the outputs asynchronously in the background: With the latest Arthas, you can log the outputs asynchronously in the background:
```sh ```bash
$ trace Test t >> & $ trace Test t >> &
job id : 2 job id : 2
cache location : /Users/zhuyong/logs/arthas-cache/28198/2 cache location : /Users/zhuyong/logs/arthas-cache/28198/2

@ -61,7 +61,7 @@ org.apache.catalina.connector.Connector->getMaxCookieCount
``` ```
```sh ```bash
$ sm org.apache.catalina.connector.Connector -d $ sm org.apache.catalina.connector.Connector -d
declaring-class org.apache.catalina.connector.Connector declaring-class org.apache.catalina.connector.Connector
constructor-name <init> constructor-name <init>

@ -7,7 +7,7 @@ Start Arthas
./as.sh ./as.sh
``` ```
```sh ```bash
➜ bin git:(develop) ✗ ./as.sh ➜ bin git:(develop) ✗ ./as.sh
Found existing java process, please choose one and hit RETURN. Found existing java process, please choose one and hit RETURN.
[1]: 3088 org.jetbrains.idea.maven.server.RemoteMavenServer [1]: 3088 org.jetbrains.idea.maven.server.RemoteMavenServer

@ -100,7 +100,7 @@ $ thread 1
Using `-b`, we can effectively locate the threads holding locks blocking other threads resulting in a frozen system. Using `-b`, we can effectively locate the threads holding locks blocking other threads resulting in a frozen system.
```sh ```bash
$ thread -b $ thread -b
"http-bio-8080-exec-4" Id=27 TIMED_WAITING "http-bio-8080-exec-4" Id=27 TIMED_WAITING
at java.lang.Thread.sleep(Native Method) at java.lang.Thread.sleep(Native Method)
@ -144,7 +144,7 @@ $ thread -b
#### thread -i specify the collecting interval #### thread -i specify the collecting interval
```sh ```bash
$ thread -n 3 -i 1000 $ thread -n 3 -i 1000
"as-command-execute-daemon" Id=4759 cpuUsage=23% RUNNABLE "as-command-execute-daemon" Id=4759 cpuUsage=23% RUNNABLE
at sun.management.ThreadImpl.dumpThreads0(Native Method) at sun.management.ThreadImpl.dumpThreads0(Native Method)

@ -168,14 +168,14 @@
<div class="section" id="use-to-run-the-command-in-the-background"> <div class="section" id="use-to-run-the-command-in-the-background">
<span id="use-to-run-the-command-in-the-background"></span><h2>1. Use &amp; to run the command in the background<a class="headerlink" href="#use-to-run-the-command-in-the-background" title="Permalink to this headline"></a></h2> <span id="use-to-run-the-command-in-the-background"></span><h2>1. Use &amp; to run the command in the background<a class="headerlink" href="#use-to-run-the-command-in-the-background" title="Permalink to this headline"></a></h2>
<p>For example, execute the trace command in the background:</p> <p>For example, execute the trace command in the background:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>trace Test t <span class="p">&amp;</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>trace Test t <span class="p">&amp;</span>
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="list-background-jobs"> <div class="section" id="list-background-jobs">
<span id="list-background-jobs"></span><h2>2. List background jobs<a class="headerlink" href="#list-background-jobs" title="Permalink to this headline"></a></h2> <span id="list-background-jobs"></span><h2>2. List background jobs<a class="headerlink" href="#list-background-jobs" title="Permalink to this headline"></a></h2>
<p>If you want to list all background jobs, you can execute the <code class="docutils literal notranslate"><span class="pre">jobs</span></code> command and the results are as follows:</p> <p>If you want to list all background jobs, you can execute the <code class="docutils literal notranslate"><span class="pre">jobs</span></code> command and the results are as follows:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ <span class="nb">jobs</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ <span class="nb">jobs</span>
<span class="o">[</span><span class="m">10</span><span class="o">]</span>* <span class="o">[</span><span class="m">10</span><span class="o">]</span>*
Stopped watch com.taobao.container.Test <span class="nb">test</span> <span class="s2">&quot;params[0].{? #this.name == null }&quot;</span> -x <span class="m">2</span> Stopped watch com.taobao.container.Test <span class="nb">test</span> <span class="s2">&quot;params[0].{? #this.name == null }&quot;</span> -x <span class="m">2</span>
execution count : <span class="m">19</span> execution count : <span class="m">19</span>
@ -212,12 +212,12 @@
<div class="section" id="redirect-the-job-output"> <div class="section" id="redirect-the-job-output">
<span id="redirect-the-job-output"></span><h2>5. Redirect the job output<a class="headerlink" href="#redirect-the-job-output" title="Permalink to this headline"></a></h2> <span id="redirect-the-job-output"></span><h2>5. Redirect the job output<a class="headerlink" href="#redirect-the-job-output" title="Permalink to this headline"></a></h2>
<p>The job output can be redirect to the specified file by <code class="docutils literal notranslate"><span class="pre">&gt;</span></code> or <code class="docutils literal notranslate"><span class="pre">&gt;&gt;</span></code>, and can be used together with <code class="docutils literal notranslate"><span class="pre">&amp;</span></code> to implement the asynchronous job of the arthas command. such as:</p> <p>The job output can be redirect to the specified file by <code class="docutils literal notranslate"><span class="pre">&gt;</span></code> or <code class="docutils literal notranslate"><span class="pre">&gt;&gt;</span></code>, and can be used together with <code class="docutils literal notranslate"><span class="pre">&amp;</span></code> to implement the asynchronous job of the arthas command. such as:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ trace Test t &gt;&gt; test.out <span class="p">&amp;</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ trace Test t &gt;&gt; test.out <span class="p">&amp;</span>
</pre></div> </pre></div>
</div> </div>
<p>The trace command will be executed in the background and the output will be redirect to <code class="docutils literal notranslate"><span class="pre">~/logs/arthas-cache/test.out</span></code>. You can continue to execute other commands in the console.</p> <p>The trace command will be executed in the background and the output will be redirect to <code class="docutils literal notranslate"><span class="pre">~/logs/arthas-cache/test.out</span></code>. You can continue to execute other commands in the console.</p>
<p>When connecting to a remote arthas server, you may not be able to view the files of the remote machine. Arthas also supports automatic redirection to the local cache file. Examples are as follows:</p> <p>When connecting to a remote arthas server, you may not be able to view the files of the remote machine. Arthas also supports automatic redirection to the local cache file. Examples are as follows:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ trace Test t &gt;&gt; <span class="p">&amp;</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ trace Test t &gt;&gt; <span class="p">&amp;</span>
job id : <span class="m">2</span> job id : <span class="m">2</span>
cache location : /Users/gehui/logs/arthas-cache/28198/2 cache location : /Users/gehui/logs/arthas-cache/28198/2
</pre></div> </pre></div>

@ -189,13 +189,13 @@ sc -d org.apache.commons.lang.StringUtils
<div class="section" id="step-2-run-the-script"> <div class="section" id="step-2-run-the-script">
<span id="step-2-run-the-script"></span><h3>Step-2: Run the script<a class="headerlink" href="#step-2-run-the-script" title="Permalink to this headline"></a></h3> <span id="step-2-run-the-script"></span><h3>Step-2: Run the script<a class="headerlink" href="#step-2-run-the-script" title="Permalink to this headline"></a></h3>
<p>Using <code class="docutils literal notranslate"><span class="pre">-b</span></code> to turn on script mode, and <code class="docutils literal notranslate"><span class="pre">-f</span></code> to run it and you can also <em>redirect</em> the output as:</p> <p>Using <code class="docutils literal notranslate"><span class="pre">-b</span></code> to turn on script mode, and <code class="docutils literal notranslate"><span class="pre">-f</span></code> to run it and you can also <em>redirect</em> the output as:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>./as.sh -b -f /var/tmp/test.as <span class="m">56328</span> &gt; test.out <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>./as.sh -b -f /var/tmp/test.as <span class="m">56328</span> &gt; test.out
</pre></div> </pre></div>
</div> </div>
</div> </div>
<div class="section" id="step-3-check-the-outputs"> <div class="section" id="step-3-check-the-outputs">
<span id="step-3-check-the-outputs"></span><h3>Step-3: Check the outputs<a class="headerlink" href="#step-3-check-the-outputs" title="Permalink to this headline"></a></h3> <span id="step-3-check-the-outputs"></span><h3>Step-3: Check the outputs<a class="headerlink" href="#step-3-check-the-outputs" title="Permalink to this headline"></a></h3>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>cat test.out <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>cat test.out
</pre></div> </pre></div>
</div> </div>
</div> </div>

@ -231,7 +231,7 @@
<ul class="simple"> <ul class="simple">
<li>Categorised by class loader</li> <li>Categorised by class loader</li>
</ul> </ul>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ classloader <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ classloader
name numberOfInstances loadedCountTotal name numberOfInstances loadedCountTotal
com.taobao.pandora.service.loader.ModuleClassLoader <span class="m">29</span> <span class="m">11659</span> com.taobao.pandora.service.loader.ModuleClassLoader <span class="m">29</span> <span class="m">11659</span>
com.taobao.pandora.boot.loader.ReLaunchURLClassLoader <span class="m">1</span> <span class="m">5308</span> com.taobao.pandora.boot.loader.ReLaunchURLClassLoader <span class="m">1</span> <span class="m">5308</span>
@ -250,7 +250,7 @@ Affect<span class="o">(</span>row-cnt:11<span class="o">)</span> cost in <span c
<ul class="simple"> <ul class="simple">
<li>Categorized by class loader instance</li> <li>Categorized by class loader instance</li>
</ul> </ul>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ classloader -l <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ classloader -l
name loadedCount hash parent name loadedCount hash parent
BootstrapClassLoader 3711 null null BootstrapClassLoader 3711 null null
com.alibaba.fastjson.util.ASMClassLoader@3bbaa1b8 2 3bbaa1b8 monitor&#39;s ModuleClassLoader com.alibaba.fastjson.util.ASMClassLoader@3bbaa1b8 2 3bbaa1b8 monitor&#39;s ModuleClassLoader

@ -167,28 +167,28 @@
<span id="arthas-documentation"></span><h1>Arthas Documentation<a class="headerlink" href="#arthas-documentation" title="Permalink to this headline"></a></h1> <span id="arthas-documentation"></span><h1>Arthas Documentation<a class="headerlink" href="#arthas-documentation" title="Permalink to this headline"></a></h1>
<p><strong><a class="reference external" href="https://alibaba.github.io/arthas/">中文文档/Chinese Docs</a></strong></p> <p><strong><a class="reference external" href="https://alibaba.github.io/arthas/">中文文档/Chinese Docs</a></strong></p>
<p><img alt="arthas" src="_images/arthas.png" /></p> <p><img alt="arthas" src="_images/arthas.png" /></p>
<p><code class="docutils literal notranslate"><span class="pre">Arthas</span></code> is an Java Diagnostic tool open sourced by Alibaba.</p> <p><code class="docutils literal notranslate"><span class="pre">Arthas</span></code> is a Java Diagnostic tool open sourced by Alibaba.</p>
<p>Arthas can help developer trouble-shooting production issues for Java applications without modifying your code or restating your server.</p> <p>Arthas help developers in trouble-shooting production issues for Java applications without modifying code or restarting servers.</p>
<div class="section" id="background"> <div class="section" id="background">
<span id="background"></span><h2>Background<a class="headerlink" href="#background" title="Permalink to this headline"></a></h2> <span id="background"></span><h2>Background<a class="headerlink" href="#background" title="Permalink to this headline"></a></h2>
<p>In production system, sometimes the networks is unreachable from local development environment. If you encounter some issues in production system, it is impossible to use IDE to debug the application remotely. More importantly, debugging in production is unacceptable, because it will suspend all the threads, which leads to business unavailability.</p> <p>Often times, the production system network is inaccessible from local development environment. If issues are encountered in production systems, it is impossible to use IDE to debug the application remotely. More importantly, debugging in production environment is unacceptable, as it will suspend all the threads, which leads to blocking of business services.</p>
<p>Some may think of reproducing the same issue on the test/staging environment, however, some tricky issue either can hardly be reproduced on a different environment, or even disappeared once restarted.</p> <p>Developers could always try to reproduce the same issue on the test/staging environment. However, this is tricky as some issues cannot be be reproduced easily on a different environment, or even disappear once restarted.</p>
<p>Thinking of adding some logs to your code? You have to go through test, staging, and then on to production. Time is money! That is a lot inefficient! Besides, the issue may not be reproducible once restart your JVM, as described above.</p> <p>And if youre thinking of adding some logs to your code to help trouble-shoot the issue, you will have to go through the following lifecycle; test, staging, and then to production. Time is money! This approach is inefficient! Besides, the issue may not be reproducible once the JVM is restarted, as described above.</p>
<p>Arthas is born to solve these issues. You can trouble-shoot your production issue on-the-fly. No JVM restart, no additional code changes. Arthas works as an observer, which will never suspend your existing threads.</p> <p>Arthas was built to solve these issues. A developer can trouble-shoot your production issues on-the-fly. No JVM restart, no additional code changes. Arthas works as an observer, which will never suspend your existing threads.</p>
</div> </div>
<div class="section" id="key-features"> <div class="section" id="key-features">
<span id="key-features"></span><h2>Key features<a class="headerlink" href="#key-features" title="Permalink to this headline"></a></h2> <span id="key-features"></span><h2>Key features<a class="headerlink" href="#key-features" title="Permalink to this headline"></a></h2>
<ul class="simple"> <ul class="simple">
<li>Check whether a class is loaded? And whether is class loaded from? (Useful for trouble-shooting jar file conflicts)</li> <li>Check whether a class is loaded? Or where the class is loaded from? (Useful for trouble-shooting jar file conflicts)</li>
<li>Decompile a class to ensure the code is running as expected.</li> <li>Decompile a class to ensure the code is running as expected.</li>
<li>View classloader statistics, e.g. how may classloaders are there? how many class is loaded per classloader? What is the classloader hierarchy? Is there possible classloader leaks?</li> <li>View classloader statistics, e.g. the number of classloaders, the number of classes loaded per classloader, the classloader hierarchy, possible classloader leaks, etc.</li>
<li>View the method invocation details, e.g. method parameter, return object, thrown exception, and etc.</li> <li>View the method invocation details, e.g. method parameter, return object, thrown exception, and etc.</li>
<li>Check the stack trace of specified method invocation. This is useful when you would like to know who is calling your method?</li> <li>Check the stack trace of specified method invocation. This is useful when a developers wants to know the caller of the said method.</li>
<li>Trace the method invocation to find slow sub-invocations.</li> <li>Trace the method invocation to find slow sub-invocations.</li>
<li>Monitor method invcation statistics, e.g. qps, rt, success rate and etc.</li> <li>Monitor method invocation statistics, e.g. qps, rt, success rate and etc.</li>
<li>Monitoring your system metrics, thread states and cpu usage, gc statistics, and etc.</li> <li>Monitor system metrics, thread states and cpu usage, gc statistics, and etc.</li>
<li>Support command line interactive mode, with auto completed feature enabled.</li> <li>Supports command line interactive mode, with auto-complete feature enabled.</li>
<li>Support telnet and websocket, which enables both local and remote diagnostics with command line and browsers.</li> <li>Supports telnet and websocket, which enables both local and remote diagnostics with command line and browsers.</li>
</ul> </ul>
</div> </div>
<div class="section" id="contents"> <div class="section" id="contents">

@ -327,7 +327,7 @@ Affect(row-cnt:1) cost in 190 ms.
</pre></div> </pre></div>
</div> </div>
<p>De-compile the specified method:</p> <p>De-compile the specified method:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ jad com.taobao.container.web.arthas.rest.MetricsController directMetrics <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ jad com.taobao.container.web.arthas.rest.MetricsController directMetrics
ClassLoader: ClassLoader:
+-com.taobao.pandora.boot.loader.ReLaunchURLClassLoader@1817d444 +-com.taobao.pandora.boot.loader.ReLaunchURLClassLoader@1817d444

@ -166,7 +166,7 @@
<span id="log-command-outputs"></span><h1>Log command outputs<a class="headerlink" href="#log-command-outputs" title="Permalink to this headline"></a></h1> <span id="log-command-outputs"></span><h1>Log command outputs<a class="headerlink" href="#log-command-outputs" title="Permalink to this headline"></a></h1>
<p>Log command outputs for later analysis, turned off by default.</p> <p>Log command outputs for later analysis, turned off by default.</p>
<p>To turn it on, using <a class="reference internal" href="options.html"><span class="doc">options</span></a> as:</p> <p>To turn it on, using <a class="reference internal" href="options.html"><span class="doc">options</span></a> as:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ options save-result <span class="nb">true</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ options save-result <span class="nb">true</span>
NAME BEFORE-VALUE AFTER-VALUE NAME BEFORE-VALUE AFTER-VALUE
---------------------------------------- ----------------------------------------
save-result <span class="nb">false</span> <span class="nb">true</span> save-result <span class="nb">false</span> <span class="nb">true</span>
@ -182,7 +182,7 @@ Affect<span class="o">(</span>row-cnt:1<span class="o">)</span> cost in <span cl
<span id="asynchronous-log"></span><h2>Asynchronous log<a class="headerlink" href="#asynchronous-log" title="Permalink to this headline"></a></h2> <span id="asynchronous-log"></span><h2>Asynchronous log<a class="headerlink" href="#asynchronous-log" title="Permalink to this headline"></a></h2>
<p>:notes: :notes: <p>:notes: :notes:
With the latest Arthas, you can log the outputs asynchronously in the background:</p> With the latest Arthas, you can log the outputs asynchronously in the background:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ trace Test t &gt;&gt; <span class="p">&amp;</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ trace Test t &gt;&gt; <span class="p">&amp;</span>
job id : <span class="m">2</span> job id : <span class="m">2</span>
cache location : /Users/zhuyong/logs/arthas-cache/28198/2 cache location : /Users/zhuyong/logs/arthas-cache/28198/2
</pre></div> </pre></div>

File diff suppressed because one or more lines are too long

@ -266,7 +266,7 @@ org.apache.catalina.connector.Connector-&gt;getMaxCookieCount
... ...
</pre></div> </pre></div>
</div> </div>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sm org.apache.catalina.connector.Connector -d <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ sm org.apache.catalina.connector.Connector -d
declaring-class org.apache.catalina.connector.Connector declaring-class org.apache.catalina.connector.Connector
constructor-name &lt;init&gt; constructor-name &lt;init&gt;
modifier public modifier public

@ -169,7 +169,7 @@
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>./as.sh <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>./as.sh
</pre></div> </pre></div>
</div> </div>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>➜ bin git:<span class="o">(</span>develop<span class="o">)</span> ✗ ./as.sh <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>➜ bin git:<span class="o">(</span>develop<span class="o">)</span> ✗ ./as.sh
Found existing java process, please choose one and hit RETURN. Found existing java process, please choose one and hit RETURN.
<span class="o">[</span><span class="m">1</span><span class="o">]</span>: <span class="m">3088</span> org.jetbrains.idea.maven.server.RemoteMavenServer <span class="o">[</span><span class="m">1</span><span class="o">]</span>: <span class="m">3088</span> org.jetbrains.idea.maven.server.RemoteMavenServer
* <span class="o">[</span><span class="m">2</span><span class="o">]</span>: <span class="m">12872</span> org.apache.catalina.startup.Bootstrap * <span class="o">[</span><span class="m">2</span><span class="o">]</span>: <span class="m">12872</span> org.apache.catalina.startup.Bootstrap

@ -308,7 +308,7 @@ ID NAME GROUP PRIORITY STA
<div class="section" id="thread-b-locate-the-blocking-threads"> <div class="section" id="thread-b-locate-the-blocking-threads">
<span id="thread-b-locate-the-blocking-threads"></span><h3>thread -b locate the blocking threads<a class="headerlink" href="#thread-b-locate-the-blocking-threads" title="Permalink to this headline"></a></h3> <span id="thread-b-locate-the-blocking-threads"></span><h3>thread -b locate the blocking threads<a class="headerlink" href="#thread-b-locate-the-blocking-threads" title="Permalink to this headline"></a></h3>
<p>Using <code class="docutils literal notranslate"><span class="pre">-b</span></code>, we can effectively locate the threads holding locks blocking other threads resulting in a frozen system.</p> <p>Using <code class="docutils literal notranslate"><span class="pre">-b</span></code>, we can effectively locate the threads holding locks blocking other threads resulting in a frozen system.</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ thread -b <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ thread -b
<span class="s2">&quot;http-bio-8080-exec-4&quot;</span> <span class="nv">Id</span><span class="o">=</span><span class="m">27</span> TIMED_WAITING <span class="s2">&quot;http-bio-8080-exec-4&quot;</span> <span class="nv">Id</span><span class="o">=</span><span class="m">27</span> TIMED_WAITING
at java.lang.Thread.sleep<span class="o">(</span>Native Method<span class="o">)</span> at java.lang.Thread.sleep<span class="o">(</span>Native Method<span class="o">)</span>
at test.arthas.TestThreadBlocking.doGet<span class="o">(</span>TestThreadBlocking.java:22<span class="o">)</span> at test.arthas.TestThreadBlocking.doGet<span class="o">(</span>TestThreadBlocking.java:22<span class="o">)</span>
@ -351,7 +351,7 @@ ID NAME GROUP PRIORITY STA
</div> </div>
<div class="section" id="thread-i-specify-the-collecting-interval"> <div class="section" id="thread-i-specify-the-collecting-interval">
<span id="thread-i-specify-the-collecting-interval"></span><h3>thread -i specify the collecting interval<a class="headerlink" href="#thread-i-specify-the-collecting-interval" title="Permalink to this headline"></a></h3> <span id="thread-i-specify-the-collecting-interval"></span><h3>thread -i specify the collecting interval<a class="headerlink" href="#thread-i-specify-the-collecting-interval" title="Permalink to this headline"></a></h3>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ thread -n <span class="m">3</span> -i <span class="m">1000</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ thread -n <span class="m">3</span> -i <span class="m">1000</span>
<span class="s2">&quot;as-command-execute-daemon&quot;</span> <span class="nv">Id</span><span class="o">=</span><span class="m">4759</span> <span class="nv">cpuUsage</span><span class="o">=</span><span class="m">23</span>% RUNNABLE <span class="s2">&quot;as-command-execute-daemon&quot;</span> <span class="nv">Id</span><span class="o">=</span><span class="m">4759</span> <span class="nv">cpuUsage</span><span class="o">=</span><span class="m">23</span>% RUNNABLE
at sun.management.ThreadImpl.dumpThreads0<span class="o">(</span>Native Method<span class="o">)</span> at sun.management.ThreadImpl.dumpThreads0<span class="o">(</span>Native Method<span class="o">)</span>
at sun.management.ThreadImpl.getThreadInfo<span class="o">(</span>ThreadImpl.java:440<span class="o">)</span> at sun.management.ThreadImpl.getThreadInfo<span class="o">(</span>ThreadImpl.java:440<span class="o">)</span>

@ -325,7 +325,7 @@ Affect(row-cnt:1) cost in 190 ms.
</pre></div> </pre></div>
</div> </div>
<p>反编译指定的方法:</p> <p>反编译指定的方法:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ jad com.taobao.container.web.arthas.rest.MetricsController directMetrics <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ jad com.taobao.container.web.arthas.rest.MetricsController directMetrics
ClassLoader: ClassLoader:
+-com.taobao.pandora.boot.loader.ReLaunchURLClassLoader@1817d444 +-com.taobao.pandora.boot.loader.ReLaunchURLClassLoader@1817d444

@ -194,7 +194,7 @@
<ul class="simple"> <ul class="simple">
<li>默认情况下,该功能是关闭的,如果需要开启,请执行以下命令:</li> <li>默认情况下,该功能是关闭的,如果需要开启,请执行以下命令:</li>
</ul> </ul>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ options save-result <span class="nb">true</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ options save-result <span class="nb">true</span>
NAME BEFORE-VALUE AFTER-VALUE NAME BEFORE-VALUE AFTER-VALUE
---------------------------------------- ----------------------------------------
save-result <span class="nb">false</span> <span class="nb">true</span> save-result <span class="nb">false</span> <span class="nb">true</span>
@ -208,7 +208,7 @@ Affect<span class="o">(</span>row-cnt:1<span class="o">)</span> cost in <span cl
<p>结果会异步保存在:<code class="docutils literal notranslate"><span class="pre">{user.home}/logs/arthas-cache/result.log</span></code>,请定期进行清理,以免占据磁盘空间</p> <p>结果会异步保存在:<code class="docutils literal notranslate"><span class="pre">{user.home}/logs/arthas-cache/result.log</span></code>,请定期进行清理,以免占据磁盘空间</p>
<div class="section" id="arthas"> <div class="section" id="arthas">
<span id="arthas"></span><h2>使用新版本Arthas的异步后台任务将结果存日志文件<a class="headerlink" href="#arthas" title="永久链接至标题"></a></h2> <span id="arthas"></span><h2>使用新版本Arthas的异步后台任务将结果存日志文件<a class="headerlink" href="#arthas" title="永久链接至标题"></a></h2>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ trace Test t &gt;&gt; <span class="p">&amp;</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ trace Test t &gt;&gt; <span class="p">&amp;</span>
job id : <span class="m">2</span> job id : <span class="m">2</span>
cache location : /Users/zhuyong/logs/arthas-cache/28198/2 cache location : /Users/zhuyong/logs/arthas-cache/28198/2
</pre></div> </pre></div>

@ -267,7 +267,7 @@ org.apache.catalina.connector.Connector-&gt;getMaxCookieCount
... ...
</pre></div> </pre></div>
</div> </div>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ sm org.apache.catalina.connector.Connector -d <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ sm org.apache.catalina.connector.Connector -d
declaring-class org.apache.catalina.connector.Connector declaring-class org.apache.catalina.connector.Connector
constructor-name &lt;init&gt; constructor-name &lt;init&gt;
modifier public modifier public

@ -170,7 +170,7 @@
<div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>./as.sh <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>./as.sh
</pre></div> </pre></div>
</div> </div>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>➜ bin git:<span class="o">(</span>develop<span class="o">)</span> ✗ ./as.sh <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>➜ bin git:<span class="o">(</span>develop<span class="o">)</span> ✗ ./as.sh
Found existing java process, please choose one and hit RETURN. Found existing java process, please choose one and hit RETURN.
<span class="o">[</span><span class="m">1</span><span class="o">]</span>: <span class="m">3088</span> org.jetbrains.idea.maven.server.RemoteMavenServer <span class="o">[</span><span class="m">1</span><span class="o">]</span>: <span class="m">3088</span> org.jetbrains.idea.maven.server.RemoteMavenServer
* <span class="o">[</span><span class="m">2</span><span class="o">]</span>: <span class="m">12872</span> org.apache.catalina.startup.Bootstrap * <span class="o">[</span><span class="m">2</span><span class="o">]</span>: <span class="m">12872</span> org.apache.catalina.startup.Bootstrap

@ -311,7 +311,7 @@ ID NAME GROUP PRIORITY STA
<div class="section" id="thread-b"> <div class="section" id="thread-b">
<span id="thread-b"></span><h3>thread -b, 找出当前阻塞其他线程的线程<a class="headerlink" href="#thread-b" title="永久链接至标题"></a></h3> <span id="thread-b"></span><h3>thread -b, 找出当前阻塞其他线程的线程<a class="headerlink" href="#thread-b" title="永久链接至标题"></a></h3>
<p>有时候我们发现应用卡住了, 通常是由于某个线程拿住了某个锁, 并且其他线程都在等待这把锁造成的。 为了排查这类问题, arthas提供了<code class="docutils literal notranslate"><span class="pre">thread</span> <span class="pre">-b</span></code> 一键找出那个罪魁祸首。</p> <p>有时候我们发现应用卡住了, 通常是由于某个线程拿住了某个锁, 并且其他线程都在等待这把锁造成的。 为了排查这类问题, arthas提供了<code class="docutils literal notranslate"><span class="pre">thread</span> <span class="pre">-b</span></code> 一键找出那个罪魁祸首。</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ thread -b <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ thread -b
<span class="s2">&quot;http-bio-8080-exec-4&quot;</span> <span class="nv">Id</span><span class="o">=</span><span class="m">27</span> TIMED_WAITING <span class="s2">&quot;http-bio-8080-exec-4&quot;</span> <span class="nv">Id</span><span class="o">=</span><span class="m">27</span> TIMED_WAITING
at java.lang.Thread.sleep<span class="o">(</span>Native Method<span class="o">)</span> at java.lang.Thread.sleep<span class="o">(</span>Native Method<span class="o">)</span>
at test.arthas.TestThreadBlocking.doGet<span class="o">(</span>TestThreadBlocking.java:22<span class="o">)</span> at test.arthas.TestThreadBlocking.doGet<span class="o">(</span>TestThreadBlocking.java:22<span class="o">)</span>
@ -354,7 +354,7 @@ ID NAME GROUP PRIORITY STA
</div> </div>
<div class="section" id="thread-i"> <div class="section" id="thread-i">
<span id="thread-i"></span><h3>thread -i, 指定采样时间间隔<a class="headerlink" href="#thread-i" title="永久链接至标题"></a></h3> <span id="thread-i"></span><h3>thread -i, 指定采样时间间隔<a class="headerlink" href="#thread-i" title="永久链接至标题"></a></h3>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ thread -n <span class="m">3</span> -i <span class="m">1000</span> <div class="highlight-bash notranslate"><div class="highlight"><pre><span></span>$ thread -n <span class="m">3</span> -i <span class="m">1000</span>
<span class="s2">&quot;as-command-execute-daemon&quot;</span> <span class="nv">Id</span><span class="o">=</span><span class="m">4759</span> <span class="nv">cpuUsage</span><span class="o">=</span><span class="m">23</span>% RUNNABLE <span class="s2">&quot;as-command-execute-daemon&quot;</span> <span class="nv">Id</span><span class="o">=</span><span class="m">4759</span> <span class="nv">cpuUsage</span><span class="o">=</span><span class="m">23</span>% RUNNABLE
at sun.management.ThreadImpl.dumpThreads0<span class="o">(</span>Native Method<span class="o">)</span> at sun.management.ThreadImpl.dumpThreads0<span class="o">(</span>Native Method<span class="o">)</span>
at sun.management.ThreadImpl.getThreadInfo<span class="o">(</span>ThreadImpl.java:440<span class="o">)</span> at sun.management.ThreadImpl.getThreadInfo<span class="o">(</span>ThreadImpl.java:440<span class="o">)</span>

Loading…
Cancel
Save