1、在目标监控进程(要查看该进程popularity中某个方法的性能) ,配置远程调试
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000
2、在arthas 中远程连接上要监控的进程的远程调试,配置如下的连接
127.0.0.1 8000
3、在arthas的控制台中,起动监听进程
as.bat pid 连接上去(pid为popularity 进程的本地进程id)
4、 arthas 源码中自动就会可以远程调用arthas的源码了。
5、使用如下命令进行验证
options save-result true --保存结果
options dump true --把监控的类dum出class文件,然后通过反编译文件进行查看
options json-format true --把控制台输出的方法结果json化
$ watch com.test.mobile.popularity.service.cache.PopularityRankCache getCurNotFinishDay "{params,returnObj}" -x 2 -b --起动监控,输出如下
$ watch com.test.mobile.popularity.service.cache.PopularityRankCache getCurNot
FinishDay "{params,returnObj}" -x 2 -b
Press Ctrl+C to abort.
[dump: G:\workspace\testweb\popularity\mobile-popularity\mobile-popularity-app\.\a
rth