20

Why does the same version of htop have so different layout of the CPU meters? How to switch between the layouts?

Layout 1

htop --version htop 2.0.2 - (C) 2004-2018 Hisham Muhammad Released under the GNU GPL. Layout 1

Layout 2

htop --version htop 2.0.2 - (C) 2004-2017 Hisham Muhammad Released under the GNU GPL.

Layout 2

3 Answers3

18

Ok, that was easy. Although it is not particularly well explained in the man page, after some tinkering in the setup I found an answer.

Press F2 and using Enter and arrows setup the following for Layout 1:, Layout 1

For Layout 2 setup this: Layout 2

  • 1
    it's also interesting to take a copy of ~/.config/htop/htoprc before playing with these and compare using diff afterwards. While the documentation (and the warning at the top of the RC file) are pretty useless, you can reverse-engineer it by playing around a lot. Or just copy one in with preferred settings, if it's from the same version of htop. – mike Feb 17 '19 at 22:25
13

See ~/.config/htop/htoprc

To put All CPUs in a single column, with Tasks/Load/Uptime on right (1st example):

left_meters=AllCPUs Memory Swap
left_meter_modes=1 1 1
right_meters=Tasks LoadAverage Uptime
right_meter_modes=2 2 2

or, for 2nd with half the CPUs on Left, and half on the Right:

left_meters=LeftCPUs2 Memory Swap
left_meter_modes=1 1 1
right_meters=RightCPUs2 Tasks LoadAverage Uptime
right_meter_modes=1 2 2 2

Note that the meter modes cycle through bar, text, LED etc in a non-intuitive way.

mike
  • 231
  • I'm tried the first config to make my htop look like layout 1 but it still lists the processes. – dman Aug 03 '19 at 05:21
  • @dman I don't understand. htop is supposed to list the processes. Do you want it to change between listing processes and threads? Or to show the process tree? Look at the F-keys (usually F4 Filter, F5 Tree, F6 Sort by) – mike Aug 05 '19 at 22:42
6

TL/DR: You might be using a htoprc optimized for another device

  • Delete your ~/.config/htop/htoprc
  • Start htop on the computer with the most cores
  • Get Layout 2

What's going on?

Supported by personal anecdotal evidence, this problem can also be caused by your htoprc being tailored to a specific machine. The preferred layout is saved to .config/htop/htoprc the first time you start htop. Or, more specifically, any time you close htop when there is no htoprc present. When you log into a machine using the same home folder (for example using LDAP) you still use the htoprc from the fist time you launched htop.

In my case, I work on a terminal with 4 CPU cores (first launch, determined the layout) and can log into a compute server with 128 CPU cores (does look like your Layout 1). I couldn't even see the option tray, let alone use it (even with @mike's solution, which only generated two columns in my case). I was still using the same home folder and my htoprc was hence optimized for 4 Cores.

How to fix that?

By removing ~/.config/htop/htoprc (or your local flavor of htop's config file), a new file is written on startup. This is optimized for the number of CPUs of the computer you currently work on. So make sure, you are logged into the device with the most cores (or the one which generates a layout you prefer).

For me personally, having four columns for the 4 core system looks a bit funny, but it beats not being able to see processes on the compute server.

Additional notes

The htoprc written automatically on the compute server was identical to perferming the replacement @mike suggested in my old config. However, I received two different layouts, none of them looked like the desired Layout 2. The diff of the config files was empty, so I guess the comment in the htoprc

# The parser is also very primitive, and not human-friendly.

is true, insofar as the parser is not human friendly ;)

m00am
  • 251