How to use the / JVM cpu process programmatically in Java

I am trying to control all running Java virtual machines.

Unfortunately, I could not find a way to reliably extract the processor utilization (for example, in percent) of certain processes or virtual machines.

I know about SIGAR , but calling ProcCpu getPercent () is not reliable at all. (several queries needed to get the result)

So far, I have managed to get the PID list for all virtual machines.

If possible, a cross-platform approach (at least windows and linux).

edit: I took a closer look at the approach Fraser refers to, but couldn't figure out how to access my virtual machines using

ObjectName.getInstance("java.lang:type=OperatingSystem");

If I'm not mistaken, it is only possible to access (java) the processes that you started and registered yourself.

+4
source share

Source: https://habr.com/ru/post/1611819/


All Articles