Htop – functional process monitor

HTOP is an improved version of top. In my head he was always a Hyper TOP (htop). Nevertheless, the truth called is slightly different. The program took it from the name of the creator, who unfortunately is not called Hyper, but Hisham :( As a curiosity, I would like to add that we also have […]

HTOP is an improved version of top. In my head he was always a Hyper TOP (htop). Nevertheless, the truth called is slightly different. The program took it from the name of the creator, who unfortunately is not called Hyper, but Hisham :(

As a curiosity, I would like to add that we also have a Polish thread here. He was an inspiration for Hisham pinfo, a program used to better view info pages. Name pinfo comes from “Przemek info ” :)

Installation

Unlike previously described on the blog top, program htop is not installed by default. For its installation, it is necessary to compile the EPEL repository or to compile it yourself. I would like to point out here that EuroLinux is not responsible for packages that go beyond the standard repository. However, for the convenience of administrators, the EuroLinux repository has a package epel-release, which installs .repo files with keys, GPL license and preset file used by systemd.

To install htop we can do:

sudo yum install -y epel-release
sudo yum install -y htop

Htop compilation

For compilation and installation compiled htop you can use:

# Installation of dependencies
sudo yum install -y @development git libncursesw ncurses-devel
# Htop compilation
git clone https://github.com/hishamhm/htop.git
cd htop
./autogen.sh && ./configure && make
# Htop installation
sudo make install

Htop personalization

We can start personalizing htop by looking into the help tab (key F1 from the bottom menu). In many cases, there will be a small grinding – as a rule F1 is assigned to help the terminal emulator (also described on the blog terminator). What can we do in this case? It may sound a bit naïve, but you should click the mouse F1. No, this is not a joke – contrary to popular opinion, it is possible to write console applications with support for mouse buttons. Htop is a great example of a program offering this functionality. Another option is to use the key h or ?.

After reading the help, we can start configuring htop. The configuration file itself is in .config/htop/htoprc and despite the author’s warning contained in the file’s comment, it is much more readable and editable than the program file top.

Below is the appearance of the default htop configuration.

htop_default

We can use to start editing htop settings F2 or click the appropriate button. The first thing I would like to point out is that the section Meters has two columns, and the location of individual elements can be changed freely. To do this, select the item (or click on it with the mouse) and the key Enter we enter edit or add mode. We place it with arrows in a selected place. To change the style of displaying the element (e.g. bar graph, text information or mode imitating a seven-segment display), use the space key.

One change that I usually introduce is the removal of information about processor utilization broken down into individual processors. If you have a server that has more than 8 threads or cores (depends on the configuration / availability of HT (Hyperthreading) or SMT (Simultaneous Multi-Threading)), the amount of space occupied by CPU information is impractical. For this purpose, I choose the appropriate columns and a button delete I remove. For people who do not like keyboards, it is also possible to click. Then I add the record CPU average I place it at the very top of the left column and change the way information is displayed on Text.

I do similar things until my speakers look like this:

Left column:

  • Load average [Text]
  • CPU [Text]
  • Task Counter [Text]
  • Memory [Text]
  • Swap [Text]

Right column:

  • Clock [Text]
  • Uptime [Text]
  • Battery [Bar]

Of course, battery information is due to the fact that I use a notebook.

Then I suggest you go to the section Dispaly options, i.e. display settings, where according to my experience I have the following flags enabled:

  • Hide kernel threads – this option can sometimes be unchecked. However, kernel processes are usually not interesting, and effectively create the noise that we need to filter.
  • Dispaly threads in a different color.
  • Highlight program “basename”.
  • Highlight large numbers in memory counters.
  • Detailed CPU time (SYSTEM/IO-wait/HARD-IRQ/Soft-IRQ/Steal/Guest).
  • Count CPUs from 0 instead of 1 – this option matters if we use separator metrics.

The color section settings should be changed if our color palette set by the terminal emulator does not match the htop. As a rule, the background is problematic. For example, a palette Solarized Dark can be illegible with default htop colors. To read text more easily, change the htop color scheme.

The next changes take place in the section Columns where I delete the VIRT column (M_SIZE) and finish editing in this section. As a curiosity, I would like to add the option of adding an OOM column. This is a point value for deciding which process will be killed in the event that we run out of memory.

After editing, you must approve the changes with the key F10. The configuration file is then saved to $HOME/.config/htop/htoprc.

Ready htop settings accepted by the author;):

htop_customized

Searching | filtering | sorting

To search for processes, we can use the key F3. Search will search single process which will be selected for further editing (e.g. nice settings, killing or downloading information about environment variables). In turn, process filtering will show us all processes that meet the given condition (name) – the following example filtered processes after the name haroopad. An important observation is the fact that filtering takes place after the usual string of characters, not after the regular expression.

Another search option is to search for a process by PID number. To do this, simply enter it. The search is incremental. To understand what I mean, imagine that we have 3 processes in the system:

1 – systemd
123 – auditd
12345 – spotify
and there are no processes with PID 12,1234.

In this case, our transitions along with entering subsequent numbers will look like this:

“” ()
“1” -> (systemd)
“12” -> (systemd)
“123” -> (auditd)
“1234” -> (auditd)
“12345” -> (spotify).

We use to sort processes F6, and then from the menu select the column after which we want processes to be sorted. You can also use the mouse to click the selected column. It may be trivial, but worth mentioning is the fact that sorting processes according to a given criterion can be combined with filtering. If you need to reverse the sorting condition, use the key I. Other abbreviations that can be used are < and >. However, unlike top they will not change left or right respectively, the column after which we sort, but call the sorting menu.

The last filter that I would like to present in the htop program is process filtering for the user’s sake. We use the key for this purpose u, and then we make a selection from the menu that will appear on the left. The user can be selected using the arrows / mouse or by entering the beginning of his name. This is a much better solution than in the top, where you need to enter the full username.

blank

Other useful features

p – prints the full command path
e – shows the environment (enviroment) of the selected process.

thanks

As usual, I would like to thank you for the time spent reading our blog. If you liked the text, I encourage you to send it to your colleagues and subscribe to the newsletter.

blank Authors

The blog articles are written by people from the EuroLinux team. We owe 80% of the content to our developers, the rest is prepared by the sales or marketing department. We make every effort to ensure that the content is the best in terms of content and language, but we are not infallible. If you see anything that needs to be corrected or clarified, we'd love to hear from you.