跳至主要内容

emulate htop with top

The top program from procps-ng (debian, centos/el7 later)

Ever being with htop for some time and miss the process tree and graphical CPU/memory usage?

The top program from procps-ng (debian, centos/el7 later) can easily emulate the presentation of htop view.

Start the top program, it looks like following with its default configuration:

top - 09:20:54 up 307 days, 22:58,  4 users,  load average: 0.80, 0.74, 0.75
Tasks: 486 total,   1 running, 485 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.6 us,  0.6 sy,  0.0 ni, 98.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 65796532 total,   808264 free, 22970744 used, 42017524 buff/cache
KiB Swap: 16777212 total, 15433868 free,  1343344 used. 39944388 avail Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
30561 clouder+  20   0   16.0g   2.3g  23296 S  11.6  3.6  11037:25 java
  703 yarn      20   0 2586468 429556  20704 S   1.0  0.7 258:14.48 java
   10 root      20   0       0      0      0 S   0.7  0.0   3613:19 rcu_sched
 2736 ericsson  20   0  162316   2684   1588 R   0.7  0.0   0:00.12 top
 2979 hdfs      20   0 6243524   1.9g  21560 S   0.7  3.0 576:11.19 java
 7197 root      20   0       0      0      0 S   0.7  0.0   0:34.26 kworker/8:2

Press ttmmcVz in the top screen, then the top view will be turn to like this:

top - 09:25:20 up 307 days, 23:03,  4 users,  load average: 0.61, 0.60, 0.68
Tasks: 485 total,   2 running, 483 sleeping,   0 stopped,   0 zombie
%Cpu(s):   0.9/0.6     1[                                                                                               ] 
KiB Mem : 39.3/65796532 [                                                                                               ]
KiB Swap:  8.0/16777212 [                                                                                               ]

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
    1 root      20   0  199708   3652   1836 S   0.0  0.0  91:41.00 /usr/lib/systemd/systemd --system --deserialize 23
  699 root      20   0   53892  21140  20540 S   0.0  0.0  20:04.10  `- /usr/lib/systemd/systemd-journald
 1052 root      39  19   16808     20      0 S   0.0  0.0   0:10.43  `- /usr/sbin/alsactl -s -n 19 -c -E ALSA_CONFIG_PAT+  1056 libstor+  20   0    8524     32      0 S   0.0  0.0   1:57.23  `- /usr/bin/lsmd -d
 1058 root      20   0  419456   1288    704 S   0.0  0.0   7:34.04  `- /usr/sbin/ModemManager
 1063 root      20   0   25212   2328   1000 S   0.0  0.0  39:10.69  `- /usr/lib/systemd/systemd-logind

And if you really like the per CPU details, presss 1 in in the top screen.

Top Key Press Command explained

Press ? in the top screen, to get full list of supported KeyPress command.

t
toggles task/cpu stats, which cycles from 3 avaiable CPU stats presention styles.
m
toggles memory info, which also cycles from 3 avaiable Memory info presention styles.
c
toggles between Cmd name or Cmd line presention styles.
V
toggles between normal process list or Forest view (process tree with parent/children relationship).
z
toggles between color and mono display.

评论

此博客中的热门博文

XEmacs 21.5 beta 35 "kohlrabi" has been released.

If you are an old XEmacs user, you may feel happy to see this from https://www.xemacs.org/.    After ten years, XEmacs released a new version 21.5. So there's still many people cares about XEmacs. The XEmacs' source repo have been moved from altassian Bitbucket to https://heptapod.net/. As Bitbucket have been dropped Mercurial support many years ago.

Fido-mode

Today, I've just discovered the Fido mode, a modified `icomplete` minor mode. `icomplete` used to be one of my favorite mode days back to my XEmacs days. Pros: It is way fast. It is much more smart in terms of find the complete candidate that you want mostly.  Cons: It does not integrate well enough with tramp yet.    `fido-mode` is a core package of Emacs 27+, and there's a vertical version available after Emacs 28+ named `fido-vertical-mode`. UPDATE: I am back with ido now