CPU usage per process
-
Is there a way to list the CPU usage per process of all the processes that are currently running in the system. What I mean is CPU % usage as is shown in the Taskmanager. I have tried a few API like sigar and JavaSysMon but am not able to get accurate values of the %'s.
-
Is there a way to list the CPU usage per process of all the processes that are currently running in the system. What I mean is CPU % usage as is shown in the Taskmanager. I have tried a few API like sigar and JavaSysMon but am not able to get accurate values of the %'s.
I would guess that the only way to get reasonable data if the
JavaSysMon()
method does not do it, is to use the native process and thread functions[^], using C/C++. This would mean you will have to write JNI[^] or JNA[^] code to act as the interface between C++ and Java.Unrequited desire is character building. OriginalGriff
-
Is there a way to list the CPU usage per process of all the processes that are currently running in the system. What I mean is CPU % usage as is shown in the Taskmanager. I have tried a few API like sigar and JavaSysMon but am not able to get accurate values of the %'s.
-
Steps. 1. Find or create a command line tool that does that. 2. Use java Runtime.exec() to run it and get the results.
These days you should probably prefer ProcessBuilder to Runtime for executing external processes. ProcessBuilder does everything Runtime.exec does and more, so it's probably worth getting into the habit of using it. After all it has been around since 1.5 which came in years ago.