In order to learn more about JMX, the first step was to show all the MBeans and properties and start exporting them to the console, but it didn’t work well. The content was too long and not intuitive, so I added a Tree structure on the Web side. And then along came the discovery that with a few tweaks it could be used as a web version of the simple monitoring end.

This tool has only been tested in a hotspot JVM 8 environment. Supports viewing local and remote JVM real-time monitoring.

React 16 + Antd + Yarn at the front end and Spring Boot + Java 1.8 at the back end. You can go to the Github repository README page for details. An online preview version is provided, with the source address and how to use the online version.

 

Support for local and remote JVM linking.

 

Tree display of all MBeans and display of properties and operations.

 

Real-time display of JVM health

The functions are as follows:

1. Display of all MBeans;

2. Display system information, including memory usage, CPU usage, etc.;

3. JVM parameters, including command-line parameters and systemProperties;

4. Real-time line chart of CPU, Heap, Metaspace, class loading, thread;

5. Type and number of garbage collectors;

Here’s how to use JMX in combination with these sections.

An acquisition

Mbeans themselves exist in this hierarchy, just as mBeans in various tools are presented in a tree.

Mbeans are contained in the Domain, which is a set of independent Spaces in which objectNames of various types and names can be defined. Like the custom one from the previous JMX article.

ObjectName lets you get various MBean information, including properties, operations, and notifications.

Some attributes are simple data types, such as int, long, double, String, and others are more complex. For example com. Sun. Management: the attribute of type = HotSpotDiagnostic DiagnosticOptions is javax.management.openmbean.Com positeData type. And the properties of the data type is javax.mail management openmbean. TabularData. These have to be dealt with separately.

 

The commonly used an

Some metrics are used by monitoring, such as memory, CPU, heap space, threads, and class-loading related MBeans.

The JDK provides a ManagementFactory, which helps us easily get commonly used MBeans. You can find this class in the java.lang.management package to look at the comments and code.

OperatingSystemMXBean

You can obtain information about the operating system, such as the machine name, memory usage, and CPU usage.

Get through ManagementFactory. GetOperatingSystemMXBean () way.

RuntimeMXBean

You can get information about the current JVM, including JVM parameters and JVM-related system parameters.

Can through the ManagementFactory. GetRuntimeMXBean () way to get.

MemoryMXBean

You can get the memory usage of the current JVM, both heap and non-heap.

Can through the ManagementFactory. GetMemoryMXBean ()

ThreadMXBean

Gets JVM thread usage, including active threads, daemons, thread spikes, and so on.

Can through the ManagementFactory. GetThreadMXBean ().

ClassLoadingMXBean

Gets JVM classes loaded, unloaded, and so on.

Can through the ManagementFactory. GetClassLoadingMXBean ().

GarbageCollectorMXBean

Gets information about the JVM garbage collector, including which garbage collector is used, the number of collections, and so on.

By ManagementFactory. GetGarbageCollectorMXBeans (), note that get here is a collection, because the garbage collector is divided into old age and new generation or two.

In addition to the above few commonly used MBeans, there are many others. Some are already provided in the ManagementFactory class, and many more need to be fetched yourself via ObjectName.