If you’ve ever logged in to a Linux server to check what’s going on, you’re probably using htop, a text-based system monitoring tool for Unix based systems.
It runs on host Unix systems, including OS X, via Homebrew: brew install htop
- Displays the CPU usage (each CPU core gets a line, my CPU was 4 hyper threads = 4 lines).
For CPU: Green = user apps, red = kernel usage. For memory: blue = low priority; yellow = IRQ.
- Displays the amount of processes and threads, load average (1, 5, 15 mins) and the system uptime.
- Has the columns. How to add more is shown below.
- List item for each process (or thread, if enabled);
- PID is the process ID
- PRI (“Priority”) is -20 (highest), 19 (lowest)
- VIRT is total amount of memory that can be allocated (including virtual)
- RES (“Resident”) shows actual physical memory used, S (status) R = running, ? = idle
- CPU% is amount of total CPU usage
- TIME is how much total cpu time that process is using
- The process path and name. See below for shortcuts to display environment, etc.
- Menu items: mouse can be used in addition to F keys, if enabled.
Use the mouse
While htop is a text-mode application, on most terminals, you can actually use the mouse to select processes, press the menu keys and navigate the Setup menu.
Selecting one or more processes
With the SPACE key, you can select multiple processes. You can them kill them via F9 .
Other things to do with a selected process:
- To view the environment variables of a specific process, just navigate to the process via the arrow keys and press E .
- Set IO priority via I .
- List open files with lsof with L .
- Trace syscalls with S .
- Toggle path with P .
Per default htop shows threads of non-system programs, but this can result in the list being very verbose (leading to a bunch of duplicate program names) and hard to navigate. To turn that off, simply go to Setup > Display Options and check off both “Hide kernel threads” and “Hide userland process threads”.
Alternatively, kernel and user threads can be toggled with K and H , respectively.
Add some more columns
Per default, htop doesn’t show all its information. To add more columns, go to Setup > Columns and choose some new ones. Which to choose? Here’s the ones I commonly use:
- PERCENT_CPU, PERCENT_MEMORY – shows how much a program is using in percentages
- IO_RATE – shows how much disk IO the process is using
Filter by users
To select and view a specific users’ processes, type U .
This entry was posted on Sunday, September 30th, 2018 at 20:28 and is filed underArticles. You can follow any responses to this entry through theRSS 2.0 feed. You can, ortrackback from your own site.