当前位置:网站首页>Arthas simple instructions

Arthas simple instructions

2022-07-07 09:36:00 Love code meow

Arthas Simple instructions for use

link :
# Jdk VisualVM Use 、 Threads dump Make analysis
# Idea debugging Debug skill
Arthas Official documents

Arthas

  • Arthas yes Alibaba stay 2018 year 9 Open source in Java The diagnosis Tools . Support JDK6+, Use command line interaction mode , Provide Tab Not fully automatic , It is convenient to locate and diagnose online program running problems .

Arthas Use scenarios

  • Is there a global perspective to see the health of the system ?
  • Why? CPU It's going up again , Where did it take up CPU
  • Does the multithread running have a deadlock ? Is there a jam ?
  • The program takes a long time to run , Where does it take longer ? How to monitor ?
  • Where does this class come from jar Package loaded ? Why do you report all kinds of related Exception
  • Why didn't I change the code to ? I didn't commit? The branch is wrong ?
  • I can't get online when I have a problem debug, Can't we just add logs and redistribute them ?
  • Is there any way to monitor JVM The real-time running state of ?

Installing the

Relevant command

command Introduce
dashboard Real time data panel of current system
thread View the current JVM Thread stack information for
watch Methods perform data observation
trace Method internal call path , And output the time consumption of each node on the method path
stack Output the call path of the current method to be called
tt Method to execute the spatiotemporal tunnel of data , Record the input and return information of each call of the specified method , And can observe these different time adjustments
monitor Method execution monitoring
jvm View the current JVM Information
vmoption see , to update JVM Diagnosis related parameters
sc see JVM Loaded class information
sm View method information for loaded classes
jad Decompile specifies the source code of the loaded class
classloader see classloader Inheritance tree of ,urls, Class loading information
heapdump similar jmap Ordered heap dump function

Common operations

  • Use dashboard Command can overview the program's Threads 、 Memory 、GC、 Operating environment information .
  • Use thread see all Thread information , The... Of each thread will also be listed CPU Usage rate

Thread

Parameter name Parameter description
id Threads id
[n:] Before you designate the busiest N Thread and print stack
[b] Find out which threads are currently blocking other threads
[i <value>] Appoint cpu Sampling interval for usage statistics , The unit is millisecond , The default value is 200
[--all] Show all matching threads

thread -b Find the deadlock thread

  • thread --state blocked

  • thread -b

 Please add a picture description

The busiest before N Thread and print stack

  • thread -n 3

Decompile class

  • Decompile specifies the source code of the loaded class , Check whether the code in the current environment is the latest code

  • jad com.li.springbootproject.service.thread.impl.ThreadTestServiceImpl

  • Output to directory :jad --source-only com.li.springbootproject.service.user.impl.UserServiceImpl > J://Documents//Desktop//UserServiceImpl.java
     Please add a picture description

View class related properties

  • see JVM Loaded class information

  • sc -d -f com.li.springbootproject.service.thread.impl.ThreadTestServiceImpl
     Please add a picture description

Look at the value of the variable

The viewing method takes time

class-pattern Class name expression matching
method-pattern Method name expression matching
condition-express Conditional expression
[E] Turn on regular expression matching , The default is wildcard matching
[n:] Command execution times
#cost Method execution time
  • Use trace The command can track the statistics method time consuming

  • trace com.li.springbootproject.service.test.impl.CommonServiceImpl insertDemo
     Please add a picture description

Method execution monitoring

Monitoring item explain
timestamp Time stamp
classJava class
method Method ( Construction method 、 Common method )
total Call the number
success Number of successes
fail Number of failures
rt Average RT
fail-rate Failure rate
  • monitor -c 5 com.li.springbootproject.controller.test.CommonController test

Observation method information

  • Call path :stack com.UserServiceImpl mysql

Find the corresponding class classloader

  • sc -d *ThreadTestServiceImpl | grep classLoader

Idea install Arthas plug-in unit

  • Installing this plug-in can quickly copy related commands
     Please add a picture description
原网站

版权声明
本文为[Love code meow]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207070653365737.html