htop: Here’s how to customize it

htop is an interactive system-monitor, but also a process-viewer, process-manager, strace tool and more. Sysadmins may opt to use htop in cases where Unix top does not provide enough information about system processes. htop uses a cursor-controlled interface for sending signals to processes. Just one example where this comes in handy: you don’t have to type in PIDs, simply select one or more processes using your mouse or other input device.

Although similar to top, htop also allows you to scroll vertically and horizontally, so you can see all the processes running on the system as well as viewing them as a process tree. Below is a screenshot of htop, taken from the StackLinux VPS which hosts this blog…


How to customize htop

Now the fun part! With htop open, you can use your mouse or touchpad to navigate. Start, by clicking Setup (bottom left) or by pressing F2 or shift + s. This will open the following screen…

htop setup

Just about all of us use top and htop, however, more often than not, we don’t tweak to our liking. (Also read: how to customize top command and atop for Linux server performance analysis, here’s how). From the above screen you can tweak many settings. These settings are then saved to $HOME/.config/htop/htoprc

A copy of my htop config file:

(Feel free to backup and replace, then tweak some more.)

# Beware! This file is rewritten by htop when settings are changed in the interface.
# The parser is also very primitive, and not human-friendly.
fields=50 0 48 17 18 38 39 40 2 46 47 49 1
left_meters=CPU AllCPUs
left_meter_modes=2 1
right_meters=Blank Clock Uptime LoadAverage Tasks Swap Memory
right_meter_modes=2 2 2 2 2 2 2

htop tweaks made with Sysadmins in mind

  • Added detailed CPU usage line at the very top (System/IO-wait/Hard-IRQ/Soft-IRQ/Steal/Guest).
  • hid userland process threads. (Ever open htop and without scrolling the only processes visible are MySQL threads? This solves that. Optional)
  • Added NLWP column. NLWP = Number of threads in a process. (Eg. MySql) Useful when the above change is made.
  • Added detailed memory usage line. (mem/used/buffers/cache)
  • Change process lists to tree view.
  • Changed CPU count to start from 0.
  • Change CPU cores from 2, to 1 column. (may need more for high  # of cores)

Here’s a visual comparison. My tweaked config on the left and default htop on the right. (full sized image here):

tweaked htop config

This is a start, feel free to share your custom htop config. Also read: htop and top alternatives: Glances, nmon.

Tags: , ,