'SystemCpuLoad' for System CPU usage coming different if called from different JVMS

482 views Asked by At

I have two JVM's where one JVM(JVM 1) is lightweight and another JVM (JVM 2) does heavy tasks. When I try to get System usage from JVM's by fetching 'SystemCpuLoad', JVM 1 is giving correct CPU values (matching SAR values) and another JVM which does heavy work is giving high CPU usage not matching SAR values. Followed the below approach :

final ObjectName mapMBeanName = new ObjectName( "java.lang:type=OperatingSystem" );
MBeanServer server = ManagementFactory.getPlatformMBeanServer();
cpu =100.0 * Float.parseFloat( server.getAttribute( mapMBeanName, "SystemCpuLoad" ).toString() );

Can anyone help me how can I get correct System CPU usage irrespective of whether the JVM process does the heavy task or lighter task?

0

There are 0 answers