This content has been marked as final. Show 5 replies
JConsole's CPU usage graph is computed as follows:
... long elapsedCpu = result.processCpuTime - prevProcessCpuTime; long elapsedTime = result.upTime - prevUpTime; // cpuUsage could go higher than 100% because elapsedTime // and elapsedCpu are not fetched simultaneously. Limit to // 99% to avoid Plotter showing a scale from 0% to 200%. float cpuUsage = Math.min(99F, elapsedCpu / (elapsedTime * 10000F * result.nCPUs)); ...
* processCpuTime: com.sun.management.OperatingSystemMXBean.getProcessCpuTime()
* upTime: java.lang.management.RuntimeMXBean.getUpTime()
* nCPUs: java.lang.management.OperatingSystemMXBean.getAvailableProcessors()
JConsole is open source and the code is available in the OpenJDK site.
Have a look at the java class sun/tools/jconsole/SummaryTab.java.
Luis-Miguel Alventosa - JConsole dev team
Thank you for answering my question! I had looked for the open source JConsole, but somehow missed it ... I'll go look again. I was able to implement based on the information you gave me and it works great.
Somehow, when I registered, my screen name got messed up (notice this is timpanogos1, not the original timpanogos) ... I've posted an enquiry to get this fixed so I can award you your points and mark this question answered.
Thanks again for you prompt response ... much appreciated!
P.S. Feedback - Sun Microsystems FID:18088
Edited by: timpanogos1 on Jun 14, 2008 9:33 AM
Thanks again ... finally got my account straight and marked this as answered correct
Can You tell me from where to download com.sun.management package ?
Welcome to the forum. Please don't post in threads that are long dead and don't hijack other threads. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem.
I'm locking this thread now.