4

I need to monitor CPU and network utilisation from a terminal.

For network traffic, I have found the perfect tool: slurm. It gives me a moving chart. It gives me an nCurses-like UI I can use from a tty.

Here's a screenshot: slurm 0.3.3 on Falce

Is there a slurm equivalent showing CPU utilisation?

  • 3
    htop? Though it's not as pretty/big as slurm's chart, see the second PNG from bottom at htop.sourceforge.net/index.php?page=screenshots – livibetter Nov 28 '12 at 23:03
  • That's what I use at the moment: htop. And I love it for process monitoring. For utilisation charts? ASCII art just doesn't cut it, does it? – Robottinosino Nov 29 '12 at 13:12
  • nmon might help. – Spike Jul 19 '16 at 3:06
18

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.

EDIT:

Screenshot:

ttysys example

Install:

You will have to compile it from source. I provided a simple makefile that calls gcc.

You can run the program using make then ./build/target/ttysys Alternatively, you can run make install followed by ttysys since it is in your path now.

Usage:

$ ttysys [<sequence>]

sequence can consist of any number of the following characters:

  • ? - Displays a help window.
  • h - Split current window horizontally.
  • v - Split current window vertically.
  • c - Close current window.
  • Tab - Move to next window in order of creation.
  • Arrow Keys - Move to next window on screen in direction pressed.
  • Numbers 0 - 9 - Select a data source for a window.
    • 0 will set the data source to an overview, and 1 - 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.
  • u - Same as pressing up arrow key. Move to window above current one.
  • d - Same as pressing down arrow key. Move to window below current one.
  • l - Same as pressing left arrow key. Move to window left of current one.
  • r - Same as pressing right arrow key. Move to window right of current one.

These same buttons will control the program while it is running.

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 /proc/stat.
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.

  • 1
    Nice work. Could you include a screenshot here and also a bit more about the tool? We like answers to be able to stand on their own and not just be links. Great job on the tool BTW. – slm Dec 28 '13 at 3:15
  • Good job. I've made one myself although much less features. None to be exact :) github.com/mnmnc/cpuchart – mnmnc Oct 30 '14 at 14:13
  • Try: ttysys hvm$'\t'v$'\t'1h$'\t'3h$'\t'2$'\t'4 for a quad core CPU. – Aziz Alfoudari Jun 6 '18 at 15:28
  • r,l,u, and d can be used in the argument for arrow keys: right, left, up, and down - so ttysys vhmdhh1r2rh3r4 should accomplish the same result – Cody Creager Aug 1 '18 at 4:40
  • Which occurs to me is an undocumented feature which conflicts with the incorrect documentation of u for unsplit, it should be c for close. I should update my readme and answer. – Cody Creager Aug 1 '18 at 4:52
4

Try:

  • tload, which is typically installed by default
  • ttyload is pretty good, too

ttyload screen sample ttyload screen sample

3

Take a look at Glances. I think it might fit your bill.

http://nicolargo.github.com/glances/

enter image description here

  • Looks very cool. Will have to wait until it graduates to the Ubuntu package list, though. I could use something from the standard apt-get repository (no addition of a PPA) with less functionality but full support... – Robottinosino Nov 29 '12 at 13:07
  • No need to wait, just grab the script and run it. It looks like a single script program. If not, use pip to install it. – livibetter Nov 29 '12 at 13:41
  • It's based on python, pretty standard. – Mark Cohen Nov 29 '12 at 17:29
  • i just installed Glances, but I only see real time info just like top provides. Is it also possible to chart CPU usage with Glances? – kramer65 Aug 20 '18 at 10:24
2

I'm a fan of htop. (http://hisham.hm/htop/)

enter image description here

To install:

sudo apt-get install htop
  • 1
    htop has its uses, but it can't show a moving chart of CPU usage over a period of time, as described in the question. It can only show meters of the current CPU usage. – Rory O'Kane Jun 2 '17 at 20:48
  • sorry but couldnt stop myself, your computers name is lulz? that's so hilarious lol ^^ – MuhsinFatih May 27 '18 at 9:51
  • No, hah. That's just an image I pulled from image search. Someone's computer's name is lulz though. – Enigma May 29 '18 at 13:49
2

I use elmon (http://elmon.sourceforge.net/) it may draw graphs not only for the CPU. For example: Example Screenshot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.