JMX is a Java standard for monitoring and managing applications written in the Java development language. JMX supports distributed monitoring and management capabilities and allows access to JMX attributes and operations via a variety of access protocols. Firescope leverages the access capabilities made available in JMX to deliver the ability to monitor or manipulate many JMX data attributes or operations. In order to deliver these capabilities several configurations must be initiated. The following document is intended to guide you through the necessary configurations required to enable JMX capabilities for use with the FireScope appliance. Firescope JMX Monitoring ArchitectureThe figure below details a simple FireScope appliance monitoring two hosts, each of which houses two Java applications.
Configuration SummaryThe following points highlight the necessary steps required for JMX monitoring with FireScope:
JVM ConfigurationEach JVM that will be monitored must be configured to allow access to the JMX server that runs inside of each monitored JVM. Configuration is accomplished by providing a few system parameters to the JVM upon application startup. The parameters are listed below along with their description.
Example:
Use netstat prior to starting or restarting your application to ensure that the configured port is not in use. Restart your Java application using the new configuration. Then run netstat again to ensure that the system reports a listening port on the selected configuration port. JMX DiscoveryJConsole is a JVM monitoring application that has been in existence since the release of Java JDK 1.5.x. With JConsole it is possible to explore all JMX managed beans in a virtual machine once the JVM is configured to allow JMX remote access as described above. The JConsole executable can be found in the bin directory for your JDK1.5.x or greater installation. Launch JConsole and select the "Remote Process" option button. Enter "localhost: " in the entry text box, where the port is the configured JMX listener port. Then select the "Connect" button. Once started, JConsole will display several tabs. Select the "Mbeans" tab. Along the left hand side is a tree view that lists each deployed Mbean in the JMX Managed Bean Server. The treeview allows exploring down to each Mbean and displays each Mbean attribute or operation. Once you have navigated down to the bean level JConsole will display the Mbean name in the display on the right hand side. Notes:
Individual JMX Attribute AccessFireScope makes available a client access tool called jmxclient for querying and setting individual Mbean attributes and invoking Mbean operations. As described above, the JConsole utility can be used to determine the names and attributes of Mbeans deployed in a particular java virtual machine. The bean names, attributes names and operation names are passed to the jmxclient tool for access. First deploy the jmxclient.jar file to an appropriate location on your monitored system. The following example uses a bean names from a system that has a default Tomcat version 6.0.13 deployed running and configured for JMX access. The jmxclient tool uses the following command format:
The following example command line will retrieve the “requestCount� attribute from the deployed tomcat manager application that comes as a part of the standard Tomcat deployment:
Note the nested / complex bean name created by Tomcat shown again as follows: Invoking the above command returns the current requestCount. Now invoke the manager via a web browser as follows: Then re-invoke jmxclient tool to show that the request count increases with each manager invocation. Example of FireScope JMX Managed BeansThe FireScope solution is delivered with an application called SyslogListener. The SyslogListener application receives syslog messages over TCP/IP and transfers these messages to the FireScope database. The SyslogListener application contains a few managed beans which expose some data points which may be of interest to FireScope users. The exposed beans are described in the following table:
Accessing the FireScope managed beans can be accomplished via the following jmxclient invocations:
FireScope JMX Agent ConfigurationThe following list outlines prerequisites for enabling FireScope JMX monitoring on remote hosts:
For the purposes of this example we shall assume each of the following has been configured as described below:
To configure our new user parameter we edit the agent configuration file by adding the following line: FireScope JMX Server ConfigurationCreate a Configuration Item (CI) that references the UserParameter that was created in the previous section. See Creating a Configuration Item. JMX Enabling Your Own Java ApplicationsThe code listed below describes the steps necessary to make your applications JMX capable. The process covered outlines only standard Mbeans. For more information regarding other typs of Mbeans such as MXBeans, or DynamicBeans refer to the following JMX API documentation or Java tutorial: http://java.sun.com/javase/6/docs/api/. http://java.sun.com/javase/6/docs/technotes/guides/jmx/tutorial/tutorialTOC.html. For any class that you wish to make available to JMX you must write an Mbean interface that lists the available JMX methods. The Mbean interface name must have the same prefix name as the implementing class. Then provide an implementation for the above interface such as the following: package example: import java.util.Calendar;
public class ExecutionMessageCounter implements ExecutionMessageCounterMBean
{
private int lastIndex;
private long[] perMinuteMessageCount;
public ExecutionMessageCounter()
{
super();
lastIndex = 0;
perMinuteMessageCount = new long[1440];
}
public long getPerMinuteMessageCount()
{
int perMinuteMessageCountIndex = getMinuteIndexNow();
return perMinuteMessageCount[perMinuteMessageCountIndex];
}
public long getDailyMessageCount()
{
long dailyMessageCount = 0;
for(long oneMinuteCount : perMinuteMessageCount)
{ dailyMessageCount += oneMinuteCount; }
return dailyMessageCount; }
private synchronized int getMinuteIndexNow()
{
Calendar calendar = Calendar.getInstance();
int resultIndex = calendar.get(Calendar.HOUR_OF_DAY) * 60 + calendar.get(Calendar.MINUTE); return resultIndex;
}
}Now register your managed bean with the local Mbean server. Each bean must be registered using a unique name. For purposes of this example we shall use the domain of “example†and a name of “MessageCounter†as shown below: ExecutioinMessageCounter counter = new ExecutionMessageCounter();
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
try { ObjectName objectName = new ObjectName(“example:name=MessageCounterâ€); mBeanServer.registerMBean(counter, objectName); }
catch(Exception exception)
{ // Add appropriate exception handling }Change History
| Related Pages
|
Labels
