问题
I need to get info for memory and CPU usage of some process running on the machine (not the Java process).
How can I do that?
回答1:
It's platform dependent, but essentially use Runtime.getRuntime()
to execute the appropriate command, capture its output and parse it for the data you need.
回答2:
If I'm not mistaken Runtime.getRuntime
is for the virtual machine and not the physical. What you are about asking is getting the physical machine information (meaning the CPU).
来源:https://stackoverflow.com/questions/7377271/how-can-i-get-memory-and-cpu-usage-of-an-external-process-with-java