introduction

The top command is the first entry to view system details in UNIX / Linux system. Generally, when we view the running status of the machine, we are always the first to use the top command. In fact, the top command displays a lot of data, which is not friendly for novices. The main purpose of this paper is to do a detailed carding.

Introduction

Top program provides a real-time data display of the running system. It can display the basic information of the system and the tasks currently managed by the Linux kernel. The types of summary information and task presentation, sorting and size of these systems are user configurable, and these configurations can be persistent and not affected by restart.

First line / basic information

Top command of Linux

The first line can be replaced by the command uptime. The contents of the first line from left to right are

*Current time

*System accumulation and running time

*Number of current logged in users

*Current system load.

The meaning of three numbers of system load

Generally speaking, the system will check the number of active processes in the current system every 5 seconds. There are three prerequisites for this active process

*It is not waiting for the result of the I / O operation

*It does not actively enter the wait state (that is, it does not call ‘wait’)

*Not stopped (e.g. waiting for termination)

The three values of system load represent the average value of system load in 1 minute, 5 minutes and 15 minutes respectively.

For a system with N-Core processor, when the load average of the system load is n, it means that the system is almost full load, but there is no extra experience to deal with other tasks. When load average is greater than N, it means that the system is overloaded. Generally speaking, in order to make the system work normally, in our experience, the task load average / N “0.7” is generally acceptable.

Second line / CPU Information

Top command of Linux

The second line mainly displays the process and CPU information. Note that task refers to the process in the top command. The information in the second line is

*Total number of processes

*Number of running processes

*Total number of dormant processes

*Total number of processes stopped

*Total number of dead processes

*The percentage of CPU resources occupied by us user processes

*The percentage of SY kernel processes in CPU resources

*The percentage of CPU resources of processes that have changed their priority in Ni user process space

*ID percentage of idle CPU

*The percentage of CPU resources that processes are waiting for input and output

*Hi hard interrupt occupancy percentage

*Percentage of Si soft interrupt occupied

*St virtual machine occupancy percentage

Third line / memory related information

Top command of Linux

mem

Total physical memory

Total physical memory used

Total amount of free physical memory

The total amount of memory used in the kernel cache

swap

Total swap memory

Total number of swap zones used

Total number of free swap areas

The total number of swap areas cached.

Swap: indicates the usage of swap partition on the hard disk. Swap is only used when MEM is actually occupied by the current process, that is, there are no buffers and caches.

In fact, the kernel may actively write some temporarily unused memory blocks to the swap of the disk, so that the saved memory can be used for other purposes. The memory that is written to swap will be re written to memory only when it is needed.

Note: when the physical memory is free, there may be a large number of swap. The reason is that there may be a situation where a process needs a lot of physical memory, and when the process ends, the process will be switched into swap memory in its life cycle and will not be released actively. The operating system is always in the actual need to do processing, so it will appear in a certain period of time, the physical memory is very idle, but the use of swap is very high.

Process information

See top in Linux

*PID: process ID, process ID, which is the unique identifier of the process. This ID will be copied periodically, but it will not start from 0.

*PPID: parent process PID

*Ruser: real user name, the real user name of the current process

*Uid: user ID. valid user ID of the process owner

*User: user name

*Group: group name

*TTY: name of controlling TTY control terminal. The name of the terminal that started the process. However, when a process is not accessed from the terminal, you will see a question mark

*PR: priority of priority process

*Ni: nice value. A negative number indicates a high priority and a positive number indicates a low priority.

* p : Last userd CPU (SMP)。 In a multiprocessing environment, represents the most recently used CPU sequence number.

*% CPU: percentage of CPU usage in total CPU time

*Time: the total CPU time used by CPU time task from the beginning to now.

*Time +: CPU time, hundredths more fine-grained and more accurate CPU time

*% MES: amount of memory used by the process

*Virt: the size of virtual memory used by the process

*Swap: the size of the swap used by the process

*Res: resident size refers to the size of the physical memory used by the process to remove the memory used by swap

*Code: code size refers to the amount of physical memory occupied by the code

*Data: data + stack size data and stack size

*SHR: shared MEM size the size of the shared memory of the process

*Nflt: page fault count

*Ndrt: dirty pages count

*S: process status. There are d r s t Z, respectively, which means [non interruptible sleep], [running], [sleeping], [pause or tracking state], [dead state], for reference

*Command: command line or program name

*Wchan: sleep in function displays the currently dormant function

*Flags: the standard of task flags process in process planning.

Tagged:

Leave a Reply

Your email address will not be published. Required fields are marked *