The front:
Everybody old iron people, did not meet with everybody for a long time, recently 2B elder brother has been hiding in the home dare not come out the door, live like a pig’s life…..
Eat, drink, poop, sleep. Telecommuting for a while also presents a tricky problem. So there is no time to share with you, but we rest assured, 2B brother from this article I will return to the right track (XXXX, there will be a blessing) hahaha agree to a praise ~~~~
Arthas profile
Arthas is an open source Java diagnostic tool for Alibaba. Arthas was first incubated for use within Taobao and later became a mandatory internal tool for Alibaba Java projects. Arthas became an Ali open source project in 2018, with the code hosted on Github. This was a great boon for the Java department, and the project was loved by developers.
Alibaba.github. IO /arthas
Quick start
The latest version is 3.1.7. Download address is as follows
Maven.aliyun.com/repository/…
Start the
Sh or enter Java -jar arthas-boot.jar (recommended)
This indicates that there are currently no Java processes. So what?
The official provided a demo that we can run.
Enter the command: java-jar arthash-demo.jar is a demo of a math game
The source code is as follows:
package demo;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.TimeUnit;
public class MathGame {
private static Random random = new Random();
public int illegalArgumentCount = 0;
public static void main(String[] args) throws InterruptedException {
MathGame game = new MathGame();
while (true) {
game.run();
TimeUnit.SECONDS.sleep(1);
}
}
public void run() throws InterruptedException {
try {
int number = random.nextInt()/10000;
List<Integer> primeFactors = primeFactors(number);
print(number, primeFactors);
} catch (Exception e) {
System.out.println(String.format("illegalArgumentCount:%3d, ", illegalArgumentCount) + e.getMessage());
}
}
public static void print(int number, List<Integer> primeFactors) {
StringBuffer sb = new StringBuffer(number + "=");
for (int factor : primeFactors) {
sb.append(factor).append(The '*');
}
if (sb.charAt(sb.length() - 1) == The '*') {
sb.deleteCharAt(sb.length() - 1);
}
System.out.println(sb);
}
public List<Integer> primeFactors(int number) {
if (number < 2) {
illegalArgumentCount++;
throw new IllegalArgumentException("number is: " + number + ", need >= 2");
}
List<Integer> result = new ArrayList<Integer>();
int i = 2;
while (i <= number) {
if (number % i == 0) {
result.add(i);
number = number / i;
i = 2;
} else{ i++; }}returnresult; }}Copy the code
Java -jar arthas-boot.jar and you’ll see the following image: select the process you want to view and I’ll type 1 enter and arthas will start.
Web console
Arthas is connected through a browser
Arthas currently supports a Web Console, which users can access directly after attaching: http://127.0.0.1:3658/.
You can fill in an IP to remotely connect to arthas on other machines.
Conclusion:
Installation and download, use or relatively simple, we can try, download down their own play. Everyone pay attention to me, the next article to teach you advanced use. Such as:
ø From which JAR is this class loaded? Why are all kinds of class-related exceptions reported?
Why is the code I changed not executed? Did I not commit? Got the branch wrong?
ø If you encounter problems, you cannot debug them online. Can you only re-publish them by adding logs?
ø There is a problem with a user’s data processing online, but it cannot be debugged online, and cannot be reproduced offline!
Is there a global perspective to see the health of the system?
Is there any way to monitor the real-time health of the JVM?
These questions you want to know you can pay attention to or like to 2b brother Oh