<liclass="toctree-l1"><aclass="reference external"href="https://github.com/alibaba/arthas/issues?q=label%3Aquestion-answered">Questions and answers</a></li>
<liclass="toctree-l1"><aclass="reference external"href="https://github.com/alibaba/arthas">Fork me at GitHub</a></li>
<liclass="toctree-l1"><aclass="reference external"href="https://github.com/alibaba/arthas/blob/master/CONTRIBUTING.md#">Compile and debug/CONTRIBUTING</a></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">execTimeout</span></code> : Timeout for executing commands (ms), default value is 30000.</p></li>
</ul>
<p>Note: Different actions use different parameters. Set the parameters
according to the specific action.</p>
</div>
<divclass="section"id="request-actions">
<h3>Request Actions<aclass="headerlink"href="#request-actions"title="Permalink to this headline">¶</a></h3>
<p>Currently supported request actions are as follows:</p>
<ulclass="simple">
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">exec</span></code> : The command is executed synchronously, and the command
results is returned after the command execution end or interrupted.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">async_exec</span></code> : The command is executed asynchronously, and the
scheduling result of the command is returned immediately. The command
execution result is obtained through <codeclass="docutils literal notranslate"><spanclass="pre">pull_results</span></code> action.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">interrupt_job</span></code> : To interrupt the foreground command of the session,
similar to the function of Telnet <codeclass="docutils literal notranslate"><spanclass="pre">Ctrl</span><spanclass="pre">+</span><spanclass="pre">c</span></code>.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">pull_results</span></code> : Get the result of the command executed
asynchronously, and execute it repeatedly in http long-polling mode.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">init_session</span></code> : Create new session.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">join_session</span></code> : Join the session, used to support multiple people
sharing the same Arthas session.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">close_session</span></code> : Close the session.</p></li>
</ul>
</div>
<divclass="section"id="response-status">
<h3>Response status<aclass="headerlink"href="#response-status"title="Permalink to this headline">¶</a></h3>
<p>The state attribute in the response indicates the request processing
state, and its value is as follows:</p>
<ulclass="simple">
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">SCHEDULED</span></code>: When the command is executed asynchronously, it means that
the job has been created, and may not be executed yet or is being
executed;</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">SUCCEEDED</span></code>: The request is processed successfully (completed status);</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">FAILED</span></code>: Request processing failed (completed status), usually
accompanied by a message explaining the reason;</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">REFUSED</span></code>: The request is rejected (completed status), usually
accompanied by a message explaining the reason;</p></li>
</ul>
</div>
</div>
<divclass="section"id="one-time-command">
<h2>One-time command<aclass="headerlink"href="#one-time-command"title="Permalink to this headline">¶</a></h2>
<p>Similar to executing batch commands, the one-time commands are executed
synchronously. No need to create a session, no need to set the
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">jobId</span></code> : The job ID of the command.</p></li>
<li><p>Other fields are the data of each different command.</p></li>
</ul>
<p>Note: You can also use a one-time command to execute continuous output
commands such as watch/trace, but you can’t interrupt the command
execution, and there may be hang up for a long time. Please refer to the
example in the
“<aclass="reference external"href="#change_watch_value_to_map">Make watch command output a map object</a>”
section.</p>
<p>Please try to deal with it in the following way:</p>
<ulclass="simple">
<li><p>Set a reasonable <codeclass="docutils literal notranslate"><spanclass="pre">execTimeout</span></code> to forcibly interrupt the command
execution after the timeout period is reached to avoid a long hang.</p></li>
<li><p>Use the <codeclass="docutils literal notranslate"><spanclass="pre">-n</span></code> parameter to specify a smaller number of executions.</p></li>
<li><p>Ensure the methods of the command matched can be successfully hit and
the <codeclass="docutils literal notranslate"><spanclass="pre">condition-express</span></code> is written correctly. If the <codeclass="docutils literal notranslate"><spanclass="pre">watch/trace</span></code> does
not hit, even if <codeclass="docutils literal notranslate"><spanclass="pre">-n</span><spanclass="pre">1</span></code> is specified, it will hang and wait until the
execution timeout.</p></li>
</ul>
</div>
<divclass="section"id="session-interaction">
<h2>Session interaction<aclass="headerlink"href="#session-interaction"title="Permalink to this headline">¶</a></h2>
<p>Users create and manage Arthas sessions, which are suitable for complex
interactive processes. The access process is as follows:</p>
<ulclass="simple">
<li><p>Create a session</p></li>
<li><p>Join the session (optional)</p></li>
<li><p>Pull command results</p></li>
<li><p>Execute a series of commands</p></li>
<li><p>Interrupt command execution</p></li>
<li><p>Close the session</p></li>
</ul>
<divclass="section"id="create-session">
<h3>Create session<aclass="headerlink"href="#create-session"title="Permalink to this headline">¶</a></h3>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">state</span></code> : The status of <codeclass="docutils literal notranslate"><spanclass="pre">SCHEDULED</span></code> means that the command has been
parsed and generated the job, but the execution has not started.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">body.jobId</span></code> : The job id of command execution, filter the command
results output in <codeclass="docutils literal notranslate"><spanclass="pre">pull_results</span></code> according to this job ID.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">body.jobStatus</span></code> : The job status <codeclass="docutils literal notranslate"><spanclass="pre">READY</span></code> means that execution has not started.</p></li>
</ul>
<p>The shell output of the script that continuously pulls the result message:</p>
<p>The <codeclass="docutils literal notranslate"><spanclass="pre">value</span></code> of the watch command result is the value of watch-experss,
and the above command is <codeclass="docutils literal notranslate"><spanclass="pre">{params,</span><spanclass="pre">returnObj,</span><spanclass="pre">throwExp}</span></code>, so the value
of the watch result is an array of length 3, and each element
corresponds to the expression in the corresponding order.</p>
<p>Please refer to the section “<aclass="reference external"href="#change_watch_value_to_map">Make watch command output a map object</a>”.</p>
<p><codeclass="docutils literal notranslate"><spanclass="pre">type</span></code> is <codeclass="docutils literal notranslate"><spanclass="pre">status</span></code> to indicate the command execution status:</p>
<p>After each command is executed, there is a unique status result. If the
<codeclass="docutils literal notranslate"><spanclass="pre">statusCode</span></code> is 0, it means the execution is successful, and the
<codeclass="docutils literal notranslate"><spanclass="pre">statusCode</span></code> is a non-zero value that means the execution failed,
similar to the process exit code.</p>
<p>When the command execution fails, an error message is generally provided, such as:</p>
<p><codeclass="docutils literal notranslate"><spanclass="pre">type</span></code> is <codeclass="docutils literal notranslate"><spanclass="pre">command</span></code> to indicate the input command data:</p>
<p>It is used for the interactive UI to echo the commands entered by the
user. The pulled session command message history will contain messages
of type <codeclass="docutils literal notranslate"><spanclass="pre">command</span></code>, which can be processed in order.</p>
</div>
<divclass="section"id="enhancer">
<h3>enhancer<aclass="headerlink"href="#enhancer"title="Permalink to this headline">¶</a></h3>
<p><codeclass="docutils literal notranslate"><spanclass="pre">type</span></code> is <codeclass="docutils literal notranslate"><spanclass="pre">enhancer</span></code> to indicate the result of class enhancement:</p>
<p>Commands such as <codeclass="docutils literal notranslate"><spanclass="pre">trace/watch/jad/tt</span></code> need to enhance the class and will
receive this <codeclass="docutils literal notranslate"><spanclass="pre">enhancer</span></code> result. It may happen that the result of
<codeclass="docutils literal notranslate"><spanclass="pre">enhancer</span></code> is successful, but there is no hit method. The client can
prompt the user according to the result of <codeclass="docutils literal notranslate"><spanclass="pre">enhancer</span></code>.</p>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">echo</span><spanclass="pre">$json_data</span><spanclass="pre">|</span><spanclass="pre">tr</span><spanclass="pre">-d</span><spanclass="pre">'\n'</span></code> : Delete line breaks (the value of
<codeclass="docutils literal notranslate"><spanclass="pre">line.separator</span></code>) to avoid affecting the processing of <codeclass="docutils literal notranslate"><spanclass="pre">sed</span></code>/<codeclass="docutils literal notranslate"><spanclass="pre">json_pp</span></code>
commands.</p></li>
<li><p><codeclass="docutils literal notranslate"><spanclass="pre">awk</span><spanclass="pre">-F'"'</span><spanclass="pre">'{</span><spanclass="pre">print</span><spanclass="pre">$4</span><spanclass="pre">}'</span></code> : Use double quote as delimiter</p></li>
<h3>Make watch command output a map object<aclass="headerlink"href="#make-watch-command-output-a-map-object"title="Permalink to this headline">¶</a></h3>
<p>The result value of <codeclass="docutils literal notranslate"><spanclass="pre">watch</span></code> is generated by calculating the
<codeclass="docutils literal notranslate"><spanclass="pre">watch-express</span></code> ognl expression. You can change the ognl expression to
Built with <ahref="http://sphinx-doc.org/">Sphinx</a> using a <ahref="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<scripttype="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
<divclass="github-fork-ribbon-wrapper right">
<divclass="github-fork-ribbon">
<ahref="https://github.com/alibaba/arthas"target="_blank">Fork me at GitHub</a>