MAPK FAMILY MEMBERS
3. MACROPHAGE ACTIVATION
3.1. Type II Interferons
3.1.4. Major histocompatibility complex II, MHC-II
This chapter provides tutorial notes on the Java monitoring and management console, jconsole. Topics include description of JMX technology, list of 'jconsole' command options, turning on JMX agent for local and remote connection, running 'jconsole' to monitor local and remote Java applications.
JMX Technology and 'jconsole' Tool
'jconsole' Command Options and Connection Window
'com.sun.management.jmxremote' - JMX Agent for Local Connection 'jconsole' - Connecting to a Local JMX Agent
'com.sun.management.jmxremote.port' - JMX Agent for Remote Connection 'jconsole' - Connecting to a Remote JMX Agent
Conclusions:
• jconsole is a GUI tool that allows you to monitor a local or remote JVM process using the JMX (Java Management Extension) technology.
• JVM processes must be launched with the default JMX properties turned on in order to be connected by jconsole.
• jconsole displays monitoring diagrams for heap memory usage, counts on loaded classes, counts on threads, and CPU usages.
JMX Technology and 'jconsole' Tool
"JMX (Java Management Extensions)": A Java standard API for management and monitoring of resources such as applications, devices, services, and the Java virtual machine. The JMX technology was developed through the Java Community Process (JCP) as Java Specification Request (JSR) 3, Java Management Extensions, and JSR 160, JMX Remote API.
JMX has been implemented into JDK 5 now. You can set out-of-the-box JMX monitoring and management properties when you start the JVM to run your Java application. This allows you to use local or remote JMX connectors to monitor your application.
JDK 5 offers a graphical user interface called "jconsole" that uses the JMX technology to monitor your Java application locally or remotely. The picture below shows you how "jconsole" works with your Java application:
'jconsole' Command Options and Connection Window
"jconsole": A graphical user interface tool that enables you to monitor and manage Java applications and virtual machines on a local or remote machine using the JMX technology.
The "jconsole" tool supports several command options, which can be obtained by the "-help" option:
C:\Progra~1\java\jdk1.6.0_02\bin\jconsole -help
Usage: jconsole [ -interval=n ] [ -notile ] [ -pluginpath <path> ] [ -version ] [ connection ... ]
-interval Set the update interval to n seconds (default is 4 seconds) -notile Do not tile windows initially (for two or more connections) -pluginpath Specify the path that jconsole uses to look up the
plugins
-version Print program version
connection = pid || host:port || JMX URL (service:jmx:<protocol>://...) pid The process id of a target process host A remote host name or IP address
port The port number for the remote connection
-J Specify the input arguments to the Java virtual machine on which jconsole is running
If you run the "jconsole" command without any option in JDK 1.6, you will get the connection window as shown below:
This connection window allows you to specify the connection information from UI instead of the command line.
'com.sun.management.jmxremote' - JMX Agent for Local Connection
Since JDK 1.5, JMX has been included the Sun JVM. You can turn on the out-of-the-box JMX agent when you launch the JVM to run your application. This enables "jconsole" to connect to the JMX agent to monitor you Java application local or remotely.
In order to run your Java application and allow "jconsole" to monitor it on the local machine, you need to turn the "com.sun.management.jmxremote" system property with the "-D" option on the "java"
command.
To this out, I modified the my PrimeNumberSeeker.java program with a higher ceiling value of 1000000 to let the loop running much longer:
/**
* PrimeNumberSeeker.java
* Copyright (c) 2008 by Dr. Herong Yang, http://www.herongyang.com/
*/
public class PrimeNumberSeeker extends Thread { private static final int ceiling = 1000000;
private static final int interval = 1000;
private static final int delay = 100;
public int count = 0;
public int current = 2;
public int[] primes = null;
public static void main(String[] a) {
System.out.println("Period, Current int, # primes");
PrimeNumberSeeker t = new PrimeNumberSeeker();
t.start();
int i = 0;
while (true) { i++;
System.out.println( i+", "+t.current+", "+t.count);
try {
sleep(interval);
To run this program with the out-of-the-box JMX agent turned on, I used the following commands:
C:\Progra~1\java\jdk1.6.0_02\bin\javac PrimeNumberSeeker.java
C:\Progra~1\java\jdk1.6.0_02\bin\java -Dcom.sun.management.jmxremote PrimeNumberSeeker
Period, Current int, # primes 1, 2, 0
2, 10, 4 ...
Now my application PrimeNumberSeeker.java is running with the JMX agent turned on for local connection. See the next section on how to run "jconsole" to monitor this application.
'jconsole' - Connecting to a Local JMX Agent
If you follow the tutorial presented in the previous section, the PrimeNumberSeeker.java is running in a JVM with the default JMX agent turned on.
Now we can run "jconsole" to connect to this JVM to monitor how my PrimeNumberSeeker.java is running in two ways:
1. Find out the PID (Process ID) of this JVM and use the "jconsole <pid>" command to start "jconsole"
and connect to this JVM on the local machine.
2. Use the "jconsole" command to start "jconsole". It will search for any JVM process that has the local
JMX agent turned on. You can make the connection by clicking the search result list.
Obviously, the second way is better, because I don't have figure out the PID of my running JVM process. Here what I did to run "jconsole" and connect it to the JVM that runs
PrimeNumberSeeker.java:
1. Run "C:\Progra~1\java\jdk1.6.0_02\bin\jconole". The connection window shows up with 2 JVM listed in the local processes section:
Name PID sun.tools.jconsole.JConsole 2204 PrimeNumberSeeker 736
2. Double click the name "PrimeNumberSeeker", the Java Monitoring & Management Console window shows with the Overview tab opened as shown in the picture below:
Cool. "jconsole" automatically collects some basic statistics like: heap memory usage, number of threads, number of classes, and CPU usage.
'com.sun.management.jmxremote.port' - JMX Agent for Remote Connection
If you want to run 'jconsole' on a remote machine to monitor a Java application, you need to launch the JVM with the default JMX agent turned on using this system property:
"com.sun.management.jmxremote.port=<portNum>"
Here is what I did to run my PrimeNumberSeeker.java with the default JMX agent for remote monitoring connections:
1. To run this program with the out-of-the-box JMX agent turned on, I used the following commands:
C:\Progra~1\java\jdk1.6.0_02\bin\java
-Dcom.sun.management.jmxremote.port=6789 PrimeNumberSeeker
Error: Password file not found: C:\Program Files\java\jdk1.6.0_02\jre \lib\management\jmxremote.password
2. I got this error because the remote JMX agent requires a password file to only give permissions to authorized remote connections. For testing purpose, I used this system property:
"com.sun.management.jmxremote.authenticate=false" to turn off the authentication function:
C:\Progra~1\java\jdk1.6.0_02\bin\java
-Dcom.sun.management.jmxremote.port=6789
-Dcom.sun.management.jmxremote.authenticate=false PrimeNumberSeeker
Period, Current int, # primes 1, 2, 0
2, 10, 4 ...
3. I tried to run "jconsole localhost:6789" to connect to this JMX agent remotely. But the connection failed with this error dialog box:
4. The connection failed because the remote JMX agent also requires a SSL client certificate. For testing purpose, I used this system property: "com.sun.management.jmxremote.ssl=false" to turn off the SSL function:
C:\Progra~1\java\jdk1.6.0_02\bin\java
-Dcom.sun.management.jmxremote.port=6789
-Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
PrimeNumberSeeker
Period, Current int, # primes 1, 2, 0
2, 10, 4 ...
Now I am ready run "jconsole" to connect to this JMX agent remotely. See the next section for more tutorial examples.
'jconsole' - Connecting to a Remote JMX Agent
If you follow the tutorial presented in the previous section, the PrimeNumberSeeker.java is running in a JVM with the remote JMX agent turned on waiting for remote connections at the port: 6789.
Now we can run "jconsole localhost:6789" to connect to this JVM remotely to monitor how my
PrimeNumberSeeker.java is running:
1. Run "jconsole localhost:6789". "jconsole" connects to my Java application correctly. The Java Monitoring & Management Console shows up.
2. Click the Memory tab, the memory usage detail information show up as shown in this picture: