mirror of
https://github.com/alibaba/arthas.git
synced 2026-10-23 02:31:10 +00:00
Arthas tee 命令教程 (#1322)
* add tee command scenario. #847 Signed-off-by: hollowman6 <hollowman186@vip.qq.com> * fix link typo Signed-off-by: hollowman6 <hollowman186@vip.qq.com> * add tee details to documents Signed-off-by: hollowman6 <hollowman186@vip.qq.com> * polish tee command scenario. #847 Signed-off-by: hollowman6 <hollowman186@vip.qq.com>
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
tee
|
||||
===
|
||||
|
||||
> Similar to the traditional `tee` command.
|
||||
[`tee` online tutorial](https://alibaba.github.io/arthas/arthas-tutorials?language=en&id=command-tee)
|
||||
|
||||
> Similar to the traditional `tee` command, it is used to read standard input data and output its contents into a file.
|
||||
|
||||
> `tee` will read data from standard input device, output its content to standard output device, and save it as a file.
|
||||
|
||||
|
||||
```
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
tee
|
||||
===
|
||||
|
||||
> 类似传统的`tee`命令。
|
||||
[`tee`在线教程](https://alibaba.github.io/arthas/arthas-tutorials?language=cn&id=command-tee)
|
||||
|
||||
> 类似传统的`tee`命令, 用于读取标准输入的数据,并将其内容输出成文件。
|
||||
|
||||
> tee指令会从标准输入设备读取数据,将其内容输出到标准输出设备,同时保存成文件。
|
||||
|
||||
|
||||
```
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
|
||||
|
||||
|
||||
在新的`Terminal 2`里,下载`arthas-boot.jar`,再用`java -jar`命令启动:
|
||||
|
||||
`wget https://alibaba.github.io/arthas/arthas-boot.jar
|
||||
java -jar arthas-boot.jar --target-ip 0.0.0.0`{{execute T2}}
|
||||
|
||||
`arthas-boot`是`Arthas`的启动程序,它启动后,会列出所有的Java进程,用户可以选择需要诊断的目标进程。
|
||||
|
||||
选择第一个进程,输入 `1`{{execute T2}} ,再`Enter/回车`:
|
||||
|
||||
Attach成功之后,会打印Arthas LOGO。输入 `help`{{execute T2}} 可以获取到更多的帮助信息。
|
||||
|
||||

|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
|
||||
|
||||
|
||||
下载`arthas-demo.jar`,再用`java -jar`命令启动:
|
||||
|
||||
`wget https://alibaba.github.io/arthas/arthas-demo.jar
|
||||
java -jar arthas-demo.jar`{{execute T1}}
|
||||
|
||||
`arthas-demo`是一个很简单的程序,它随机生成整数,再执行因式分解,把结果打印出来。如果生成的随机数是负数,则会打印提示信息。
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
通过本教程基本掌握了Arthas tee的用法。更多高级特性,可以在下面的进阶指南里继续了解。
|
||||
|
||||
* [Arthas进阶](https://alibaba.github.io/arthas/arthas-tutorials?language=cn&id=arthas-advanced)
|
||||
* [Arthas Github](https://github.com/alibaba/arthas)
|
||||
* [Arthas 文档](https://alibaba.github.io/arthas/)
|
||||
|
||||
欢迎关注公众号,获取Arthas项目的信息,源码分析,案例实践。
|
||||
|
||||

|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"title": "Arthas tee命令教程",
|
||||
"description": "Arthas tee命令教程",
|
||||
"details": {
|
||||
"steps": [
|
||||
{
|
||||
"title": "启动arthas-demo",
|
||||
"text": "arthas-demo.md"
|
||||
},
|
||||
{
|
||||
"title": "启动arthas-boot",
|
||||
"text": "arthas-boot.md"
|
||||
},
|
||||
{
|
||||
"title": "tee 命令",
|
||||
"text": "tee.md"
|
||||
}
|
||||
],
|
||||
"intro": {
|
||||
"text": "intro.md"
|
||||
},
|
||||
"finish": {
|
||||
"text": "finish.md"
|
||||
}
|
||||
},
|
||||
"environment": {
|
||||
"uilayout": "terminal"
|
||||
},
|
||||
"backend": {
|
||||
"imageid": "java",
|
||||
"environmentsprotocol": "http"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
`Arthas` 是Alibaba开源的Java诊断工具,深受开发者喜爱。在线排查问题,无需重启;动态跟踪Java代码;实时监控JVM状态。
|
||||
|
||||
`Arthas` 支持JDK 6+,支持Linux/Mac/Windows,采用命令行交互模式,同时提供丰富的 `Tab` 自动补全功能,进一步方便进行问题的定位和诊断。
|
||||
|
||||
* Github: https://github.com/alibaba/arthas
|
||||
* 文档: https://alibaba.github.io/arthas/
|
||||
@@ -0,0 +1,44 @@
|
||||
|
||||
类似传统的`tee`命令 用于读取标准输入的数据,并将其内容输出成文件。
|
||||
|
||||
tee指令会从标准输入设备读取数据,将其内容输出到标准输出设备,同时保存成文件。
|
||||
|
||||
`tee -h`{{execute T2}}
|
||||
|
||||
```bash
|
||||
USAGE:
|
||||
tee [-a] [-h] [file]
|
||||
|
||||
SUMMARY:
|
||||
tee command for pipes.
|
||||
|
||||
EXAMPLES:
|
||||
sysprop | tee /path/to/logfile | grep java
|
||||
sysprop | tee -a /path/to/logfile | grep java
|
||||
|
||||
WIKI:
|
||||
https://alibaba.github.io/arthas/tee
|
||||
|
||||
OPTIONS:
|
||||
-a, --append Append to file
|
||||
-h, --help this help
|
||||
<file> File path
|
||||
```
|
||||
|
||||
## 命令示范
|
||||
|
||||
### 将sysprop命令执行结果另外存储在`/tmp/logfile`中
|
||||
|
||||
`sysprop | tee /tmp/logfile`{{execute T2}}
|
||||
|
||||
查看`/tmp/logfile`文件:
|
||||
|
||||
`cat /tmp/logfile`{{execute T2}}
|
||||
|
||||
### 将sysprop命令执行结果匹配`java`后另外追加在`/tmp/logfile`中
|
||||
|
||||
`sysprop | grep java | tee -a /path/to/logfile`{{execute T2}}
|
||||
|
||||
查看`/tmp/logfile`文件:
|
||||
|
||||
`cat /tmp/logfile`{{execute T2}}
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
|
||||
|
||||
In the new `Terminal 2`, download `arthas-boot.jar` and start with the `java -jar` command:
|
||||
|
||||
`wget https://alibaba.github.io/arthas/arthas-boot.jar
|
||||
java -jar arthas-boot.jar --target-ip 0.0.0.0`{{execute T2}}
|
||||
|
||||
`arthas-boot` is the launcher for `Arthas`. It lists all the Java processes, and the user can select the target process to be diagnosed.
|
||||
|
||||
Select the first process, type `1`{{execute T2}} ,then type `Enter`:
|
||||
|
||||
After the Attach is successful, Arthas LOGO is printed. Enter `help`{{execute T2}} for more help.
|
||||
|
||||

|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
|
||||
|
||||
|
||||
Download `arthas-demo.jar` and start with the `java -jar` command:
|
||||
|
||||
`wget https://alibaba.github.io/arthas/arthas-demo.jar
|
||||
java -jar arthas-demo.jar`{{execute T1}}
|
||||
|
||||
`arthas-demo` is a very simple program that randomly generates integers, performs factorization, and prints the results.
|
||||
If the generated random number is negative, a error message will be printed.
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
Through this tutorial, you can know how to use Arthas `tee`. More advanced features can be found in the Advanced Guide below.
|
||||
|
||||
* [Arthas Advanced](https://alibaba.github.io/arthas/arthas-tutorials?language=en&id=arthas-advanced)
|
||||
* [Arthas Github](https://github.com/alibaba/arthas)
|
||||
* [Arthas Documentation](https://alibaba.github.io/arthas/en)
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"title": "Arthas tee",
|
||||
"description": "Arthas tee",
|
||||
"details": {
|
||||
"steps": [
|
||||
{
|
||||
"title": "Start arthas-demo",
|
||||
"text": "arthas-demo.md"
|
||||
},
|
||||
{
|
||||
"title": "Start arthas-boot",
|
||||
"text": "arthas-boot.md"
|
||||
},
|
||||
{
|
||||
"title": "tee command",
|
||||
"text": "tee.md"
|
||||
}
|
||||
],
|
||||
"intro": {
|
||||
"text": "intro.md"
|
||||
},
|
||||
"finish": {
|
||||
"text": "finish.md"
|
||||
}
|
||||
},
|
||||
"environment": {
|
||||
"uilayout": "terminal"
|
||||
},
|
||||
"backend": {
|
||||
"imageid": "java",
|
||||
"environmentsprotocol": "http"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
`Arthas` is a Java diagnostic tool open-sourced by Alibaba middleware team. Arthas helps developers in trouble-shooting issues in production environment for Java based applications without modifying code or restarting servers.
|
||||
|
||||
`Arthas` supports JDK 6+, supports Linux/Mac/Windows.
|
||||
|
||||
* Github: https://github.com/alibaba/arthas
|
||||
* Documentation: https://alibaba.github.io/arthas/en
|
||||
@@ -0,0 +1,44 @@
|
||||
|
||||
Similar to the traditional `tee` command, it is used to read standard input data and output its contents into a file.
|
||||
|
||||
`tee` will read data from standard input device, output its content to standard output device, and save it as a file.
|
||||
|
||||
`tee -h`{{execute T2}}
|
||||
|
||||
```bash
|
||||
USAGE:
|
||||
tee [-a] [-h] [file]
|
||||
|
||||
SUMMARY:
|
||||
tee command for pipes.
|
||||
|
||||
EXAMPLES:
|
||||
sysprop | tee /path/to/logfile | grep java
|
||||
sysprop | tee -a /path/to/logfile | grep java
|
||||
|
||||
WIKI:
|
||||
https://alibaba.github.io/arthas/tee
|
||||
|
||||
OPTIONS:
|
||||
-a, --append Append to file
|
||||
-h, --help this help
|
||||
<file> File path
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Store sysprop execution result into `/tmp/logfile`
|
||||
|
||||
`sysprop | tee /tmp/logfile`{{execute T2}}
|
||||
|
||||
Check `/tmp/logfile`:
|
||||
|
||||
`cat /tmp/logfile`{{execute T2}}
|
||||
|
||||
### Append sysprop matching `java` result into `/tmp/logfile`
|
||||
|
||||
`sysprop | grep java | tee -a /path/to/logfile`{{execute T2}}
|
||||
|
||||
Check `/tmp/logfile`:
|
||||
|
||||
`cat /tmp/logfile`{{execute T2}}
|
||||
Reference in New Issue
Block a user