The Java 2 Platform, Standard Edition beginning with version 5.0, supports JMX 1.2 and JMX Remote API 1.0, which is now the official JMX reference implementation. It includes significant monitoring and management features which can be divided into three broad categories.
Instrumentation for the Java Virtual Machine (Java VM) that enables built-in (or out-of-the-box) management capabilities that can be accessed both remotely and locally.
Monitoring and Management application programming interfaces (API) that provide the interface for monitoring and managing the Java VM.
Monitoring and Management tools that provide a graphical monitoring tool called JConsole, which implements the JMX API and enables you to monitor the performance of the Java VM and any instrumented applications.
The Java Management Extensions (JMX) technology is native to the Java programming language and, as a result, it offers natural, efficient, and lightweight management and monitoring extensions to Java-based functions. It can be used to monitor and manage the Java Virtual Machine and also user Java applications. The key components are the MBeans, the notification model, namely Java objects that represent resources to be managed. An MBean has a management interface consisting of the following:
MBeans are not accessed directly by an application but reside in a repository called an MBean server. To be useful, an MBean must be registered in an MBean server. The Java SE platform includes a built-in platform MBean server. The MBean represents a resource running in the Java virtual machine, such as an application or a Java EE technical service (transactional monitor, JDBC driver, etc.) and, of course, can be used to be monitor the health state of JVM and Java applications.
Generally, any JVM supplies the following JMX MBean Platforms that collect important information about JVM and application health status.
[table id=1 /]
In addition, almost any software vendor providing a more-or-less serious application will insert includes Mbeans to provide important information about the application state. For instance, Jboss, GlassFish, Tomcat and others use JMX MBeans to for managing and monitoring by implementing hundreds of custom Mbeans.
The Monitis JMX Monitor
The Monitis JMX Monitor represents the Java implementation of a standalone JMX client which allows it to get Mbeans attribute values from any Java application and to send them to Monitis via the Monitis open API.
This project uses the Java Management Extensions and the Monitis custom monitor approach to provide a simple solution for users who want to monitor any Java application.
If you want to monitor the JVM health state, you don’t need to make any changes in your application at all.
The only requirement for the monitored application is the following:
The JMX Monitor project structure
The JMX Monitor project contains the following sources:
Please notice that we are using the cropped Open API Java client library (wrapper) – m_api.jar (which contains only the essential functionality required for the custom monitor)
The monitor.config file is used to configure JMXMonitor. It should be prepared in JSON form and has the following structure.
Testing and results
To check that the monitor is working correctly, the embedded test application can be started with the following parameters:
Note: you can use the “jmxserver.sh” script on a Linux machine that already contains the parameters mentioned above.
Next, you should start the JMX monitor. After some time, sufficient data will be accumulated and the results will be viewable on the user’s Monitis dashboard.
To do this, the user should log in to their Monitis account and add a new custom monitor into the dashboard.
Also, the Graphical representation of the monitored data can be shown by switching to the corresponding view:
Please look also into existing code of Monitis JMXMonitor for more details