-
1. Re: Server Info listThreadCpuUtilization();
dimitris Apr 17, 2006 1:31 PM (in response to vignesh76)The total is just the sum of what gets reported by http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/ThreadMXBean.html#getThreadCpuTime(long) for each running thread, so the accuracy depends on the jdk implementation.
Do you count the elapsed time interval between 2 calls? I don't know also if xCPU is a correct assumption.
My take is the value of this information is to help you see how jboss spends internally its time, i.e. which threads are doing most of the work.
If you want information on jboss as a process, you better take this from the operating system. -
2. Re: Server Info listThreadCpuUtilization();
vignesh76 Apr 17, 2006 2:38 PM (in response to vignesh76)Thanks for the reply.
Yeah, I count the elapsed time interval between the 2 calls and the total cpu usage in this time interval. The no of CPUs is as reported by the jboss web-console, home page (Hardware section)
The JVM i'm using is
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
For example for a particular 2 minute interval the values I get are as follows
total thread cpu usage in 2 mins -->298760 ms, elapsed cpu time-->120,000 * 2 (no of cpus) = 240000 ms that results in
(298760 / 240000 ) * 100 = 124%
I thought of making this monitoring OS independent, and so looked for a method to get the cpu usage from the JVM. I guess there's no other way to acquire the cpu usage from the JVM directly. -
3. Re: Server Info listThreadCpuUtilization();
vignesh76 May 15, 2006 10:57 AM (in response to vignesh76)I found another way to accurately calculate % CPU usage using J2SE 5.0 management MBean OperatingSystemMXBean, which has an attribute ProcessCpuTime. Using this value provided accurate results for % cpu usage. The JConsole monitoring application that comes with J2SE 5.0 also uses this MBean to report cpu usage.
-
4. Re: Server Info listThreadCpuUtilization();
dimitris May 17, 2006 10:05 AM (in response to vignesh76)Looking at http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management/OperatingSystemMXBean.html
you'll see there is no ProcessCpuTime, so this is a Sun JDK feature (maybe is supported by other jdks as well). -
5. Re: Server Info listThreadCpuUtilization();
vignesh76 May 18, 2006 11:22 AM (in response to vignesh76)I thought it'll be useful to post a small code snippet also:
MBeanServerConnection server = ManagementFactory.getPlatformMBeanServer(); OperatingSystemMXBean sunOperatingSystemMXBean = ManagementFactory.newPlatformMXBeanProxy(server, ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, com.sun.management.OperatingSystemMXBean.class); //cpu usage in milli secs long currentCpuUsage = sunOperatingSystemMXBean.getProcessCpuTime()/1000000;
I could not find com.sun.management.OperatingSystemMXBean anywhere in jdk 5.0 docs. I came to know about it referring to the sourcecode of JConsole.
Regards