I want to find out CPU usage (in Percentage) of an Apache Tomcat Server(6.x) using JMX.
There is an attribute ProcessCpuTime
of MBean java.lang:OperatingSystem
. But, how to calculate usage percentage from it?
Thanks.
Take the difference of two samples and divide by the time between samples.
To get a percentage, multiply by 100.
Since you will probably want to do this over time, you can use a tool like http://jmxtrans.googlecode.com/ to query Tomcat via JMX and then graph it with Graphite.