Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Tomcat MBean to realize Monitoring Application

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Today, I would like to talk to you about how to use Tomcat MBean to achieve monitoring applications, many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.

As a mature open source application server released for many years, Tomcat has many advantages, among which convenient monitoring is one of them.

In Tomcat, monitoring can be achieved through JMX, both in the monitoring application and inside the container.

When you open the window of JConsole, you can see that the local JVM process listed contains the Tomcat process that has been started, where the name column is the name of the currently applied Main-Class, and the PID and jps commands display the same. When it is not clear which application to attach, you can use the jps command to display the details, through the loaded configuration, JVM parameters, and so on. (jps command Please refer to this java gadget that you may not know about.)

After attach, you will see a series of objects exposed by Tomcat and JVM, which are called MBean in JMX. Here JConsole is just a Client, and what the process we are connecting to provides is a Server, which is called MBeanServer in JMX. These MBean are the objects on this Server that provide properties and methods.

The following figure shows some of the MBean seen after the attach to Tomcat process. Catalina is obviously provided by Tomcat, some at the beginning of java, and provided by JVM.

The Engine here is a MBean, and the properties and operations in the red box are the contents provided by the MBean object for reading and execution, while the ObjectName here on the right is the name of a MBean that we locate on a MBeanServer.

JMX

When it comes to MBean, we have to mention JMX. What is JMX?

JMX is an acronym for Java Management Extensions, as described on Wikipedia:

JMX is a Java technology that supplies tools for managing and monitoring applications, system objects, devices (such as printers) and service-oriented networks. Those resources are represented by objects called MBeans (for Managed Bean).

The main function is to manage and monitor the application. The concepts we mentioned above are the core concepts in JMX.

Borrow this picture on wikipedia. We see that Console connects to the MBeanServer through different protocols.

The use of JMX in Tomcat

Tomcat uses JMX for its own monitoring and management. The MBean we see under the Catalina package has different MBean description files in different packages.

If there is a need for monitoring and management of our deployed applications, we can also develop MBean ourselves, and then directly obtain the MBeanServer of the platform, so that we can be with the Tomcat process.

Tomcat internal deployment of some applications, attribute provision, etc., can be done in the form of JMX. We have written some of this section before:

Do you know the application of JMX in Tomcat?

You must have no idea how Tomcat works in IDE!

It introduces how the deployment of applications in IDE is realized through JMX and so on.

Here, which Web applications are deployed in Tomcat and which thread pools and Connector are created at the same time can be obtained and managed through JMX's MBean.

To get this information, all you need to do is write a Client of JMX, and then read it through ObjectName. All the attribute reading and operation execution can be understood as ordinary JavaBean making reflection calls.

For a Web application, the information configured in web.xml is also reflected in MBean.

There are also statistics on the number of requests.

Servlet and Jsp in a Web application are listed separately. As different MBean, their ObjectName format is similar to this:

Catalina:j2eeType=Servlet,WebModule=//localhost/examples,name=HelloWorldExample,J2EEApplication=none,J2EEServer=none

You only need to modify the boldface part.

The management realized by JMX is to realize the dynamic change of some content in the application through the execution of some operations provided by MBean. For example, a startup pause like Connector.

Method calls can be made directly in Jconsole.

After reading the above, do you have any further understanding of how to use Tomcat MBean to implement monitoring applications? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report