I couldn't find a live, text-only CPU chart either. So, I made one.
Here's a link to my github repo: https://github.com/rigel314/ttysys
Try it out if you like, and please report any errors on my repo's issues page.
You will have to compile it from source. I provided a simple makefile that calls gcc.
You can run the program using
Alternatively, you can run
make install followed by
ttysys since it is in your path now.
? - Displays a help window.
h - Split current window horizontally.
v - Split current window vertically.
u - Un-split current window.
- Tab - Move to next window in order of creation.
- Arrow Keys - Move to next window on screen in direction pressed.
9 - Select a data source for a window.
0 will set the data source to an overview, and
9 set it to a specific core.
g - Toggle grid for selected window.
e - Toggle value display in current window's title.
t - Toggle display of current window's title bar.
l - Toggle display of current window's label sidebar.
q - Quit this program.
How it works:
It works by reading the first few lines in
/proc/stat that begin with cpu.
man 5 proc explained the meaning of contents of
These lines tell you how much time each CPU spent in different states. The sum of each line is the total time spent for each CPU. I read this file twice with a second in between. Then, I subtract the two totals to have the total CPU time spent during my
sleep(). Now, I add the user and system numbers together and divide by my difference. Finally, it's just a matter of displaying it nicely.