Linux performance analysis tool top commands

Source: Internet
Author: User

Linux performance analysis tool top commands

The top command is a common performance analysis tool in Linux. It can display the resource usage of various processes in the system in real time and is often used for server performance analysis.

Top Command description
[www.bkjia.com@bkjia-t-tomcat-188-193 ~]$ toptop - 16:07:37 up 241 days, 20:11,  1 user,  load average: 0.96, 1.13, 1.25Tasks: 231 total,   1 running, 230 sleeping,   0 stopped,   0 zombieCpu(s): 12.7%us,  8.4%sy,  0.0%ni, 77.1%id,  0.0%wa,  0.0%hi,  1.8%si,  0.0%stMem:  12196436k total, 12056552k used,   139884k free,    64564k buffersSwap:  2097144k total,   151016k used,  1946128k free,  3120236k cachedPID     USER      PR    NI   VIRT    RES     SHR    S   %CPU    %MEM        TIME+   COMMAND18411   pplive    20     0  11.9g   7.8g    5372    S  220.2    67.1     16761:00   java 1875   pplive    20     0  3958m   127m    4564    S    4.6     1.1     12497:35   java    4   root      20     0      0      0       0    S    0.3     0.0    184:01.76   ksoftirqd/0   13   root      20     0      0      0       0    S    0.3     0.0    135:49.83   ksoftirqd/2   25   root      20     0      0      0       0    S    0.3     0.0    136:54.49   ksoftirqd/5
The result of the top command is divided into two parts:
  • Statistical information: the first five lines are the overall statistical information of the system;
  • Process Information: process details are displayed in a table area below the statistics. The process is refreshed every 5 seconds by default.
Statistical Information Description:
  • Row 1st: Top task queue information (system running status and average load). The result is the same as that of the uptime command.
    • Section 1st: current system time, for example, 16: 07: 37
    • Section 2nd: system running time. The longer the system is, the more stable the system is.
      • Format: up xx days, HH: MM
      • For example: 241 days, indicating that the operation lasted 241 days, 20 hours, and 11 minutes.
    • Section 3rd: number of currently logged-on users. For example, 1 user indicates that only one user is logged-on.
    • Section 4th: system load, that is, the average length of the task queue. Three values are used to calculate the average system load for the last 1, 5, and 15 minutes respectively.
      • Average system load: in Single-core CPU, 0.00 indicates that there is no load, 1.00 indicates that there is just full load, over 1 indicates overload, and the ideal value is 0.7;
      • Multi-core CPU load: the number of CPU cores * the ideal value is 0.7 = the ideal load. For example, if the 4-core CPU load does not exceed 2.8, it indicates that there is no high load.
  • Row 3: Tasks Process Information
    • Section 1st: total number of processes. For example, Tasks: 231 total indicates that a total of 231 processes are running.
    • Section 2nd: Number of running processes, for example, 1 running,
    • Section 3rd: Number of sleeping processes, for example, 230 sleeping,
    • Section 4th: Number of stopped processes, for example, 0 stopped,
    • Section 5th: Number of zombie processes, for example, 0 zombie
  • Row 3rd: CPU information about Cpus. For multi-core Cpus, press number 1 to Display CPU information for each core. At this time, line 1 is converted to number of CPU cores, and line 1 can switch back and forth.
    • Section 1st:usCPU usage percentage of user space, for example, Cpu (s): 12.7% us,
    • Section 2nd:syCPU usage of kernel space, for example, 8.4% sy,
    • Section 3rd:niCPU usage percentage of processes that have changed their priorities in the process space, for example, 0.0% ni,
    • Section 4th:idIdle CPU percentage, for example, 77.1% id,
    • Section 5th:waPercentage of CPU time waiting for input and output, for example, 0.0% wa,
    • Section 6th:hiTotal amount of time consumed by the CPU service for hardware interruption, for example: 0.0% hi,
    • Section 7th:siTotal amount of time spent on the Soft Interrupt of the CPU service, for example, 1.8% si,
    • Section 8th:stCPU time when the Steal time vm is stolen by the hypervisor (if the vm is in the same hypervisor, The hypervisor actually consumes some CPU processing time)
  • Row 3: Mem memory information (Mem: 4th k total, 12196436 k used, 12056552 k free, 139884 k buffers)
    • Section 1st: total physical memory, for example, Mem: 12196436 k total,
    • Section 2nd: total physical memory used, for example, 12056552 k used,
    • Section 3rd: Total idle memory, for example, Mem: 139884 k free,
    • Section 4th: The amount of memory used as the kernel cache, for example, 64564 k buffers
  • Row 5th: Swap partition information (Swap: 2097144 k total, 151016 k used, 1946128 k free, 3120236 k cached)
    • Section 1st: total number of Swap areas, for example, Swap: 2097144 k total,
    • Section 2nd: the total number of swap areas used, for example, 151016 k used,
    • Section 3rd: Total number of free swap areas, for example, 1946128 k free,
    • Section 4th: Total number of buffer swap zones, 3120236 k cached
Process Information:

In the top command, press f to view the displayed column information, and press the corresponding letter to enable/disable the column. in upper case, the column information is enabled, and in lower case, the column information is disabled. The default column with the * sign is used.

  • A:PID= (Process Id) Process Id;
  • E:USER= (User Name) User Name of the process owner;
  • H:PR= (Priority) Priority
  • I:NI= (Nice value) nice value. A negative value indicates a high priority, and a positive value indicates a low priority.
  • O:VIRT= (Virtual Image (kb) Total Virtual memory used by the process, in kb. VIRT = SWAP + RES
  • Q:RES= (Resident size (kb) the size of physical memory used by the process, not swapped out, in kb. RES = CODE + DATA
  • T:SHR= (Shared Mem size (kb) Shared memory size, in kb
  • W:S= (Process Status) Process Status. D = uninterrupted sleep state, R = running, S = sleep, T = tracking/stopping, Z = zombie Process
  • K:%CPU= (CPU usage) Percentage of CPU usage since the last update
  • N:%MEM= (Memory usage (RES) Percentage of physical Memory used by the Process
  • M:TIME+ = (CPU Time, hundredths) total CPU Time used by the process, in the unit of 1/100 seconds
    B:PPID= (Parent Process Pid) Parent Process Id
    C:RUSER= (Real user name)
    D:UID= (User Id) User Id of the process owner
    F:GROUP= (Group Name) Group Name of the process owner
    G:TTY= (Controlling Tty) the terminal name of the startup process. Processes not started from the terminal are displayed?
    J:P= (Last used cpu (SMP) The Last CPU used, only meaningful in multiple CPU Environments
    P:SWAP= (Swapped size (kb) The size of the virtual memory used by the process, in kb
    L:TIME= (CPU Time) total CPU Time used by the process, in seconds
    R:CODE= (Code size (kb) physical memory occupied by executable Code, in kb
    S:DATA= (Data + Stack size (kb) physical memory occupied by parts other than executable code (Data Segment + Stack), in kb
    U:nFLT= (Page Fault count) Page error count
    V:nDRT= (Dirty Pages count) number of modified Pages that were last written to the present
    Y:WCHAN= (Sleeping in Function) if the process is Sleeping, the system Function name displayed during sleep
    Z:Flags= (Task Flags <sched. h>). For more information, see sched. h.
  • X:COMMAND= (Command name/line) Command name/Command line
Top Command Options
  • -b: Operate in batch mode;
  • -c: Displays complete governance commands;
  • -d: Screen refresh interval;
  • -I: Ignore the failure process;
  • -s: Confidentiality mode;
  • -S: Accumulation mode;
  • -I <time>: Set the interval;
  • -U <User Name>: Specifies the user name;
  • -P <process number>: Specifies the process;
  • -N <times>: The number of cycles.
Top Command Interaction
  • Common interactive operations
    • Basic operations
      • 1: displays CPU details, one line per core
      • D/s: Modify the refresh frequency, in seconds
      • H: The Help page is displayed.
      • N: number of lines displayed in the Process List. The default value is the number of lines displayed on the full screen.
      • Q: Exit top.
    • Hide the Panel
      • L: Hide/display 1st lines of load information;
      • T: Hide/show 2nd ~ 3 rows of CPU Information;
      • M: Hide/show 4th ~ Five lines of memory information;
    • Process List sorting
      • M: sort by resident memory size;
      • P: sort by CPU usage percentage;
      • T: sort by time/accumulative time;
  • Interaction instructions: h /? The Help page is displayed. The original version is in English. Simple translation is as follows:
Help for Interactive Commands-procps version 3.2.8Window 1: Def: Cumulative mode Off. system: delay3.0 secs; Secure mode Off. z, B Global: 'Z' change color mappings; 'B' disable/enable bold Z: Modify the color configuration; B: disable/enable bold l, t, m Toggle Summaries: 'L' load avg; 't'task/cpu stats; 'M' mem info l: Hide/display 1st rows of load information; t: Hide/show 2nd ~ 3 rows of CPU information; m: Hide/display 4th ~ 5 rows of memory information; 1, I Toggle SMP view: '1' single/separate states; 'I' Irix/Solaris mode 1: single/multi-row Display CPU information; I: irix/Solaris mode switch f, o. fields/Columns: 'F' add or remove; 'O' change display order f: Column display Control; o: column sorting control; f or o adjusted by letter. select sort field Select the sorting column <,>. move sort field: '<'Next col left;'> 'next col right Move content up and down R, H. toggle: 'R' normal/reverse sort; 'H' show threads R: Content sorting; H: display thread c, I, S. toggle: 'C' cmd nam E/line; 'I idle tasks;'s 'cumulative time c: COMMAND column COMMAND name and complete COMMAND line path switch; I: Ignore idle and dead processes switch; S: accumulative mode switch x, y. toggle highlights: 'X' sort field; 'y' running tasks x: column sorting; y: running task z, B. toggle: 'Z' color/mono; 'B' bold/reverse (only if 'X' or 'y') z: color mode; B: bold switch only applies to x, u. show specific user only filters by user. When an input error occurs, press Ctrl + Backspace to delete n or #. set maximum tasks displayed to Set the maximum number of display processes k. r Manipulate tasks: 'K' kill; 'R' renice k: terminate a process; r: reset the priority level of a process. d or s Set update interval changes the delay time between two refreshes (unit: s ), if there is a decimal number, it is converted to ms. If the input value is 0, the system will refresh continuously. The default value is 5 s. W Write configuration file writes the current settings ~ /. In the toprc file, exit q Quit (commands shown '. 'require a visible task display window) Note:. the Command requires a visible task display window Press 'H' or '? 'For help with Windows, any other key to continue

References

Linux top commands

Linux top commands

Linux top commands for monitoring and diagnosis tools

Top command causes system load increase

Practical top Command

Why does Linux's htop command win the top command?

Use the most powerful process monitor htop in Ubuntu

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.