Welcome everyone

Arthas 初使用

java 汪明鑫 704浏览 0评论

Arthas 是阿里整的一套采用命令行的线上问题排查工具

详情可见 https://alibaba.github.io/arthas/install-detail.html

快速安装

[root@xinyeshuaiqi ~]# curl -O https://alibaba.github.io/arthas/arthas-boot.jar
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  135k  100  135k    0     0  16721      0  0:00:08  0:00:08 --:--:-- 12728

 

启动Arthas

[root@xinyeshuaiqi ~]# java -jar arthas-boot.jar
[INFO] arthas-boot version: 3.3.3
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 19141 learningcenter-0.0.1-SNAPSHOT.jar
  [2]: 12312 push-yuque-rest.jar

选1 (是我刚起的一个服务)

 

 

dashboard当前系统数据实时面板

control + c 中断

 

monitor 监控这个方法的调用情况   -c指定采样时间

 

trace 可以看到调用链路和耗时

monitor、trace等 这些命令,都是通过字节码增强技术来实现的,会在指定类的方法中插入一些切面来实现数据统计和观测

 

dump java heap, 类似jmap命令的heap dump功能

[arthas@19141]$ heapdump
Dumping heap to /tmp/heapdump2020-06-10-21-011443721569420485011.hprof...
Heap dump file created

 

classloader信息

[arthas@19141]$ classloader
name numberOfInstances loadedCountTotal
org.springframework.boot.loader.LaunchedURLClassLoader 1 7981
BootstrapClassLoader 1 3582
com.taobao.arthas.agent.ArthasClassloader 1 1237
sun.reflect.DelegatingClassLoader 113 113
sun.misc.Launcher$ExtClassLoader 1 66
sun.misc.Launcher$AppClassLoader 1 47

 

查看已加载类的方法信息, “Search-Method” 的简写

[arthas@19141]$ sm pers.wmx.learningcenter.controller.UserController
pers.wmx.learningcenter.controller.UserController <init>()V
pers.wmx.learningcenter.controller.UserController registry()Ljava/lang/String;
pers.wmx.learningcenter.controller.UserController toRegistry(Lorg/springframework/ui/Model;Lpers/wmx/learningcenter/domain/User;)Ljava/lang/String;
pers.wmx.learningcenter.controller.UserController login()Ljava/lang/String;
pers.wmx.learningcenter.controller.UserController toLogin(Lorg/springframework/ui/Model;Lpers/wmx/learningcenter/domain/User;Ljavax/servlet/http/HttpServletRequest;)Ljava/lang/String;
pers.wmx.learningcenter.controller.UserController loginout(Ljavax/servlet/http/HttpServletRequest;)Ljava/lang/String;
pers.wmx.learningcenter.controller.UserController homepage(Lorg/springframework/ui/Model;Ljavax/servlet/http/HttpServletRequest;)Ljava/lang/String;
pers.wmx.learningcenter.controller.UserController editInfo()Ljava/lang/String;
pers.wmx.learningcenter.controller.UserController toEditInfo(Lpers/wmx/learningcenter/domain/User;Ljavax/servlet/http/HttpServletRequest;)Ljava/lang/String;
pers.wmx.learningcenter.controller.UserController deleteUserById(Ljava/lang/Integer;)Lpers/wmx/learningcenter/domain/Result;
pers.wmx.learningcenter.controller.UserController banUser(Ljava/lang/Integer;)Lpers/wmx/learningcenter/domain/Result;
pers.wmx.learningcenter.controller.UserController activeUser(Ljava/lang/Integer;)Lpers/wmx/learningcenter/domain/Result;
pers.wmx.learningcenter.controller.UserController resetPas(Ljava/lang/Integer;Lorg/springframework/ui/Model;)Ljava/lang/String;
pers.wmx.learningcenter.controller.UserController updatePas(Ljava/lang/Integer;Ljava/lang/String;Lorg/springframework/ui/Model;)Ljava/lang/String;

 

反编译

 

退出arthas

如果只是退出当前的连接,可以用quit或者exit命令。Attach到目标进程上的arthas还会继续运行,端口会保持开放,下次连接时可以直接连接上。

如果想完全退出arthas,可以执行stop命令

 

 

 

转载请注明:汪明鑫的个人博客 » Arthas 初使用

喜欢 (0)

说点什么

您将是第一位评论人!

提醒
avatar
wpDiscuz