Linux Common Performance Detection command interpretation

Source: Internet
Author: User
Tags cpu usage

1, uptime

    1. [Email protected] ~]# uptime

15:08:15 up 98 days, 4:19, 2 users, load average:0.07, 0.29, 0.14

The current time system has been running for how many users logged on the current system is 1 minutes, 5 minutes, 15 minutes ago to the present load situation

Load average is the average length of the queue and the number of processes waiting to be executed in the queue

The lower the value, the more likely the process is to be processed by the CPU immediately, and the higher it is, the more likely the process is to block

This command checks to see if the server load is high.

2. Top

Show CPU actual usage


The first line of top is the contents of the uptime command.

Second line: Process information

tasks:71 Total Process Totals

2 running number of running processes

Number of processes for sleeping sleep

0 Number of processes stopped stopped

0 Zombie Number of zombie processes

Third line: CPU information

CPU (s): 4.8%us user space consumes CPU percentage

6.9%sy CPU percent of kernel space consumed

0.0%ni CPU Percentage of processes that have changed priority within the user process space

87.2%id Idle CPU Percentage

0.0%wa percentage of CPU time waiting for input and output

1.1% hi

0.0% si

Line four: physical memory information

mem:255102k Total Physical Memory

Total physical memory used by 253572K used

1548k free Memory Total

The amount of memory that 13576k buffers uses as the kernel cache

Line five: Exchange area information

Total swap area of swap:522104k

Total swap area used by 9892k used

512212k Free Swap Area total

34120k cached Buffers The total number of swap areas.

The in-memory content is swapped out to the swap area and then swapped in to memory, but the used swap area has not been overwritten, which is the size of the swap area where the content already exists in memory. When the corresponding memory is swapped out again, it is no longer necessary to write to the swap area.

Process Information Area:

The details of each process are shown below the statistics area. Let's start by understanding the meaning of the columns.

Ordinal column name meaning

PID Process ID

PPID Parent Process ID

Ruser Real User Name

User ID of the UID process owner

Username of user Process Owner

Group Process Owner's name

The terminal name of the TTY startup process. Processes that are not started from the terminal are displayed as?

PR-Priority

NI Nice, negative indicates high priority, positive value indicates low priority

P last used CPU, only meaningful in multi-CPU environment

VIRT: Total amount of virtual memory used by the process, in kilobytes, Virt=swap+res

RES: The size of the non-swapped physical memory used by the process, in kilobytes, also known as resident memory, Res=code+data

SHR: Shared memory size, in kilobytes, that is, the number of shared memory for the process and other processes

%MEM: Percentage of physical memory used by the process

Time+: Total CPU time used by the process, Unit 1/100s

Command: Name/Line

%cpu percentage of CPU time that was last updated to current

Swap: The size of the virtual memory that the process is using, not swapped out (KB)

Code: The size of the physical memory that the executable code occupies

Data: The amount of physical memory (KB) occupied by parts other than executable code (data segment + stack)

Nflt Number of page faults

NDRT the number of pages that were modified the last time it was written to.

STAT: Status of the process: s= hibernation, r= running state, t= stop state, d= interrupt hibernation, z= zombie status

Wchan If the process is sleeping, the system function name in sleep is displayed

Flags task flag, reference sched.h

Size: The amount of memory the process consumes (code + data + stack)

RSS; The amount of physical memory used by the process

Badness=oom_score (bandness)

Adj=oom_adjustment

After you have entered the top command, you can continue to press the F key to select the display column you want to add

The F key allows you to select what is displayed. Press the F key to display a list of columns, press A-Z to show or hide the corresponding column, and then press ENTER to confirm.

Press the O key to change the order in which the columns are displayed. A-Z in the lower case moves the corresponding column to the right, while the uppercase A-Z moves the corresponding column to the left. Finally, press ENTER to confirm.

Press the uppercase F or O key, and then press A-Z to sort the process by the appropriate column. The uppercase R key can reverse the current sort.

The top command parameter explains:

Top [-] [d] [P] [Q] [C] [C] [s] [s] [n]

d Specifies the interval between every two times the screen information is refreshed. Of course the user can use the s interactive command to change it.

P only monitors the state of a process by specifying the monitoring process ID.

Q This option will cause top to refresh without any delay. If the calling program has Superuser privileges, top will run at the highest possible priority.

S Specifies the cumulative mode

s enables the top command to run in Safe mode. This removes the potential danger of interactive commands.

I make top not show any idle or zombie processes.

C Displays the entire command line instead of just displaying the command name

The following are some of the interactive commands that you can use during the execution of the top command. From a point of view of use, mastering these commands is more important than mastering the options. These commands are single-letter, and if you use the S option in command-line options, some of these commands may be masked out.

Ctrl+l Erase and rewrite the screen.

H or? Display the help screen and give a brief summary of the commands.

K Terminates a process. The user will be prompted for the process PID to be terminated and what signal needs to be sent to the process. The normal termination process can use a 15 signal, and if not, use signal 9 to force end the process. The default value is signal 15. This command is masked in safe mode.

I ignore idle and zombie processes. This is a switch-type command.

Q quit the program.

R reschedule the priority level of a process. The user is prompted to enter the process PID that needs to be changed and the process priority value that needs to be set. Entering a positive value lowers the priority and, conversely, it gives the process a higher priority. The default value is 10.

S switch to cumulative mode.

s changes the delay time between two refreshes. The user will be prompted to enter a new time in S. If there are decimals, it is converted into M S. Enter a value of 0 and the system will refresh continuously, the default value is 5 S. It is important to note that if you set too small a time, it is likely to cause a constant refresh, so it is too late to see the display, and the system load will be greatly increased.

F or F Add or remove items from the current display.

O or O change the order in which items are displayed.

L Toggle Display Average load and start time information.

M toggles display memory information.

T toggles the display of process and CPU status information.

The C toggle Displays the command name and the full command line.

M sorts based on the size of the resident memory.

P is sorted according to the percentage size of CPU usage.

T is sorted by time/accumulated time.

W writes the current settings to the ~/.TOPRC file. This is the recommended way to write top configuration files.

Zombie Process

When a process is finished, it usually takes some time to complete all tasks (such as closing open files) before it ends, and in a very short time, the status of this process is zombie state. After the process has completed all the shutdown tasks, it submits the information it closed to the parent process. In some cases, a zombie process cannot shut itself down, when the process state is Z (zombie). You cannot use the KILL command to kill a zombie process because it is already marked as "dead". If you can't get rid of a zombie process, you can kill its parent process, and the zombie process disappears. However, if the parent process is the INIT process, you cannot kill the init process because INIT is an important system process, in which case you can only get rid of the zombie process by restarting the server at once. You also have to analyze why applications can cause zombies.

The second row of tasks can see the number of zombie processes in the system

3, Iostat


AVG-CPU:

%user:user level (application) CPU usage

%nice: CPU Usage for the user level with nice priority

%sys:system level (kernel) CPU usage

%idle: Idle CPU resource condition

Disk information

Device: Block device name

Tps: The number of devices per second that the device transmits (I/O requests per second). Multiple individual I/O requests can be composed of one transport operation, because a transfer operation can be of different capacity.

BLK_READ/S, BLK_WRTN/S: The number of blocks that the device reads and writes per second. The block may be of different capacity.

Blk_read, Blk_wrtn: The total number of block devices that have been read and written since the system started.

4, Vmstat

The Vmstat command provides monitoring of information such as processes, memory, page I/O blocks, and CPUs, Vmstat can display the average or sampled values of the test results, and sampling patterns can provide a monitoring result of different frequencies over a sampling period.


process (procs)

R: Number of processes waiting for run time

B: Process in non-disruptive sleep state

W: Processes that are swapped out but can still be run, this value is calculated

MEMORYSWPD: Number of virtual memory

Free: The number of idle memory

Buff: The amount of memory used as a buffer

Swap

Si: Quantity exchanged from hard disk

So: The number of swapped to the hard drive

· Io

BI: Number of blocks output to a single block device

Bo: Number of blocks accepted from a single block device

system

In: Number of interrupts per second, including clock

CS: Number of context switches that occur per second

CPU (percent of the total CPU run time)

US: Time for non-kernel code to run (user time, including nice time)

SY: Kernel code run time (System time)

ID: Idle Time

WA: Time to wait for I/O operations

• M: Showing memory utilization of the kernel

A: Display memory page information, including active and inactive memory pages

• N: Displays the header line, which is useful when using sampling mode and outputting command results to a file. For example, Root#vmstat–n 2 10 displays 10 output results at 2-second frequency


5, PS and Pstree

Good command of the analysis process!


6. Sar

Automatically collect and save system information, crontab Configure system timing tasks

crontab command format meaning: minutes (0-59) hours (0-23) Date (1-31) month (1-12) week (0-6) command segment

Let's take a look at a few specific examples:

0 */2 * * */sbin/service httpd restart means to reboot Apache every two hours

7 * * */sbin/service sshd start means SSH service is opened 7:50 every day

* * * */sbin/service sshd stop means the SSH service is closed 22:50 every day

0 0 1,15 * * fsck/home monthly 1th and 15th check/home disk

1 * * * */home/bruce/backup the first minute of every hour to execute/home/bruce/backup this file

* * 1-5 find/home "*.xxx"-mtime +4-exec rm {} \; Every Monday to Friday 3 o'clock, in the directory/home, look for files with the file name *.xxx and delete the files 4 days ago.

6 */10 * ls means monthly 1, 11, 21, 31st Yes 6:30 execute the LS command


7. Free

Display system memory Information

-b,-k,-m and-G respectively according to bytes, kilobytes, megabytes, gigabytes display results.

-l difference shows low and high memory

-c {count} shows the number of free outputs


8, Pmap

Pmap PID view memory usage for specific processes

Linux Common Performance Detection command interpretation

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.