I need to run a cpu load monitor on a server. I'd like to create a separate process for that purpose, instead of instrumenting a messy blob of server application code. The question is simple though:
How can I get the system cpu usage (overall and per core, in percentage) using Java?
I've checked OperatingSystemMXBean.getSystemLoadAverage(), but it gives me the average system cpu load of the last minute, which is too long for me. I need to monitor the load every second (or less). Besides this one give the overall system cpu load.
Finally, is it possible to get the cpu usage of threads that belong to another Java process?