Troubleshooting Production Issues with Alibaba’s Arthas

What Arthas all Features

  • Check whether the class is loaded
  • Decompile classes to ensure the code is working as expected
  • View class loader statistics and the method invocation information (including the relevant parameters, return object, and thrown exceptions)
  • Check the stack trace of specified method invocation
  • Trace the method invocation to track slow invocation
  • Monitor the method invocation statistics (such as the queries per second, response time, and success rate)
  • Monitor items such as system metrics, thread states, CPU usage, and garbage-collection statistics
  • Support telnet and the web socket for both local and remote debugging using a command line and browser interface
  • Support Javaa Development Kit 6+
  • Support Linux, MacOS, and Windows

Installing and Running Arthas

wget https://alibaba.github.io/arthas/arthas-boot.jar
  • Run: java -jar arthas-boot.jar
  • Getting Help: java -jar arthas-boot.jar –h

Using Arthas and Arthas Commands

  • --target-ip: In case the targeted Java Virtual Machine is located at a specific IP address over the network, then the default is 127.0.0.1 (which is the localhost).
  • --telnet-port: The targeted Java Virtual Machine listen telnet port. The default port is 3658.
  • --http-port: The targeted Java Virtual Machine listen HTTP port. The default port is 8563.
  • --use-version: This uses a special Arthas version
  • --use-http: This enforces use of HTTP for downloading items. By default, HTTPS is used.
  • --verbose: This is used to make the code more verbose so to print more debug information.

Using the Terminal Console

$ help
NAME DESCRIPTION
help Display Arthas Help
keymap Display all the available keymap for the specified connection.
sc Search all the classes loaded by JVM
sm Search the method of classes loaded by JVM
classloader Show classloader info
jad Decompile class
getstatic Show the static field of a class
monitor Monitor method execution statistics, e.g. total/success/failure count, average rt, fail rate, etc.
stack Display the stack trace for the specified class and method
thread Display thread info, thread stack
trace Trace the execution time of specified method invocation.
watch Display the input/output parameter, return object, and thrown exception of specified method invocation
tt Time Tunnel
jvm Display the target JVM information
ognl Execute ognl expression.
mc Memory compiler, compiles java files into bytecode and class files in memory.
redefine Redefine classes. @see Instrumentation#redefineClasses(ClassDefinition...)
dashboard Overview of target jvm's thread, memory, gc, vm, tomcat info.
dump Dump class byte array from JVM
options View and change various Arthas options
cls Clear the screen
reset Reset all the enhanced classes
version Display Arthas version
shutdown Shutdown Arthas server and exit the console
session Display current session information
sysprop Display, and change the system properties.
sysenv Display the system env.
history Display command history
cat Concatenate and print files
pwd Return working directory name

Some Additional Examples

- sm java.lang.String
- sm -d java.lang.String toString
watch package.to.*Controller * '{params, returnObj, throwExp}'
  • *Controller matches with such things as the UserController, BillingController, AuthController, IndexController, so on.
  • The watch command supports the -e option, which means that only requests that throw an exception are detected.

Arthas Web Console

Conclusion

Original Source

--

--

--

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Laravel Blade Loops

Harvester: Dynamic Configuration in Go

Federated Query in Amazon Redshift for Postgres & MySQL databases

Zero-Trust Security — Part 2: Getting Started with Zero-Trust Security

Proc, Ampersand, & shorter Ruby Code

Shodan and Python API

Welcome go-critic

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com

More from Medium

Containers for embedded systems

Creating Complex “Transforms” in ELK (Elastic) Stack for WSO2 Identity Server Events

Getting Started With Apache Kafka