0

My Java application is deployed on Tomcat Application server. Using TaskManager, I can see CPU and memory usage. The memory usage shown by Jconsole for same process ID is different from the memory usage shown by Task Manager. This is because task manager shows whole system memory while Jconsole shows memory allocated to JVM. Kindly correct me if my understanding is wrong.

I want to log memory and CPU usage by my java application process Id for a particular span of time. If I am trying to use perfmon, it's showing usage of all the processes. Is there any way with which I can configure in perfmon for one particular process ID and which counters I need to select in it.

Thanks.

icedwater
  • 4,701
  • 3
  • 35
  • 50
jasminum
  • 471
  • 1
  • 7
  • 12

2 Answers2

0

"I want to log memory and CPU usage by my java application process Id for a particular span of time."

You can use the FlightRecorder from JavaMissionControl. It can be found in the binary directory of Oracle JDKs (>6 I think) and its called "jmc.exe". Add the following parameters to Tomcat, maybe CATALINA_OPTS:

-XX:+UnlockCommercialFeatures -XX:+FlightRecorder 

If you are only interested in the values you can use JMX. Have a look at the "MBeanBrowser" in JavaMissionControl, too. For example:

MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
double cpuLoad = (double) mbeanServer.getAttribute(new ObjectName("java.lang", "type", "OperatingSystem"), "SystemCpuLoad");
Stefan
  • 12,108
  • 5
  • 47
  • 66
0

Yes you can.

  1. Click on + to add a counter
  2. Select Process
  3. Select Tomcat from the list of instances of selected Object.
  4. Click Add >>

You can then unselect any counters you are not interested in. You probably want to keep % Processor Time, Working Set Private and Private Bytes on your graph. Thread Count and Page Faults can also be interesting.

Chris McCowan
  • 467
  • 5
  • 10