60

I like to use htop to show me how the server is being used.

Unfortunately with modern servers, the machine might have 48 or even 120 cores. This means that I can only see the first few lines of htop and never the second half of the htop display that shows which processes are using the machine.

How can I hide all of the core-usage lines or even better aggregate them for some sort of statistic?

5 Answers 5

43

Open the setup screen using F2 or ShiftS. The first page of that screen is dedicated to configuring header meters, so you can remove "CPUs" and add "CPU average".

In recent htop versions, there also are "CPUs (1&2/4)" and "CPUs (3&4/4)" meters showing two cores per line, though this is more of use on 8–32 core systems.

To save two more lines, open the "Display options" page and turn off "Leave a margin around header".

3
  • 13
    Doesn't work. On a smaller machine it works. A configuration page pops up under the CPU usage bars. But on the bigger machines it doesn't appear because the CPU usage bars take up all of the screen... Any other idea? (And yes, it took me 2 hours to figure out why nothing changed when pressing F2)
    – Unapiedra
    Sep 3, 2014 at 12:48
  • Workaround 1: blindly, hit F2, then right arrow, then DEL. Workaround 2: shrink the font on your terminal to a ridiculously small value, then hit F2 and you should see a barely readable menu.
    – alexei
    Apr 4, 2021 at 23:57
  • Just as an addition, if your terminal doesn't respond to F2 in ssh. You can use F2 to edit htop in your local machine. And diff the config file(~/.config/htop/htoprc) before and after change. Then apply the diff to your remote machine.
    – Ynjxsjmh
    Apr 11, 2021 at 6:28
34

Based on grawity's answer, you can create a configuration that you like on a different machine and then copy it to the machine where the problem occurs.

The configuration is saved (under Debian) under ~/.config/htop/htoprc.

  1. On a machine where you can see past the header:
  2. Press F2 to get into the configuration.
  3. Move left to the "Left Column"
  4. Move down to select "CPU" and press F9 to delete it.
  5. From the right most column select "CPU Average" and press F5 to insert it instead.
  6. F10 let's you leave the menu.
  7. copy ~/.config/htop/htoprc to the larger machine.

In my case (120 cores) a configuration with "CPUs (1&2/4)" on the left side of the header, and "CPUs (3&4/4)" on the right side of the header looks good. As a result, the header takes up about half the screen and the other half lists the processes. Each line in the header shows four CPUs which is fine for me.

Sample configuration:

# 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=0 48 17 18 38 39 40 2 46 47 49 1 
sort_key=46
sort_direction=1
hide_threads=0
hide_kernel_threads=1
hide_userland_threads=0
shadow_other_users=0
show_thread_names=0
highlight_base_name=0
highlight_megabytes=1
highlight_threads=0
tree_view=0
header_margin=1
detailed_cpu_time=0
cpu_count_from_zero=0
color_scheme=0
delay=15
left_meters=Memory Swap CPU Load LoadAverage 
left_meter_modes=1 1 1 1 1 
right_meters=Tasks LoadAverage Uptime 
right_meter_modes=2 2 2 

#Alternative (Blind navigation) Press F2, left, F9. (If CPUs are the items in the header.) After this you can see what is going on and would continue by pressing F10 to quit the configuration.

Blind Navigation v2 (2020-07)

Thanks to islandman93:

New blind navigation: F2, right, delete, right, delete. Then you probably want to add cpu average to the left column

4
  • 4
    Blind navigation worked perfectly!
    – zplizzi
    Mar 26, 2018 at 21:46
  • 2
    New blind navigation: F2, right, delete, right, delete. Then you probably want to add cpu average to the left column Jul 23, 2020 at 15:23
  • Just for who is interested what items changes after modifying CPU. They are right_meters, right_meters and corresponding left_meter_modes, right_meter_modes.
    – Ynjxsjmh
    Apr 11, 2021 at 6:32
  • And for anyone using MacOs, you do Fn+delete not delete
    – JZL003
    Mar 15 at 19:37
-3

Try the 't' key.

None of the other answers helped. My top and terminal must be different. My top was installed via the procps-3.2.8-45.0.1.el6_9.1.x86_64 package on Oracle Enterprise Linux (repackaged RedHat Enterprise Linux) 6.9 and I was accessing it via PuTTY 0.62.

1
  • Well the thread is about htop, not top.
    – user1686
    May 23, 2018 at 20:15
-3

I just had this issue as well, system has 24 cores, boatloads of disks and interfaces, and I couldn't read the process data after all the mem/disk/net lines etc..

Simply starting it differently was the easiest solution:

atop -l

From the man page: Limit the number of system level lines for the counters per-cpu, the active disks and the network interfaces.

1
  • It didn't work for me Dec 2, 2020 at 12:38
-3

SuSE : Press F2, Press F10, press q, sed -i 's/AllCPUs/CPU/g' ~/.htoprc

debian : Press F2, Press F10, press q, sed -i 's/AllCPUs/CPU/g' ~/.config/htop/htoprc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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