From: guy_vt <sig...@hy...> - 2010-06-09 22:46:04
|
I want to use Sigar to monitor a running process for CPU load. So far I have only gotten values smaller than 1 percent. So I wanted to test how it would handle higher CPU values and whether it gave correct values under load. It would appear that it doesnt: I am using the following code: try { Sigar sigar = new Sigar(); long id = sigar.getPid(); ProcCpu cpu = sigar.getProcCpu(id); System.out.println(cpu.toString()); while (true) { cpu = sigar.getProcCpu(id); System.out.println("cpu=" + cpu.toString()); } } catch (Exception e) { e.printStackTrace(); } I get the following output: cpu={LastTime=1276071236204, StartTime=1276071231143, Percent=8.504036623604765E-299, Sys=296, User=1388, Total=1684} cpu={LastTime=1276071236204, StartTime=1276071231143, Percent=8.504036623604765E-299, Sys=296, User=1388, Total=1684} cpu={LastTime=1276071236205, StartTime=1276071231143, Percent=16.0, Sys=312, User=1388, Total=1700} As you can see it occasionnaly returns 15-16% but appart from that it returns a rediculously low values. Another problem is dat the javaw (I run under Eclipse) process consumes more than the 15-16% ! I am running on Windows Vista using a Sun java 1.5.0_15 |