当前位置:网站首页>Common usage of Arthas
Common usage of Arthas
2022-07-18 22:02:00 【Luoluo 1024】
Arthas Common usage of
watch
scene : Look at the input parameters of the method , Just want to observe your call , Filter irrelevant calls
Parameters are basic reference types
@GetMapping("test1")
public String test1(String name,Integer age){
return "ok";
}
In the use of watch When , An interface , If it is called frequently , Sometimes it's too late to see what you want to observe , Now I want to filter the specified name In order to see what I want to observe
#params[0], Represents the first parameter , And so on
watch com.luo.test test1'{params,returnObj}' "params[0]=='zhangsan'" -n 5 -x 3
The parameter is one VO
@GetMapping("test2")
public String test2(Student student){
return "ok";
}
@Data
private class Student{
private String name;
private Integer age;
private Addr addr;
}
# Filter out last name luo Of the students
watch com.luo.test test2 '{params,returnObj,throwExp}' "params[0].name=='luo'" -n 5 -x 3
trace
Method internal call path , And output the time consumption of each node on the method path
scene : An interface reports an error in the production environment , But there are many interfaces if-else Branch , And because the log did not print out under certain circumstances , Just looking at the code, you can't know the method call stack , Can't accurately locate
# Capture a call ,-n Number of times
$ trace --skipJDKMethod false demo.MathGame run -n 1
Press Q or Ctrl+C to abort.
Affect(class-cnt:1 , method-cnt:1) cost in 60 ms.
`---ts=2019-12-04 00:44:41;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=[email protected] `---[1.357742ms] demo.MathGame:run()
+---[0.028624ms] java.util.Random:nextInt() #23
+---[0.045534ms] demo.MathGame:primeFactors() #24 [throws Exception]
+---[0.005372ms] java.lang.StringBuilder:<init>() #28
+---[0.012257ms] java.lang.Integer:valueOf() #28
+---[0.234537ms] java.lang.String:format() #28
+---[min=0.004539ms,max=0.005778ms,total=0.010317ms,count=2] java.lang.StringBuilder:append() #28
+---[0.013777ms] java.lang.Exception:getMessage() #28
+---[0.004935ms] java.lang.StringBuilder:toString() #28
`---[0.06941ms] java.io.PrintStream:println() #28 `---ts=2019-12-04 00:44:42;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=sun.misc.Launcher$AppClassLoader@3d4eac69
`---[3.030432ms] demo.MathGame:run() +---[0.010473ms] java.util.Random:nextInt() #23 +---[0.023715ms] demo.MathGame:primeFactors() #24 [throws Exception] +---[0.005198ms] java.lang.StringBuilder:<init>() #28 +---[0.006405ms] java.lang.Integer:valueOf() #28 +---[0.178583ms] java.lang.String:format() #28 +---[min=0.011636ms,max=0.838077ms,total=0.849713ms,count=2] java.lang.StringBuilder:append() #28 +---[0.008747ms] java.lang.Exception:getMessage() #28 +---[0.019768ms] java.lang.StringBuilder:toString() #28 `---[0.076457ms] java.io.PrintStream:println() #28
scene : Look for the location that causes the slow response of the interface
# The display takes longer than 20ms Call path for
$ trace demo.MathGame run '#cost > 20'
Press Ctrl+C to abort.
Affect(class-cnt:1 , method-cnt:1) cost in 41 ms.
`---ts=2018-12-04 01:12:02;thread_name=main;id=1;is_daemon=false;priority=5;TCCL=[email protected] `---[12.033735ms] demo.MathGame:run()
+---[0.006783ms] java.util.Random:nextInt()
+---[11.852594ms] demo.MathGame:primeFactors()
`---[0.05447ms] demo.MathGame:print()
logger
Update the log level in real time
scene : In the production environment , The log level of Key log information in the code is lower than that configured by the configuration file , Don't think of replacing file restart service
# Check the package or class logger Information
[[email protected]]$ logger -n packageName/className
name org.springframework.web
class ch.qos.logback.classic.Logger
classLoader sun.misc.Launcher$AppClassLoader@2a139a55
classLoaderHash 2a139a55
level null
effectiveLevel INFO
additivity true
codeSource file:/Users/hengyunabc/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar
# View specific classes classloader hashcode
[[email protected]]$ sc -d myClassName
# Modify the log level to debug
[[email protected]]$ logger -c 2a139a55 --name ROOT --level debug
update logger level success.
ognl expression
scene : For example, I have changed the configuration , But I don't want to restart the service , What can I do to refresh the configuration cache in memory ?
Dynamic execution bean The method in
# Query this class , Find its classloader hash value
[[email protected]]$ sc -d com.fy.CsdAndHjdCache
class-info com.fy.CsdAndHjdCache
name com.fy.CsdAndHjdCache
isInterface false
isAnnotation false
isEnum false
isAnonymousClass false
isArray false
isLocalClass false
isMemberClass false
isPrimitive false
isSynthetic false
simple-name CsdAndHjdCache
modifier public
annotation
interfaces
super-class +-java.lang.Object
[email protected]
+-sun.misc.Launcher$AppClassLoader@18b4aac2
+-sun.misc.Launcher$ExtClassLoader@32cf48b7
classLoaderHash 69fbea59
# According to the class loader hash value , find spring The context of , Get... By context bean, Calling bean The method we want to call in , In this case , I want to re execute init() Method
[[email protected]]$ ognl -c 69fbea59 '#[email protected][email protected], #context.getBean("csdAndHjdCache").init()'
vmtool
Implement query memory object , mandatory GC And so on
scene : For example, I have changed the configuration , But I don't want to restart the service , What can I do to refresh the configuration cache in memory ?
# Query this class , Find its classloader hash value
[[email protected]]$ sc -d com.tq.questions.MyController
# Call the... Of this instance getA() Method
[[email protected]]$ vmtool --action getInstances -c 18b4aac2 --className com.tq.questions.MyController --express 'instances[0].refreshConfigs()'
getInstances: action The returned result is bound to instances Variables on the , It's an array
The rest to be added ........
边栏推荐
- 【C】 Dynamic memory management
- MySQL trigger
- 镍氢电池的特性和使用方法(FDK镍氢电池充电机制)
- MP1655GG-Z MPS/美国芯源 MOSFET 的开关模式转换器 资源 方案
- 6G synaesthesia integrated networking integration technology
- Pyqt5 file dialog (QFileDialog)
- Localstorage, sessionstorage string or number considerations
- 阿普奇 E8 工控机——MinipiceCAN卡在建筑机器人的应用
- [PHP code audit] Introduction analysis of vulnerabilities in Pikachu shooting range
- CONDA installation requirements Txt specified dependent package
猜你喜欢

降噪蓝牙耳机哪个好?蓝牙耳机降噪推荐

Machine learning notes - data enhancement using Gan for defect detection

Leetcode 1332. 删除回文子序列(看完题解才恍然大悟!!!!!!!)

Ranking of top ten OA systems

今天去 OPPO 面试,被问麻了

FreeSwitch的限流配置

Pyqt5 file dialog (QFileDialog)

(笔记整理未完成)【图论:最小生成树】

Pyqt5 color dialog (qcolordialog)

App packet capturing tips how to break network exceptions?
随机推荐
升级版打榜活动再次火热袭来,放眼望去全是奖金
MySQL variables, process control and cursors
What if win11 always pops up the input experience
当前主流的RPA厂商主要有哪些
【C】 Dynamic memory management
基于Gensim计算文本相似度
Calculate text similarity based on gensim
MySQL 5.7.37数据库下载安装教程(Windows无需安装版)
国内外主要RPA产品盘点
鎳氫電池的特性和使用方法(FDK鎳氫電池充電機制)
How do top enterprises such as Starbucks, Coca Cola and apple carry out brand marketing
Personal information protection based on classification and classification
Leetcode 1342. 将数字变成 0 的操作次数
信息收集
Backup MySQL database on Linux server (detailed tutorial)
AcWing 1183. Power problem solution (double connected components and cut points of undirected graph)
【面试:并发篇15:多线程:synchronized优化原理】
openGauss数据库
No bugs.
降噪蓝牙耳机哪款好?性价比最高的主动降噪蓝牙耳机