rohansr002
Programmer
I am working on this code for CPU Utilization, i am getting output as "0.0", for including the class file u need to Add .jar file, which is at Url " JavaSysMon 0.3.0 from this url and to Library.
The code is as follows:
import com.jezhumble.javasysmon.*;
public class CpuUtilize {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
JavaSysMon obj1= new JavaSysMon();
long p1=obj1.cpuTimes().getUserMillis();
long p2=obj1.cpuTimes().getSystemMillis();
long p3=obj1.cpuTimes().getIdleMillis();
CpuTimes previous=new CpuTimes(p1,p2,p3);
//JavaSysMon obj1= new JavaSysMon();
Float tr1= obj1.cpuTimes().getCpuUsage(previous);
System.out.println("The Cpu Utiliztion Value: "+tr1);
}
}
...
1. I am unable to understand how to get CPU Utilization from this code, as it is giving "0.0" output.
please Help as soon as possible.
The code is as follows:
import com.jezhumble.javasysmon.*;
public class CpuUtilize {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
JavaSysMon obj1= new JavaSysMon();
long p1=obj1.cpuTimes().getUserMillis();
long p2=obj1.cpuTimes().getSystemMillis();
long p3=obj1.cpuTimes().getIdleMillis();
CpuTimes previous=new CpuTimes(p1,p2,p3);
//JavaSysMon obj1= new JavaSysMon();
Float tr1= obj1.cpuTimes().getCpuUsage(previous);
System.out.println("The Cpu Utiliztion Value: "+tr1);
}
}
...
1. I am unable to understand how to get CPU Utilization from this code, as it is giving "0.0" output.
please Help as soon as possible.