Over a million developers have joined DZone.

Monitor the Health of Your System

DZone's Guide to

Monitor the Health of Your System

If you are relatively inexperienced with performance, like this author was, here are some performance analysis programs to get you started.

· Performance Zone ·
Free Resource

Container Monitoring and Management eBook: Read about the new realities of containerization.

When I first got a requirement to pick up tools in "Performance Monitoring" of any application, I thought it was an ardent task as I was new to this area. Primarily I got overwhelmed by the expensive tools in the market which costs thousands of dollars. There was also lot of jargon about performance monitoring kept me dis-interested. However, due to job pressure, I decided to chalk out a plan to pick up the basics of performance monitoring and tuning. In this article, I would capture some of the open source tools available to easily check the memory/CPU/thread usage for an application.

First things first: This article assumes that the application is hosted on any Java based server (JBoss, WebLogic etc) which internally uses JVM to run and execute the programs. Basic knowledge of heap, stack, CPU usage must be familiar to the user.

Let's take a tour of some command line that is available by default with Oracle/SUN JDK.

Also, we will discuss GUI-based performance monitoring tools available as plugins in Eclipse IDE.

JPS Command:

Assume a Java process is running on the system, you can find out the Java process using the command: jps -l. For example:

List of Java Process by Id

It is clear from the above example there are a few processes and the ID is shown mapped to the process. Once the Java process ID is obtained, we can use a variety of tools to get health of that particular process in terms of memory, CPU, and thread usage.

JMap Command

In the below example, the heap usage is shown at that particular instant of time using the "jmap" command.

Image title

The Eden Space section explains the used heap size by the Java process mentioned in the command which is 1145 MB out of available 1364MB. Note heap can resize based on the usage by JVM and the maxiumum heap as shown above is 4GB. The only issue with JMap is the command is intrusive that it temporarily stops the JVM to obtain the stats on the heap.

JStat Command

Alternatively, JStat command can also be used to get a snapshot of the heap usage in a similar way as JMap.

Image title

The heap utilization is the sum of the following parameters: OU+EU+S0U+S1U, where the variables mean the following:

OU — Old Space Utilization

EU — Eden Space Utilization

S0U — Survivor Space1 Utilization

S1U — Survivor Space2 Utilization

JStack Command: To get an idea of stack utilization by the process, we can use this command. Recall that JVM allocates stack space for function level variables and thread related parameters.  All objects are however assigned space within the heap memory. Hence this command gives information stack memory usage.

For eg: jstack <javapid>

Image title


Let's now move on to GUI-based monitoring tools. One frequently-used tool is JConsole which gives a real time monitoring of the health of the system based on the process ID. Type jconsole on the command prompt that will open up the "Java Monitoring and Management Console."

Image title

In the captured screenshot, the memory usage graph is clearly shown with time on the X-axis and usage in MB on Y-axis, as well as information on the GC mechanism. Note the green boxes on the bottom. These are very helpful to give old, eden, and survivor space utilization. Clicking on the first bar above the "Heap" gives the Old Generation usage, the second gives Eden Usage, and third box gives Survivor Space utilization. Similarly the other tabs like "Threads" and "Classes" give the usage of the same on the system. The "VM Summary" gives overall summary about the JVM and is quite helpful in terms of live memory usage, committed memory, and threads running.

Visual VM

This is yet another interesting GUI tool that helps the developer monitor the health of the system. It is an Eclipse plugin and can be downloaded and updated in Eclipse. Visual VM is similar to JConsole except that the representation is quite clear and in a presentable format.

Image title


With the above discussed tools the developer can understand resource usage in terms of memory, threads, and stack usage. Since all these tools are open source and easily available, the first level analysis and debugging can be done using these. There are other tools like Memory Analyzer that can be downloaded from Eclipse marketplace which can give deep drive into resource usage on method level and can be quite useful. Using these tools can give the developer unusual resource usage, detect memory leaks over time and help avoid application crashes on the live system. Further, these tools can help developer point any code level mishaps that can be potential issue in the future. Hope these tools help others as much as it helped me in picking up this topic.

Take the Chaos Out of Container Monitoring. View the webcast on-demand!

performance engineering ,performance tools ,java ,open source ,real time monitoring

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}