Posted by: Rakesh Menon on: June 29, 2009
Execute top using ProcessBuilder, get the Process instance. Get the output stream from process and read the output of top command. Now parse this content (a bit tricky, each version had its own output format) to get the CPU and Memory information. Plot the chart using JavaFX chart APIs.
For Applet mode, click on above image
Note: The implementation is not concrete (as it relies on simple text parsing), may not work on some platforms or locales due to difference in output of top command. It will not work on platforms which does not support top command.
Source available here