当前位置:网站首页># Arthas 简单使用说明
# Arthas 简单使用说明
2022-07-07 06:53:00 【爱码代码的喵】
Arthas 简单使用说明
友情链接:
# Jdk VisualVM使用、线程 dump 制作分析
# Idea 调试 Debug 技巧
Arthas官方文档
Arthas
Arthas
是Alibaba
在 2018 年 9 月开源的 Java 诊断工具。支持JDK6+
, 采用命令行交互模式,提供Tab
自动不全,可以方便的定位和诊断线上程序运行问题。
Arthas 使用场景
- 是否有一个全局视角来查看系统的运行状况?
- 为什么
CPU
又升高了,到底是哪里占用了CPU
? - 运行的多线程有死锁吗?有阻塞吗?
- 程序运行耗时很长,是哪里耗时比较长呢?如何监测呢?
- 这个类从哪个
jar
包加载的?为什么会报各种类相关的Exception
? - 我改的代码为什么没有执行到?难道是我没
commit
?分支搞错了? - 遇到问题无法在线上
debug
,难道只能通过加日志再重新发布吗? - 有什么办法可以监控到
JVM
的实时运行状态?
安装启动
从镜像下载:https://arthas.aliyun.com/download/latest_version?mirror=aliyun
启动:
java -jar arthas-boot.jar
Web Console
:http://127.0.0.1:8563/)
:页面上的操作模式和控制台完全一样。
相关命令
命令 | 介绍 |
---|---|
dashboard | 当前系统的实时数据面板 |
thread | 查看当前 JVM 的线程堆栈信息 |
watch | 方法执行数据观测 |
trace | 方法内部调用路径,并输出方法路径上的每个节点上耗时 |
stack | 输出当前方法被调用的调用路径 |
tt | 方法执行数据的时空隧道,记录下指定方法每次调用的入参和返回信息,并能对这些不同的时间下调用进行观测 |
monitor | 方法执行监控 |
jvm | 查看当前 JVM 信息 |
vmoption | 查看,更新 JVM 诊断相关的参数 |
sc | 查看 JVM 已加载的类信息 |
sm | 查看已加载类的方法信息 |
jad | 反编译指定已加载类的源码 |
classloader | 查看 classloader 的继承树,urls ,类加载信息 |
heapdump | 类似 jmap 命令的 heap dump 功能 |
常用操作
- 使用 dashboard 命令可以概览程序的 线程、内存、
GC
、运行环境信息。 - 使用 thread查看所有线程信息,同时会列出每个线程的
CPU
使用率
Thread
参数名称 | 参数说明 |
---|---|
id | 线程id |
[n:] | 指定最忙的前N 个线程并打印堆栈 |
[b] | 找出当前阻塞其他线程的线程 |
[i <value>] | 指定cpu 使用率统计的采样间隔,单位为毫秒,默认值为200 |
[--all] | 显示所有匹配的线程 |
thread -b 找出死锁线程
thread --state blocked
thread -b
最忙的前N个线程并打印堆栈
thread -n 3
反编译类
反编译指定已加载类的源码,查看当前环境中的代码是否是最新的代码
jad com.li.springbootproject.service.thread.impl.ThreadTestServiceImpl
输出到目录下:
jad --source-only com.li.springbootproject.service.user.impl.UserServiceImpl > J://Documents//Desktop//UserServiceImpl.java
查看类相关属性
查看
JVM
已加载的类信息sc -d -f com.li.springbootproject.service.thread.impl.ThreadTestServiceImpl
查看变量的值
ognl '@com[email protected]hashSet'
静态变量修改值:
ognl '@com[email protected]hashSet.add("test")'
查看方法耗时
class-pattern | 类名表达式匹配 |
---|---|
method-pattern | 方法名表达式匹配 |
condition-express | 条件表达式 |
[E] | 开启正则表达式匹配,默认为通配符匹配 |
[n:] | 命令执行次数 |
#cost | 方法执行耗时 |
使用 trace 命令可以跟踪统计方法耗时
trace com.li.springbootproject.service.test.impl.CommonServiceImpl insertDemo
方法执行监控
监控项 | 说明 |
---|---|
timestamp | 时间戳 |
class | Java 类 |
method | 方法(构造方法、普通方法) |
total | 调用次数 |
success | 成功次数 |
fail | 失败次数 |
rt | 平均RT |
fail-rate | 失败率 |
monitor -c 5 com.li.springbootproject.controller.test.CommonController test
观察方法信息
- 调用路径:
stack com.UserServiceImpl mysql
查找对应类的 classloader
sc -d *ThreadTestServiceImpl | grep classLoader
Idea 安装 Arthas 插件
- 安装这个插件可以快速复制相关命令
边栏推荐
- Mysql数据库-锁-学习笔记
- asp. How to call vb DLL function in net project
- Run can start normally, and debug doesn't start or report an error, which seems to be stuck
- 【SVN】SVN是什么?怎么使用?
- 消费互联网的产业链其实是很短的,它仅仅承接平台上下游的对接和撮合的角色
- Unittest simple project
- Install pyqt5 and Matplotlib module
- Unity shader (data type in cghlsl)
- Postman setting environment variables
- 信息安全实验四:Ip包监视程序实现
猜你喜欢
Jenkins modifies the system time
[SVN] what is SVN? How do you use it?
H5网页播放器EasyPlayer.js如何实现直播视频实时录像?
JMeter JDBC batch references data as input parameters (the simplest method for the whole website)
二叉树高频题型
数据建模中利用3σ剔除异常值进行数据清洗
MongoDB怎么实现创建删除数据库、创建删除表、数据增删改查
Port multiplexing and re imaging
Connecting mobile phone with ADB
Entity of cesium data visualization (Part 1)
随机推荐
在EXCEL写VBA连接ORACLE并查询数据库中的内容
进程和线程的区别
NATAPP内网穿透
Mysql database lock learning notes
How to speed up video playback in browser
Unity shader (data type in cghlsl)
Implementation of corner badge of Youmeng message push
Postman data driven
第一讲:寻找矩阵的极小值
H5网页播放器EasyPlayer.js如何实现直播视频实时录像?
Data association between two interfaces of postman
DRF authentication, permissions, and flow restrictions (only for views in DRF)
信息安全实验三 :PGP邮件加密软件的使用
Register address name mapping
数据建模中利用3σ剔除异常值进行数据清洗
Some pit avoidance guidelines for using Huawei ECS
Using JWT to realize login function
Unity shader (to achieve a simple material effect with adjustable color attributes only)
[cloud native] Devops (I): introduction to Devops and use of code tool
Over 100000 words_ Ultra detailed SSM integration practice_ Manually implement permission management