I want to write a GUI that graphs CPU usage in real time. My goal was to be able to run a program from the GUI, and then once the program has started, a graph of the CPU usage would run that would illustrate how the program was using CPU resources. What's the simplest way of doing something like this? I'm developing on Linux, and am aware of tools like (h)top and mpstat.
EDIT: I should be a bit more descriptive, sorry. How can I get something like CPU usage from top, and redirect it to a GUI that illustrates it into a graph form in real time?