I am trying to monitor all running Java virtual machines.
Unfortunately I couldn't find a way to reliably retrieve the cpu usage (e.g. in percent) of specific processes or VMs.
I know about SIGAR, but the ProcCpu getPercent() call isn't reliable at all. (multiple invocations needed to get a result)
So far I managed to get a list of PIDs for all VMs.
Should be a cross-platform approach if possible (at least windows & linux).
edit: I took a closer look into the approach referenced by Fraser, but couldn't figure out how to access my VMs using
ObjectName.getInstance("java.lang:type=OperatingSystem");
If I am not mistaken, it's only possible to access (java) processes you started and registered yourself.