跳至主要内容

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.

评论

此博客中的热门博文

Eglot and before/after-save-hook and use-package

In Emacs, when you try to automate some actions during every save action, you will surely get to the before-save-hook and the after-save-hook. Simply adding something like gofmt-before-save to before-save-hook will save you tons of time to do the go-fmt. And then, I meet eglot, and gopls will also save me tons of time doing googling and api documentation navigation. But eglot-ensure is not very friendly to the good old ways of how after-save-hooks were designed to work. It makes the before/after-save-hook a buffer local variable and it does not inherit the variable's global value. So, to make before/after-save-hook work again, experts start to adding hooks to major mode specific hooks like this: emacs.md - Go (opensource.google) """ ;; Optional: install eglot-format-buffer as a save hook. ;; The depth of -10 places this before eglot's willSave notification, ;; so that that notification reports the actual contents that will be saved. (defu...

Use MobaDiff with git difftool

Recently there's an activity in IT that forces the deletion of all unauthorized softwares from all work machines. Unfortunately, kdiff3 is one in the list. As it is generally okay to use vimdiff as an alternative for kdiff3, A gui tool is better suited for desktop workflows. Known that MobaXterm is shipping a gui diff tool named MobaDiff. But it only appears in the windows right click context menu. Find the real application name takes me some time to search in the windows registry. "MobaRTE.exe", which is the one invoked by HKCR\*\shell\MobaDiff. And it was invoked with "-contextdiff" switch to show MobaDiff UI, while when the switch is "-contextedit" it shows MobaTextEditor. Too bad that the "-contextdiff" switch do not support pre-image post-image as other diff tool did, which effectively made it unable to be used as a command line diff utility. Also MobaTech did not mention anything in their document of this Mob...