origin
Recently see a very popular title, “open source XX years, star XXX, I am how to adhere to”.
It’s been a year since Arthas opened its doors in September 2018, and it’s a good time to wrap up and review.
Arthas is an open source Java diagnostic tool for Alibaba that developers love.
- Making: github.com/alibaba/art…
- Documents: alibaba. Making. IO/arthas
Arthas Star numbers have been growing rapidly throughout their history and currently exceed 16K.
Thank users for their support, which is both pressure and motivation. Arthas has released seven releases in the past year of open source, and we’ve been sticking to three things:
- Continuous improvement of ease of use
- Keep adding useful commands
- Take power from the open source community and give back to the community
Continuous improvement of ease of use
Arthas has always put ease of use first, and since open source we have made the following improvements:
- Arthas Boot was developed to support a unified Windows/Linux/Mac experience
- Smooth automatic completion, reference jshell experience
- Efficient history command matching,
Up/Down
direct - Improved class search and match functionality to better support lambdas and inner classes
- Improve the redirection mechanism
- Support the JDK 9/10/11
- Support the Docker
- RPM/DEB package installation is supported
Although we put a lot of effort into ease of use, we found that it was often difficult for users to get started, so we introduced Arthas online tutorials by referring to K8S ‘Interactive Tutorial:
- Arthas Basic tutorial
- Arthas Advanced Tutorial
The basic tutorial provides a step-by-step introduction to the interactive terminal, and the advanced tutorial provides an in-depth understanding of Arthas troubleshooting cases.
In addition, in order to facilitate large-scale deployment, tunnel Server and user data return functions are implemented:
- Add a Tunnel server to centrally manage Agent connections
- Add the user data return function to facilitate security control
Keep adding useful commands
Arthas claims to be a diagnostic tool for Java applications, so we have to live up to that claim. Arthas has continued to add more than 10 commands since open source.
- Ognl command arbitrary code execution
- MC online memory compiler
- Re-define hot update code on the command line
- The logger command displays all logger configurations in the application with one click
- Sysprop View update System Properties
- Sysenv Displays environment variables
- Vmoption View updated VM options
- Logger View logger configuration and update the level
- Mbean views JMX information
- Heapdump Heap memory snapshot
Two features are highlighted below.
Jad/MC/RE-define a dragon hot update online code
Take the UserController in the Arthas online tutorial for example:
-
Decompile code using JAD
jad --source-only com.example.demo.arthas.user.UserController > /tmp/UserController.java Copy the code
-
Compile code using VIm
If the user ID is less than 1, the system returns the same value without raising an exception:
@GetMapping("/user/{id}") public User findUserById(@PathVariable Integer id) { logger.info("id: {}" , id); if(id ! =null && id < 1) { return new User(id, "name" + id); // throw new IllegalArgumentException("id < 1"); } else { return new User(id, "name"+ id); }}Copy the code
-
Compile the modified userController.java using the MC command
$ mc /tmp/UserController.java -d /tmp Memory compiler output: /tmp/com/example/demo/arthas/user/UserController.class Affect(row-cnt:1) cost in 346 ms Copy the code
-
Use the re-define command because code can be hot updated
$ redefine /tmp/com/example/demo/arthas/user/UserController.class redefine success, size: 1 Copy the code
View the configuration and change the level by using logger command
When the site is under a lot of pressure (such as Double 11), a relief measure is to change the application log level to ERROR. So there are two questions:
- Complex applications can have multiple logging systems, so which logging system configuration actually takes effect?
- How to dynamically change logger level online?
Using logger command, you can view detailed logger configuration information in the application, such as FileAppender output file, AsyncAppender blocking or not.
[arthas@2062]$ logger
name ROOT
class ch.qos.logback.classic.Logger
classLoader sun.misc.Launcher$AppClassLoader@2a139a55
classLoaderHash 2a139a55
level INFO
effectiveLevel INFO
additivity trueCodeSource file: / Users/hengyunabc/m2 / repository/ch/qos/logback/logback - classic / 1.2.3 / logback - classic - 1.2.3. Jar appenders name CONSOLE class ch.qos.logback.core.ConsoleAppender classLoader sun.misc.Launcher$AppClassLoader@2a139a55
classLoaderHash 2a139a55
target System.out
name APPLICATION
class ch.qos.logback.core.rolling.RollingFileAppender
classLoader sun.misc.Launcher$AppClassLoader@2a139a55
classLoaderHash 2a139a55
file app.log
name ASYNC
class ch.qos.logback.classic.AsyncAppender
classLoader sun.misc.Launcher$AppClassLoader@2a139a55
classLoaderHash 2a139a55
blocking false
appenderRef [APPLICATION]
Copy the code
Logger level can also be changed online:
[arthas@2062]$ logger --name ROOT --level debug
update logger level success.
Copy the code
Take power from the open source community and give back to the community
Thanks to 67 molecules
Since Arthas opened source, there have been 67 ficolin-3 thanks for their contributions to improvements:
The community submitted a series of improvements, some of which are listed below (incomplete) :
- Translated most of the English documents
- The trace command supports line numbers
- The packaging format supports RPM/DEB
- Improved command line prompt for
arthas@pid
- Improved support for Windows
- increase
mbean
The command - Improve the WebConsole experience
In addition, 83 companies/organizations have registered their usage information, and more users are welcome to register:
Non-ergot-derived dopamine agonists project
Several spinoff projects were derived from Arthas, two of which are listed below:
- Bistoury: Qunar’s open source integrated Arthas project
- Arthas-mvel: a fork that uses the mVEL script
User Case Sharing
Arthas users have shared a lot of information about how to troubleshoot problems with Arthas.
Giving back to the open source
Arthas itself uses a lot of open source code, and in the open source process we have contributed improvements to Netty, OGNL, CFR, and others to feed back upstream.
Afterword.
At the time of the Arthas brochure, Arthas had the following tagline:
“Hand of rose, lingering fragrance.”
Hopefully Arthas will be able to help more users solve problems in the future, and hopefully developers will be able to make improvements and suggestions to Arthas.
Finally, there will be a lucky draw where you can forward your article, post your own story with Arthas on the public account, or send Arthas a suggestion, and the prize will be a hoodie from Arthas:
The public,
Welcome to hengyun Dubbo’s column focusing on Java, Spring Boot, Arthas, Dubbo.