Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please check this code for CPU utilization

Status
Not open for further replies.

rohansr002

Programmer
Feb 19, 2010
15
0
0
IN
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.
 
Some hints:

- Use the Java forum, this one is for J2EE questions.
- Post the relevant parts of code. You will get more answers that way

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top