Explanation of common CentOS Performance Detection commands

Source: Internet
Author: User
Tags superuser permission

Explanation of common CentOS Performance Detection commands

1. uptime

[Root @ smgsim02 ~] # Uptime
15:08:15 up 98 days, 2 users, load average: 0.07, 0.29, 0.14

The number of times the system has been running since the current time the number of users logging on to the current system is 1 minute, 5 minutes, 15 minutes ago the current load

Load average is the average length of the queue, and the number of processes waiting for execution in the queue

The lower the value, it indicates that the process is more likely to be processed by the CPU immediately. The higher the value, it indicates that the process is more likely to be blocked.

This command can check whether the server load is high.

2. top

Display actual CPU usage


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

Row 2: Process Information

Tasks: 71 total process count

2. Number of running Processes of running

69 sleeping sleep Processes

0 stopped process count

0 zombie botnets

Row 3: CPU Information

Cpu (s): 4.8% us CPU usage

6.9% sy CPU usage in kernel space

0.0% percentage of CPU used by processes that have changed their priorities in ni user process space

87.2% id idle CPU percentage

0.0% wa CPU time percentage waiting for Input and Output

1.1% hi

0.0% si

Row 4: physical memory information

Mem: 255102 k total physical memory

Total physical memory used by 253572 k used

1548 k free Memory Total

Memory usage of 13576 k buffers as kernel Cache

Fifth line: swap zone information

Swap: 522104 k total number of Swap Areas

The total number of swap areas used by 9892 k used

512212 k free swap zone total

The total number of swap areas of the 34120 k cached buffer.

The content in the memory is swapped out to the swap zone and then into the memory, but the used swap zone has not been overwritten,

This value indicates the size of the SWAp zone where the content already exists in the memory.

When the corresponding memory is swapped out again, you do not have to write data to the swap zone.

Process Information area:

The details of each process are displayed at the bottom of the statistics area. First, let's take a look at the meaning of each column.

Serial Number Column name meaning

PID process id

PPID parent process id

RUSER Real user name

User ID of the UID process owner

USER: USER Name of the process owner

GROUP Name of the GROUP process owner

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

PR priority

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

P indicates the last CPU used, which is only meaningful in multiple CPU environments.

VIRT: Total virtual memory used by the process, in kb, VIRT = SWAP + RES

RES: the size of the physical memory used by the process, in kb, also known as resident memory. RES = CODE + DATA

SHR: The size of shared memory, in kb, that is, the amount of memory shared by the process and other processes.

% MEM: Percentage of physical memory used by the Process

TIME +: total cpu TIME used by the process, in the unit of 1/100 s

COMMAND: COMMAND name/line

% Percentage of CPU time used since the last CPU update to the present

SWAP: the size of the virtual memory used by the process that has not been swapped out (kb)

CODE: the size of the physical memory occupied by executable CODE

DATA: physical memory size (kb) occupied by parts other than executable code (DATA Segment + stack)

Number of nFLT page errors

The number of modified pages that the last time the data is written to the present.

STAT: Process status: S = sleep, R = running, T = stopped, D = stopped, Z = botnet

If the process is sleep, WCHAN displays the system function name in sleep.

Flags task flag. For more information, see sched. h.

SIZE: The amount of memory occupied by the process (code + Data + stack)
RSS; number of physical memory used by the Process
Badness = oom_score (bandness) Adj = oom_adjustment after entering the top command, you can continue to press the f key and select the display column to be added

You can use the f key to select the displayed content. Press f to display the column list. Press a-z to display or hide the corresponding column, and press enter to confirm.

Press the o key to change the Column Display sequence. A lower-case a-z can move the corresponding column to the right, while an upper-case A-Z can move the corresponding column to the left. Press enter.

Press the F or O key in upper case, and then press a-z to sort the process according to the corresponding column. The uppercase R key can reverse the current sorting.

Top Command Parameter explanation:

Top [-] [d] [p] [q] [c] [C] [S] [s] [n]

D. Specify the interval between two screen information refreshes. Of course, you can use the s interactive command to change it.

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

Q This option will refresh top without any delay. If the caller has the superuser permission, top runs with the highest possible priority.

S indicates the accumulative mode.

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

I so that top does not show any idle or dead processes.

C. display the entire command line, not just the command name.

The following describes some interactive commands that can be used during top command execution. From the perspective of usage, mastering these commands is more important than mastering the options. These commands are single-letter. If the s option is used in the command line option, some of these commands may be blocked.

Ctrl + L erase and override the screen.

H or? The help screen is displayed, and some brief command summary is provided.

K. terminate a process. The system prompts the user to enter the PID of the process to be terminated and the signal to be sent to the process. Generally, 15 signals can be used to terminate a process. If the process cannot end normally, use signal 9 to forcibly end the process. The default value is signal 15. This command is blocked in security mode.

I ignore idle and dead processes. This is a switch-on command.

Q: exit the program.

R reschedules the priority of a process. The system prompts the user to enter the process PID to be changed and the process priority value to be set. Entering a positive value will lower the priority, and vice versa will give the process a higher priority. The default value is 10.

S switches to the accumulative mode.

S changes the delay time between two refreshes. The system prompts the user to enter a new time in seconds. If there is a decimal number, it is converted to m s. If the input value is 0, the system will be refreshed continuously. The default value is 5 s. It should be noted that if the setting is too small, it is likely to cause constant refresh, so it is too late to see the display, and the system load will increase significantly.

F or F: add or delete a project from the current display.

O or O changes the order of projects displayed.

L switching displays average load and startup time information.

The m switch displays the memory information.

T Switch displays the process and CPU status information.

C switch to display the command name and complete command line.

M is sorted Based on the resident memory size.

P is sorted by CPU usage percentage.

T is sorted by time/accumulative time.

W write the current settings ~ /. Toprc file. This is a recommended method for writing top configuration files.

Botnets
When a process ends, it usually takes some time to complete all the tasks (such as closing open files) before it ends. In a very short period of time, the status of this process is zombie. After the process completes all the close tasks, it will submit the information to the parent process. In some cases, a zombie process cannot close itself, and the process is in the z (zombie) state ). You cannot use the kill command to kill a zombie process because it is marked as "dead ". If you cannot get rid of a zombie process, you can kill its parent process and the zombie process disappears. However, if the parent process is an init process, you cannot kill the init process because init is an important system process. In this case, you can only restart the server once to get rid of the zombie process. Why does the application become frozen?

The second line of tasks shows the number of zombie processes in the system.

3. iostat

Avg-cpu:

% User: CPU usage of user level (Application)
% Nice: CPU usage of the user level with nice priority added
% Sys: CPU usage of system level (kernel)
% Idle: idle CPU resources

Disk Information

Device: block Device name
Tps: the number of I/O requests transmitted by the device per second ). Multiple independent I/O requests can be combined into one transmission operation because one transmission operation can have different capacities.
Blk_read/s, Blk_wrtn/s: The number of blocks read and written by the device per second. The block size may be different.
Blk_read and Blk_wrtn: Total number of Block devices read and written since the system was started.

4. vmstat

The Vmstat command monitors processes, memory, page I/O blocks, CPU, and other information. vmstat can display the average value or sample value of the detection results, the sampling mode provides monitoring results at different frequencies within a sampling period.

· Process (procs)
R: Number of processes waiting for running time
B: Processes in non-disruptive sleep state
W: process that is switched out but can still run. The value is calculated.
· Memoryswpd: Number of virtual memory
Free: Number of idle memory
Buff: The amount of memory used as a buffer
· Swap
Si: Number of switches from hard disk
So: Number of switches to the hard disk
· IO
Bi: number of blocks output to a block Device
Bo: number of blocks received from a device
· System
In: number of interruptions per second, including clock
Cs: Number of context switches occurring per second
· Cpu (percentage of cpu running time)
Us: Non-kernel code running time (user time, including nice time)
Sy: kernel code running time (System Time)
Id: idle time
Wa: Time to wait for I/O operations

· M: displays the memory usage of the kernel.
· A: displays the memory page information, including active and inactive memory pages.
· N: Display header lines. This parameter is useful when sampling mode is used and command results are output to a file. For example, root # vmstat-n 2 10 displays 10 output results at a frequency of 2 seconds.

5. ps and pstree

Good command for analyzing processes!

6. sar

Automatically collect and save system information. crontab configures system scheduled tasks.

Crontab command format meaning: minute (0-59) hour (0-23) Date (1-31) month (1-12) Week (0-6) command segment

Let's take a look at several specific examples:
● 0 */2 ***/sbin/service httpd restart indicates that apache is restarted every two hours.

● 50 7 ***/sbin/service sshd start means to enable the ssh service at every day

● 50 22 ***/sbin/service sshd stop means to close the ssh service at every day

● 0 0 ** fsck/home check/home disk on the 1st and 15th of each month

● 1 ***/home/bruce/backup: Execute the file/home/bruce/backup at the first point of every hour.

● 00 03 ** 1-5 find/home "*. xxx "-mtime + 4-exec rm {}\; every Monday to Friday three o'clock, in the directory/home, find the file name *. xxx file, and delete the file four days ago.
● 30 6 */10 ** ls indicates that the ls command is executed at on the first, 11th, 21st, and 31st of each month.


7. free

Display System memory information

·-B,-k,-m, and-g display results by bytes, kilobytes, megabytes, and gigabytes respectively.
·-L difference between low and high memory
·-C {count} shows the number of free outputs

8. pmap

Pmap pid to view memory usage of specific processes

Related Article

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.