Can I view system stats in the Terminal?

The widget iStat Pro allows to monitor different system stats like

  • CPU usage
  • network bandwidth in/out
  • memory usage
  • ...

How can I view such system stats in the Terminal?

enter image description here


Solution 1:

Depending on what you want displayed there are several options available using Terminal:

  • top: real-time sorted display of running processes such as memory and CPU usage
  • iostat: I/O summary statistics for terminal, device and CPU operations
  • vm_stat: Mach virtual memory statistics
  • diskutil list: disk/volume capacity
  • df: used/free space on mounted partitions
  • fs_usage: real-time file activity for both disk and network
  • nettop: updated information about the network (a bit like top for net I/O)
  • w: who is logged in and what they are doing; plus a brief system load summary
  • ifconfig and ipconfig: network interface and IP protocol details

Most of these commands have a huge list of options.  It's probably best to consult the man pages for details.

I usually rely on:

  • top -u -s 10 to identify CPU-hogging processes;
  • fs_usage -f filesys or fs_usage -f network to identify processes generating a lot of disk/network load.

Solution 2:

The iStats ruby gem lets you see the CPU temperature via the command-line.

Installation

$ gem install iStats

Usage

$ istats

Screenshot