Is there a way in monitoring cpu usage using purely java language? if yes, can you please share some articles regarding this topic. thank you.
+1
A:
This is not possible using pure Java. See this article for some ideas.
kgiannakakis
2010-01-14 05:55:06
+1
A:
Maybe if stuck, you might 'sense' cpu availability by running an intermittent bogomips calculator in a background thread, and smoothing and normalising its findings. ...worth a shot no :?
strainer
2010-01-14 06:11:06
This is a reasonable idea. You'll have to use proper microbenchmark tricks though (run for some length of time, warm up all loops before timing, use `System.nanoTime()`). There will still be a fair bit of flutter in performance too over the timing interval.
BobMcGee
2010-01-14 06:25:37
+3
A:
There is a gem in the comments on the article which kgiannakakis linked:
JavaSysMon manages processes and reports useful system performance metrics cross-platform. You can think of it as a cross-platform version of the UNIX `top’ command, along with the ability to kill processes. It comes in the form of a single JAR file /..
-works on Windows, Mac OS X, Linux, and Solaris.
strainer
2010-01-14 07:15:58
A:
How about using jmx mbeans?
final OperatingSystemMXBean osbean =
ManagementFactory.getOperatingSystemMXBean();
double load = myOsBean.getSystemLoadAverage();
baskin
2010-01-14 10:47:07