Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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

share|improve this question
add comment

5 Answers

up vote 31 down vote accepted

Depending on what you want to see, there are several options on Terminal level:

  • top: show running processes, memory usage and similar stats
  • iostat: show I/O per terminal, device and SPU summery statistics
  • vm_stat: show Mach virtual memory statistics
  • df and diskutil list: report on drive space used and free
  • fs_usage: show file activity for both disk and network
  • nettop: display updated information about the network (a bit like top for net I/O)
  • w: display who is logged in, what they are doing and system load
  • 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 hugging processes and fs_usage -f filesys/fs_usage -f network to identify processes generating a lot of disk/network load.

share|improve this answer
    
This is what I wanted! Thanks. –  gentmatt Feb 5 '12 at 19:25
add comment

Here are two commands for determining your local and public IP:

Local IP

ipconfig getifaddr en1

This is when using Wi-Fi. For ethernet use en0.

Public IP

curl whatismyip.org
share|improve this answer
1  
On current MacBook Airs (which don't have an ethernet port) the Wi-Fi device code is en0. You can find out what it is with networksetup -listallhardwareports | grep -E '(Wi-Fi|AirPort)' -A 1 | grep -o "en.". –  Lauri Ranta Feb 23 '12 at 23:05
add comment

If you are having network problems, especially with a server exposed to the Internet, lsof(1) can be extremely useful. It lists all open files.

For example, lsof | fgrep '/Library/WebServer/ will show you all the files that are open on your web server. I've been using this a lot to find and ban "leeches" and "bots" who are reducing my bandwidth by automatically sucking down file after file.

share|improve this answer
add comment

The above are great commands. Also, I like to use

du -ks *

To show how much disk space all the folders below my current directory are using.

share|improve this answer
add comment

You can use top. It'll show CPU & RAM usage together with all the processes. It'll also show you network packets in/out, and discs data read/written.

share|improve this answer
2  
And with man top you can see how to customize the output. –  Rene Larsen Feb 5 '12 at 13:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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