Tony Anecito
unread,Nov 10, 2010, 10:42:33 AM11/10/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to JavaSysMon
Hi Jez,
I am looking for an example on how to get the CPU utilization of a
java process
given a pid. I was able to use your api but there are no examples that
I could
find on the getting the CPU utilization. I can get the process from
JavaSysMon
then from that the user and system times but no idle time. The example
below is
what I tried to use but I get a 100% all the time.
//for as given processid get the CPU utilizationJavaSysMon js =
ProcessInfo[] psinfo = js.processTable();
publicstaticvoidprocessInfo(intprocessId) {newJavaSysMon();//get a
list of
Process infoProcessInfo pstemp;
pstemp = psinfo[i];
systemMillis = pstemp.getSystemMillis();
userMillis = pstemp.getUserMillis();
}
}
CpuTimes cput =
System.
System.
System.
System.
}
longuserMillis = 0, systemMillis = 0;for(inti=0; i<psinfo.length;i++)
{intpid =
pstemp.getPid();if(pid == processId) {break;newCpuTimes(userMillis,
systemMillis, 0);out.println("processId:"+
processId);out.println("processId
systemMillis:"+ systemMillis);out.println("processId userMillis:"+
userMillis);floatutil = cput.getCpuUsage(cput) *
100;out.println("processId CPU
Utilization:"+ util);
Where can I find an example I can use for windows for cpu utilization
given a
pid?
Also, I am looking for a way to get the number of processors used for
a given
pid also.
Thanks,
-Tony