Getting CPU utilization of Java processes

Hi,

I have a java application running as a service in my unix Box. I want to test the CPU utilization and the Memory utilization of the app. I used top command and also the ps commands

This command is showing each thread in my app as a separate thread. So I have a lot of j9 entries.

Now my question is, if I get the utilization data of the parent process, will that give me the cummulative CPU and memory usage of my app ???

Are there any other tools which can be used to monitor java processes ??

I don't know if there are any tool exclusively for java.

But I am pretty sure that utilization of parent process won't give you cumulative measurements. Of course you can use ps and calculate it yourself by each process.

If the java processes are the only service on this box use vmstat (the CPU-related columns). Alternatively use sar, when you need to monitor longer time intervals.

I hope this helps.

bakunin

You can monitor these kinds of statistics, and more, with Java Management Extensions (JMX). Because the Java Virtual Machine has specific quirks with how memory is utilized (say, separating the memory space into partitions such as heap and non-heap space), just looking at the OS-level resource utilization is not generally adequate. Depending on how you configure, you may either monitor a local process or a Java process running on another system, via a graphical user interface tool such as JConsole (or VisualVM although I cannot get it run properly).

With JMX, you can even write some simple Java program to log selected statistical values periodically on a 24x7 basis and analyse them later offline.

You can refer to this document for an introduction of Java SE management and JMX technology:

- Java SE Monitoring and Management Guide

Or read the JMX specification if you wish to get more in-depth programming knowledge.