Monitor the internal and external conditions of the application using JMX

Source: Internet
Author: User
Tags connection pooling stack trace

Since WebLogic 6.0, the Java Management API (JMX) is required to manage WebLogic servers. With this API, you can search the application server for admin beans (Mbeans) and through them you can query both configuration information and runtime monitoring information. In addition, this API can also be used to change the configuration of the server. In fact, this API has been used on consoles and other management tools to complete their work and provide reporting data.

This API is a powerful monitoring tool. Let's take a look at an example. In this application, there are most static content, some of your personalized JSP pages, a registration system, a data system based on JMS (Java messaging Services,java messaging service), and a small paid application system. It's good for us where jmx is used in this application. On a static page, you can access information for Fileservlet and see how much time it takes to service static content. The time may be less than you expected, because the browser automatically caches portions of the content on the client. Most requests for static content will be head requests to check for changes. For dynamic pages, each servlet in the system is calculated separately. This data does not reflect the user's experience well (since the user has a delay between sending the request and returning to the page), but the data tells the average time each servlet spends on one request and how many requests are completed. Our registration system is an entity bean, and the billing system is a stateless session bean returned by an external service. All two beans can be monitored, and the monitoring information helps us to optimize the size of the cache and pool. Our data can also help determine whether we've got the information we need, or how many users are using the data. Throughput can also be computed using the properties of the JMS topic and queue type Mbean. In addition, all JDBC connections can be monitored, and from their Mbeans you can find how many connection pools are being used, for example, which will help you determine if more database client authorization is required.

The second use of Mbeans in the WebLogic server is for configuration information. By configuring Mbeans, the configuration of all resources is included in the runtime. These mbeans are essentially representations of the information contained in the Config.xml file. All the content of an application deployed on the server listening port is included in these interfaces. Most of the individual attributes are directly related directly; however, it is complex to describe a set of attributes for a deployment unit and to facilitate their collection in WebLogic. In the Deployer class. It is possible to access them directly, but it is not recommended to look at the configuration and not to change the operation. The rest of the properties are optional, but be careful, but if components (such as the JDBC Pool) are redeployed or the server restarts, most of these properties actually only change the behavior at run time. The scope of these Mbeans applications ranges from the decision to use resources for a particular application, to the adjustment based on feedback values from the Supervisor Mbeans.

As you can see, there's a lot of information--but if you're unfamiliar with JMS and WebLogic servers, how do you get started? It's actually not that hard. As long as you can use Jndi and can read Javadocs you will find it quite easy to manipulate Mbeans. In the code example that you see below, you will be told how to get the local server's Mbean home interface and JDBC pool.

Mbeanhome home = (mbeanhome) New

InitialContext (). lookup (Mbeanhome.local_jndi_name);

Set pools = Home.getmbeansbytype ("Jdbcconnectionpool");

The above code gives the configuration Mbean for the JDBC (Java database Connectivity,java DB connection) pool. If you want to monitor connection pooling without considering their configuration, you can do this by simply adding "Runtime" to change the Mbean type. From this mbean you can identify important information, such as whether there is a connection leak--you can even get a stack trace to find the exact location of the connection.

What if you don't want to do any Java programming, just like using a jmx Mbean system from a script file. Luckily we have a command-line tool that allows you to view and change mbean-weblogic directly on the command line. Admin. In addition to pinging servers, getting a jndi list, resetting the connection pool, and shutting down the server, it gives a hierarchical structure for direct access to the Mbean. In the following code example you will see such a weblogic. Admin's instructions.

Java WebLogic. Admin-username system-password [password]-url [url] Get

-pretty-type Jdbcconnectionpool

This code gives a simple, readable description of an mbean compared to the type descriptor that adds attributes to the Mbeans. Similarly, there is a set command that alters the properties of any mbean in the system.

With this tool you should be able to monitor your application both inside and outside of the Java script.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.