arthas是阿里开源的java监控和调试工具
Arthas 是基于 Greys 进行二次开发的全新在线诊断工具,利用Java6的Instrumentation特性,
动态增强你所指定的类,获取你想要到的信息, 采用命令行交互模式,同时提供丰富的 Tab 自动补全功能,
让你在定位、分析诊断问题时看每一个操作都看起来是强大
doc --> https://alibaba.github.io/arthas/
code --> https://github.com/alibaba/arthas/releases/tag/arthas-all-3.0.5
arthas 3.0.5
https://github.com/alibaba/arthas/releases/download/arthas-all-3.0.5/arthas-3.0.5-bin.zip
the orginal startup command is not ok for me. So I write my own one.
step1:
extract arthas-3.0.5-bin.zip, and get those files
step2:
run_demo.bat ( for win)
set JAVA_HOME=C:/Progra~1/Java/jdk1.8.0_66
%JAVA_HOME%/bin/java -jar arthas-demo.jar
run.bat( for win)
set JAVA_HOME=C:/Progra~1/Java/jdk1.8.0_66
%JAVA_HOME%/bin/jps -m
set as_h=.
set as_pid=???
set as_ip=127.0.0.1
set as_telnet_port=13658
set as_http_port=18563
%JAVA_HOME%/bin/java -Dfile.encoding=UTF-8 -Xbootclasspath/a:%JAVA_HOME%\lib\tools.jar -jar arthas-core.jar -pid "%as_pid%" -target-ip %as_ip% -telnet-port %as_telnet_port% -http-port %as_http_port% -core arthas-core.jar -agent arthas-agent.ja
pause
??? is demo appliation PID, it comes from jps command. See red. it is 2248
if you want remote, please set as_ip as the pc ip, which run run.bat. Here I use 127.0.0, I just use it in local development pc.
run_demo.sh ( for linux)
? add later
run.sh ( for linux)
? add later
step3:
execute run_demo.bat to start a demo for test
execute run.bat to attach Arthas to demo PID
step4:
connect by telnet
connect by web console
http://localhost:18563/
sc demo*
sc demo* // search class by name, for example it will be demo.MathGame
sc -d demo.MathGame // it will list all info of this class
sm -d demo.MathGame // list all methods of this class
trace demo.MathGame * // statck of method call, here it is *, means all methods
monitor demo.MathGame * // method calling statistic
it is slow, not show result immediately, wait a while
watch demo.MathGame primeFactors '{params[0],returnObj}' // params[0] is the first input parameter of this method, returnObj means return value of this method.