Linux 系统学习 之 top命令

top命令显示的信息种类、顺序、大小等都是可以配置的,而且这些配置在restart之后还可以使用。

man top:
The remaining Table of Contents
1. COMMAND-LINE Options
2. FIELDS / Columns
a. DESCRIPTIONS of Fields
b. SELECTING and ORDERING Columns
3. INTERACTIVE Commands
a. GLOBAL Commands
b. SUMMARY Area Commands
c. TASK Area Commands
d. COLOR Mapping
4. ALTERNATE-DISPLAY Mode
a. WINDOWS Overview
b. COMMANDS for Windows
5. FILES
a. SYSTEM Configuration File
b. PERSONAL Configuration File
6. STUPID TRICKS Sampler
a. Kernel Magic
b. Bouncing Windows
c. The Big Bird Window
7. BUGS, 8. HISTORY Former top, 9. AUTHOR, 10. SEE ALSO

模式:full-screen mode,alternate-display mode,Secure mode

操作top的时候,最重要的两个keys是help('h' or '?')和quit(q),或者也可以用ctrl+c来退出。可以看到,有很多交互命令可以使用。以下首先说明命令行参数的用法,然后说明交互命令的用法。

top命令的命令行参数: -hv | -bcisS -d delay -n iterations -p pid [,pid...]
-b batch模式,分批显示,不允许交互
-c 原先显示程序名的地方显示命令,反之亦然(也可用作交互命令)
-d 设定延时时间 -d ss.tt(seconds, tenths)
-i 反转Idle Processes toggle,当Idle Processes toggle关闭的时候idled进程和僵尸进程不会显示
-u 仅监视某用户
-p 监视某(些)进程,-p pid [,pid,...]。 如果要返回正常状态,不用退出,直接使用'='就可以了
-S 反转Cumulative time mode toggle,When 'Cumulative mode' is On, each process is
listed with the cpu time that it and its dead children have used.

交互命令:
            3a. GLOBAL_Commands
                            ?, =, A, B, d, G, h, I, k, q, r, s, W, Z
                3b. SUMMARY_Area_Commands
                            l, m, t, 1
                3c. TASK_Area_Commands
                            Appearance:  b, x, y, z
                            Content:        c, f, o, S, u
                            Size:              #, i, n
                            Sorting:        <, >, F, O, R
                3d. COLOR_Mapping
                            , a, B, b, H, M, q, S, T, w, z, 0 - 7
                4b. COMMANDS_for_Windows
                            -, _, =, +, A, a, G, g, w

3a. GLOBAL_Commands
  :Exit_Task_Limits。退出某些限制
  Alternate_Display_Mode_toggle
                This command will switch between full-screen mode and  alternate-display  mode:
   

  是否高亮显示
      Note:  When this toggle is On and top is operating in monochrome mode, the entire display will appear as normal text.  Thus, unless the 'x' and/or 'y' toggles are using reverse for emphasis, there will  be  no visual confirmation that they are even on.

d或者s    设置delay时间

    Choose_Another_Window/Field_Group  有1-4可供选择,配置A切换到alternate-display  mode,可以看到有def、job、usr、mem四种。

    Irix/Solaris_Mode_toggle
u/U  关注某用户的进程(=退出)
    修改某个pid的nice值,正值减少它的优先级,负值增大优先级
    将目前的配置写入配置文件,下次可以同样使用
    调整颜色

3b. SUMMARY_Area_Commands
    是否显示当前名称(一般第一行的内容)
    是否显示swap和memory
    是否显示tasks和cpus
1(数字)  切换多cpu分别统计的样式

b、x、y、z  都可以用来改变高亮相关的设置。其中x高亮显示sort field所在的列。

  显示进程名称或者命令名
  调整各部分的位置,比如:Current Fields: AEHIOQTWKNMbcdfgjplrsuvy zX for window 1:Def
Upper case letter moves field left, lower case right ,那么就可以使用大小写的字母来使位置提前或推后。
  调整显示的fields,比如:Current Fields:  AEHIOQTWKNMbcdfgjplrsuvy zX  for window 1:Def
Toggle fields via field letter, type any other key to return ,其中大写的是已经显示的,小写的没显示的。
  Cumulative_Time_Mode_toggle
  仅显示active的进程
n或者#  设置显示tasks的数目,0是不限制

  选择当前sort field的左边一列为sort field(若没高亮,可使用B,x等打开高亮选项)
  选择当前sort field的右边一列为sort field
F或者O  选择sort field
  正序倒序
与ALTERNATE-DISPLAY Mode相关的交互命令在下面说。

column意义:
PR -- Priority
NI -- Nice value。负值Priority高,正值小。
TIME -- CPU Time
VIRT -- Virtual Image (kb)这个task使用到的所有虚拟内存,包括代码段、数据段等(It includes all code, data and shared libraries plus pages that have been swapped out.)
VIRT = SWAP + RES.
SWAP -- Swapped size (kb)
The swapped out portion of a task's total virtual memory image.
RES -- Resident size (kb)
The non-swapped physical memory a task has used.
RES = CODE + DATA.
SHR -- Shared Mem size (kb)
            The amount of shared memory used by a task. It simply reflects memory that could be             potentially shared with other processes.
--  Process Status
                  The status of the task which can be one of:
                        'D' = uninterruptible sleep
                        'R' = running
                        'S' = sleeping
                        'T' = traced or stopped
                        'Z' = zombie
          其中,runing状态的进程是ready to run,即使不是在标准的smp系统,也会由于nice值和长时间的延时而使很多进程处于这个状态(depending on top's delay interval and nice value.)

ALTERNATE-DISPLAY Mode 可以同时显示4 different field groups,这时,summary area显示的field group就是当前的window,那些正对current window的命令都是针对这个window的。

针对ALTERNATE-DISPLAY Mode的交互命令:
-和_      打开或者关闭当前/所有windows显示的。
a和w      选择当前的下/上一window作为当前window


可以为系统写top的配置文件,这个是手动完成的,top自己不生成。它必须在/etc下,必须叫toprc,必须仅有两行,如:
              # line 1: 'secure' mode switch
5.0            # line 2: 'delay'  interval in seconds
用户的top配置文件可以由W来生成和update。






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值