Arthas基础命令实战
⼀点睛
quit/exit 退出当前 Arthas客户端,其他 Arthas喜户端不受影响
stop/shutdown 关闭 Arthas服务端,所有 Arthas客户端全部退出
help 查看命令帮助信息
cat 打印⽂件内容,和l inux ⾥的 cat 命令类似
echo 打印参数,和 linux ⾥的 echo 命令类似
grep 匹配查,和 linux ⾥的 grep 命令类似
tee 复制标⾫输⼊到标准输出和指定的⽂件,和 linux ⾥的 tee 命令类似
pwd 返回当前的⼯作⽬录,和 linux 命令类似
cls 清空当前屏幕区域
session 查看当前会话的信息
reset 重置增强类,将被 Arthas 增强过的类全部还原, Arthas 服务端关闭时会重置所有增强过的类version 输出当前⽬标 Java 进程所加载的 Arthas 版本号
history 打印命令历史
keymap Arthas 快捷键列表及⾃定义快捷键
⼆代码
package chapter03;
import java.util.ArrayList;
console命令大全import urrent.TimeUnit;
public class JProfilerTest {
public static void main(String[] args) {
while (true){
ArrayList list = new ArrayList();
for (int i = 0; i < 500; i++) {
Data data = new Data();
list.add(data);
}
try {
TimeUnit.MILLISECONDS.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
class Data{
private int size = 10;
private byte[] buffer = new byte[1024*1024]; // 1 mb
private String info = "hello,China";
}
三 windows下进⼊命令界⾯
D:\ProgramFiles\arthas-packaging-3.5.4-bin>jps
10656 Jps
12736 Launcher
2864
10668 JProfilerTest
D:\ProgramFiles\arthas-packaging-3.5.4-bin>as.bat 10668
环境变量 JAVA_TOOL_OPTIONS 没有定义
JAVA_HOME: D:\ProgramFiles\Java\jdk1.8.0_251
telnet port: 3658
http port: 8563
信息: ⽤提供的模式⽆法到⽂件。
telnet wasn't found, please google how to install telnet under windows.
Try to visit 127.0.0.1:8563 to connecto arthas server.
四实战
,
---. ,------. ,--------.,--. ,--. ,---. ,---.
/ O \ | .--. ''--. .--'| '--' | / O \ ' .-'
| .-. || '--'.' | | | .--. || .-. |`. `-.
| | | || |\ \ | | | | | || | | |.-' |
`--' `--'`--' '--' `--' `--' `--'`--' `--'`-----'
wiki arthas.aliyun/doc
tutorials arthas.aliyun/doc/arthas-tutorials.html
version 3.5.4
main_class
pid 10668
time 2021-09-04 08:53:08
# 帮助命令
[arthas@10668]$ help
NAME DESCRIPTION
help Display Arthas Help
auth Authenticates the current session
keymap Display all the available keymap for the specified connection.
sc Search all the classes loaded by JVM
sm Search the method of classes loaded by JVM
classloader Show classloader info
jad Decompile class
getstatic Show the static field of a class
monitor Monitor method execution statistics, e.g. total/success/failure count, average rt, fail rate, etc.
stack Display the stack trace for the specified class and method
thread Display thread info, thread stack
trace Trace the execution time of specified method invocation.
watch Display the input/output parameter, return object, and thrown exception of specified method invocation tt Time Tunnel
jvm Display the target JVM information
perfcounter Display the perf counter information.
ognl Execute ognl expression.
mc Memory compiler, compiles java files into bytecode and class files in memory.
redefine Redefine classes. @see Instrumentation#)
retransform Retransform classes. @see Instrumentation#)
dashboard Overview of target jvm's thread, memory, gc, vm, tomcat info.
dump Dump class byte array from JVM
heapdump Heap dump
options View and change various Arthas options
cls Clear the screen
reset Reset all the enhanced classes
version Display Arthas version
session Display current session information
session Display current session information
sysprop Display, and change the system properties.
sysenv Display the system env.
vmoption Display, and update the vm diagnostic options.
logger Print logger info, and update the logger level
history Display command history
cat Concatenate and print files
base64 Encode and decode using Base64 representation
echo write arguments to the standard output
pwd Return working directory name
mbean Display the mbean information
grep grep command for pipes.
tee tee command for pipes.
profiler Async Profiler. github/jvm-profiling-tools/async-profiler
vmtool jvm tool
stop Stop/Shutdown Arthas server and exit the console.
# 具体某个命令的帮助
[arthas@10668]$ reset -h
USAGE:
reset [-h] [-E] [class-pattern]
SUMMARY:
Reset all the enhanced classes
EXAMPLES:
reset
reset *List
reset -E .*List
OPTIONS:
-h, --help this help
-E, --regex Enable regular expression to match (wildcard matching by default) <class-pattern> Path and classname of Pattern Matching
# cat命令
[arthas@10668]$ cat E:/JVMDemo3/src/chapter03/Stack.java
package chapter03;
import java.util.Arrays;
import java.util.EmptyStackException;
public class Stack {
private Object[] elements;
private int size = 0;
private static final int DEFAULT_INITIAL_CAPACITY = 16;
public Stack() {
elements = new Object[DEFAULT_INITIAL_CAPACITY];
}
public void push(Object e) { // ⼊栈
ensureCapacity();
elements[size++] = e;
}
// 隐式内存泄露代码
public Object pop() { // 出栈
if (size == 0)
throw new EmptyStackException();
return elements[--size];
}
private void ensureCapacity() {
if (elements.length == size)
elements = pyOf(elements, 2 * size + 1);
elements = pyOf(elements, 2 * size + 1);
}
}
# pwd 命令
[arthas@10668]$ pwd
E:\JVMDemo3
# cls 清屏
[arthas@10668]$ cls
# session 会话
[arthas@10668]$ session
Name Value
--------------------------------------------------
JAVA_PID 10668
SESSION_ID 5b10ecf4-c0f3-4453-8fbd-42a5c0337e8e
# version 版本号
[arthas@10668]$ version
3.5.4
# history 查看历史命令
[arthas@10668]$ history
1 help
2 dashboard -n 2
3 help
4 reset -h
5 pwd
6 ll
7 ls
8 dir
9 cd src
10 cat E:\JVMDemo3\src\chapter03\Stack.java
11 cat E:/JVMDemo3/src/chapter03/Stack.java
12 pwd
13 cls
14 session
15 version
16 history
# stop 关闭服务端和所有客户端
[arthas@10668]$ stop
Resetting all enhanced classes ...
Affect(class count: 0 , method count: 0) cost in 2 ms, listenerId: 0
Arthas Server is going
[arthas@10668]$ session (5b10ecf4-c0f3-4453-8fbd-42a5c0337e8e) is closed because server is going to shutdown.
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论