top

来源:互联网 发布:著名程序员 编辑:程序博客网 时间:2024/04/29 02:58

top命令
相当的关键的一个命令,结果如下
把man的结果翻一下看看

DESCRIPTION
       The  top program provides a dynamic real-time view of a running system.  It can display system summary information
       as well as a list of tasks currently being managed by the Linux kernel.  The types of system  summary  information
       shown and the types, order and size of information displayed for tasks are all user configurable and that configu‐
       ration can be made persistent across restarts.
        top程序可以来查看系统运行的实时状态。它可以显示出当前系统运行的概要状态,即显示出所有被内核管理的所有任务的列表的概要信息。概要信息显示的类型,类型以及顺序和使用量信息的显示方式可以设定并且显示的设置可以在重启动之后保持不变。

       The program provides a limited interactive interface for process manipulation as well as  a  much  more  extensive
       interface  for  personal configuration  --  encompassing every aspect of its operation.  And while top is referred
       to throughout this document, you are free to name the program anything you  wish.   That  new  name,  possibly  an
       alias, will then be reflected on top's display and used when reading and writing a configuration file.
        这个程序可以提供一个简单的于进程实现的交互接口。???


top  参数意义
    -c    参数c将COMMAND的程序名称换成启动的命令!!
    -d    d用来指名delay time,设定统计时间间隔
    -H    按照线程方式显示,COMMAND中显示的都是以线程为单位
    -H : Threads toggle
            Starts  top with the last remembered 'H' state reversed.  When this toggle is On, all individual threads will
            be displayed.  Otherwise, top displays a summation of all threads in a process.
    -i : Idle Processes toggle
            Starts top with the last remembered 'i' state reversed.  When this toggle is Off, tasks  that  are  idled  or
            zombied will not be displayed.
        对空闲的进程显示开关

    -n : Number of iterations limit as:  -n number
            Specifies the maximum number of iterations, or frames, top should produce before ending.
        设定显示的进程数目

    -u : Monitor by user as:  -u somebody
            Monitor only processes with an effective UID or user name matching that given.
        监视某个用户进程,dffective UID

    -U : Monitor by user as:  -U somebody
            Monitor only processes with a UID or user name matching that given.  This matches real, effective, saved, and
            filesystem UIDs.
        监视和当前用户进程!!跟上面的区别是什么???

    -p : Monitor PIDs as:  -pN1 -pN2 ...  or  -pN1, N2 [,...]
            Monitor only processes with specified process IDs.  This option can be given up to 20 times, or you can  pro‐
            vide a comma delimited list with up to 20 pids.  Co-mingling both approaches is permitted.
            监视特定进程,用进程号来设定,最多20个
            This  is  a command-line option only.  And should you wish to return to normal operation, it is not necessary
            to quit and and restart top  --  just issue the '=' interactive command.

       -s : Secure mode operation
            Starts top with secure mode forced, even for root.  This mode is far better  controlled  through  the  system
            configuration file (see topic 5. FILES).
            安全模式

       -S : Cumulative time mode toggle
            Starts top with the last remembered 'S' state reversed.  When 'Cumulative mode' is On, each process is listed
            with the cpu time that it and its dead children have used.  See the 'S' interactive  command  for  additional
            information regarding this mode.
            这个是什么时间, 好像显示的包括了进程之间的关系,子进程的时间会被计入父进程!!
       -v : Version
            Show library version and the usage prompt, then quit.



概要信息:
top - 14:04:05 up  4:29,  3 users,  load average: 0.04, 0.10, 0.09
Tasks: 145 total,   3 running, 142 sleeping,   0 stopped,   0 zombie
Cpu(s): 29.1%us, 13.4%sy,  0.0%ni, 57.3%id,  0.0%wa,  0.3%hi,  0.0%si,  0.0%st
Mem:   2060756k total,  1947772k used,   112984k free,   145072k buffers
Swap:        0k total,        0k used,        0k free,  1391496k cached
详细信息:
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                        
 1748 root      20   0  288m  67m  17m S 12.9  3.3   5:14.10 Xorg                                                           
 5645 tuoyu     20   0  367m  22m  14m S 10.9  1.1   1:48.79 audacious2                                                     
 5669 tuoyu     20   0  194m  16m  10m R  9.0  0.8   0:14.39 gnome-terminal                                                 
 1999 tuoyu     20   0  156m 4916 3740 S  6.4  0.2   1:07.64 pulseaudio                                                     
 2106 tuoyu     20   0 29916  20m 6756 S  0.8  1.0   0:35.04 compiz.real                                                    
 5546 tuoyu     20   0  331m  72m  36m S  0.8  3.6   0:31.84 ld-linux.so.2                                                  
 6048 tuoyu     20   0  228m  22m  14m S  0.6  1.1   0:05.10 gedit                                                          
  692 messageb  20   0  3156 1488  748 S  0.3  0.1   0:02.14 dbus-daemon                                                    
 1195 mysql     20   0  142m  18m 5452 S  0.3  0.9   0:05.16 mysqld                                                         
 2020 tuoyu     20   0 96612 9028 6792 S  0.3  0.4   0:04.53 gnome-settings-                                                
 2108 tuoyu     20   0  254m  42m  26m S  0.3  2.1   0:05.60 nautilus                                                       
 2122 tuoyu     20   0  162m  11m 9036 S  0.3  0.6   0:00.98 update-notifier                                                
 2179 tuoyu     20   0 23596 9240 7480 S  0.3  0.4   0:13.84 multiload-apple                                                
 6073 tuoyu     20   0  2468 1176  884 R  0.3  0.1   0:00.27 top                                                            
    1 root      20   0  2528 1520 1120 S  0.0  0.1   0:00.95 init                                                           
    2 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 kthreadd                                                       
    3 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 migration/0                                                    
    4 root      15  -5     0    0    0 S  0.0  0.0   0:00.03 ksoftirqd/0                                                    
    5 root      RT  -5     0    0    0 S  0.0  0.0   0:00.00 watchdog/0                                                     
    6 root      15  -5     0    0    0 S  0.0  0.0   0:00.38 events/0                                                       
    7 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 cpuset                                                         
    8 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 khelper                                                        
    9 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 netns                                                          
   10 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 async/mgr                                                      
   11 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 kintegrityd/0                                                  
   12 root      15  -5     0    0    0 S  0.0  0.0   0:00.02 kblockd/0                                                      
   13 root      15  -5     0    0    0 S  0.0  0.0   0:00.44 kacpid                                                         
   14 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 kacpi_notify                                                   
   15 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 kacpi_hotplug                                                  
   16 root      15  -5     0    0    0 S  0.0  0.0   0:02.54 ata/0                                                          
   17 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 ata_aux                                                        
   18 root      15  -5     0    0    0 S  0.0  0.0   0:00.00 ksuspend_

PID     进程号
USER    用户名,指示当前进程属于哪个用户的
PR        priority 运行的优先级
NI        Nice Value    
            The  nice  value of the task.  A negative nice value means higher priority, whereas a positive nice value means
              lower priority.  Zero in this field simply means priority will not be adjusted in  determining  a  task's  dispatchability.??

VIRT            o: VIRT  --  Virtual Image (kb) 虚拟机映像??是该这么说么??
          The  total  amount  of  virtual  memory used by the task.  It includes all code, data and shared libraries plus
          pages that have been swapped out.

          VIRT = SWAP + RES. 包括使用的swap空间和物理内存使用的和

RES              q: RES  --  Resident size (kb)
          The non-swapped physical memory a task has used. 一个进程当前使用的物理内存的量
   
SHR              t: 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. 共享内存的总大小

S              w: S  --  Process Status
          The status of the task which can be one of:
             'D' = uninterruptible sleep      无法唤醒的sleep,基本上就死了,僵尸进程
             'R' = running                    运行中
             'S' = sleeping                    休息状态
             'T' = traced or stopped        traced 或者结束了
             'Z' = zombie                    ????
            进程状态字


%CPU    当前进程使用CPU的比例 In a true SMP environment, if 'Irix mode' is Off, top will operate in 'Solaris mode' where a task's  cpu
          usage  will  be  divided by the total number of CPUs. SMP环境中,计算的是每个CPU的平均占用比例
%MEM    %MEM  --  Memory usage (RES)    A task's currently used share of available physical memory.

TIME+    当前进程运行时间,CPU的运行时间的累计
COMMAND    运行进程的名称  x: Command  --  Command line or Program name
            
y: WCHAN  --  Sleeping in Function
          Depending on the availability of the kernel link map ('System.map'), this field  will  show  the  name  or  the
          address  of  the  kernel  function  in which the task is currently sleeping.  Running tasks will display a dash
          ('-') in this column.

          Note: By displaying this field, top's own working set will be increased by over  700Kb.   Your  only  means  of
          reducing that overhead will be to stop and restart top.
???这个需要看看什么意思



这个部分的解释:
top - 14:04:05 up  4:29,  3 users,  load average: 0.04, 0.10, 0.09
Tasks: 145 total,   3 running, 142 sleeping,   0 stopped,   0 zombie
Cpu(s): 29.1%us, 13.4%sy,  0.0%ni, 57.3%id,  0.0%wa,  0.3%hi,  0.0%si,  0.0%st
Mem:   2060756k total,  1947772k used,   112984k free,   145072k buffers
Swap:        0k total,        0k used,        0k free,  1391496k cached

(CPUs)CPU States
       The  CPU  states are shown in the Summary Area. They are always shown as a percentage and are for the time between
       now and the last refresh.

        us  --  User CPU time
          The time the CPU has spent running users' processes that are not niced.
                运行用户进程(not niced)?什么样的用户进程?
        sy  --  System CPU time
          The time the CPU has spent running the kernel and its processes.
                运行系统进程或者内核的cpu时间
        ni  --  Nice CPU time
          The time the CPU has spent running users' proccess that have been niced.
                运行用户进程(niced)
        wa  --  iowait
          Amount of time the CPU has been waiting for I/O to complete.
                iowait的总时间占cpu总时间的比例
        hi  --  Hardware IRQ
          The amount of time the CPU has been servicing hardware interrupts.
                服务硬件中断的时间占cpu总时间的比例
        si  --  Software Interrupts
          The amount of time the CPU has been servicing software interrupts.
                服务软中断的时间占cpu总时间的比例
        st  --  Steal Time
          The amount of CPU 'stolen' from this virtual machine by the hypervisor for other tasks (such as running another
          virtual machine).
                时间窃取的时间时间比例


有关进程方面没有讲到Tasks段的内容是什么意思,top 中 load average怎么算的??


Summary_Area:  The  program  name  is shown, perhaps a symlink or alias.  The Cpu(s) state label hints at other
          possibilities.  The memory stats use a lower case 'k'.

原创粉丝点击