Some of the Linux directives commonly used in performance testing __linux

Source: Internet
Author: User
Tags memory usage sorts time interval

1, Uptime

[Root@smgsim02 ~]# Uptime

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

Current time system run to date how many users logged in the current system is 1 minutes, 5 minutes, 15 minutes ago the load situation

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

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

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

2, top

The top command uses the example more and reads: 12 use cases on Linux for the upper command

Show CPU actual usage

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

Second line: Process information

Total Process tasks:71

2 running number of processes running

The number of sleeping sleep processes

0 stopped number of processes stopped

0 Zombie Zombie Process number

Third line: CPU information

CPU (s): 4.8%us user space usage CPU percent

6.9%sy kernel footprint CPU%

0.0%ni percent of processes in user process space that have changed priority

87.2%id Idle CPU percent

0.0%wa percentage of CPU time waiting for input output

1.1% hi

0.0% si

Line four: physical memory information

Total physical memory of mem:255102k

Total physical memory used by 253572K used

1548k free Memory Total

13576k buffers as the kernel cache memory

Line five: Exchange area information

Total Exchange area of swap:522104k

Total number of swap areas used by 9892k used

512212k free Idle swap area total

34120k cached the total number of swap areas buffered.

The content in memory is swapped out to the swap area and then swapped into 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, you do not have to write to the swap area again.

Process Information Area:

The details of each process are shown below the statistical information area. First of all, to understand 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 name for the owner of the group process

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

PR Priority

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

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

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

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

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

%mem: Percent of physical memory used by the process

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

Command: Commands name/Line

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

Swap: In virtual memory used by the process, the size not swapped out (KB)

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

Data: Physical memory size (KB) occupied by parts other than executable code (segments + stacks)

Number of Nflt page faults

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

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

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

Flags task flags, reference sched.h

SIZE: The amount of memory consumed by the process (code + data + stack)

RSS; Number of physical memory used by the process

Badness=oom_score (bandness)

Adj=oom_adjustment

After you enter the top command, continue to press the F key and select the display column you want to add

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

Press the O key to change the order in which the columns are displayed. A A-Z in lowercase can move the corresponding column to the right, while an uppercase A-Z moves the corresponding column to the left. Finally press ENTER to determine.

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

Top Command parameter explanation:

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

d Specifies the time interval between refresh of the screen information every two times. Of course, users can use the s interactive command to change it.

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

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

S Specifies the cumulative mode

s makes the top command run in Safe mode. This removes the potential risk of interaction commands.

I make top do 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 interaction commands that you can use during the top command execution. From a usage point of view, mastering these commands is more important than mastering the options. These commands are all single letters, and if the S option is used in command-line options, some of these commands may be blocked.

Ctrl+l Erase and rewrite the screen.

H or? Displays the help screen, giving some brief summary instructions.

K Terminates a process. The user is prompted to enter the process PID that needs to be terminated, and what signal needs to be sent to the process. The general termination process can use 15 signals, and if not, use signal 9 to force the end of the process. The default value is signal 15. This command is blocked in safe mode.

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

Q quit the program.

R to reschedule a process's priority level. The system prompts the user to enter the process PID to be changed and the process priority value that needs to be set. Entering a positive value causes the priority to be lowered, whereas the process can have a higher priority. The default value is 10.

S switch to cumulative mode.

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

F or F to 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 the display of memory information.

T toggles the display of process and CPU state information.

C Toggles the display of 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 used by the CPU.

T sorts according to time/cumulative time.

W writes the current settings to the ~/.TOPRC file. This is the recommended method for writing the top configuration file.

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 state of the process is zombie state. After the process completes all shutdown tasks, it submits the information that it closed to the parent process. In some cases, a zombie process cannot close itself, at which point the process state is Z (zombie). You cannot kill a zombie process with the KILL command 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 you can only reboot the server to get rid of the zombie process. It is also necessary to analyze why applications can lead to zombie.

The second line of tasks can see the number of zombie processes in the system 3, Iostat

More Iostat use examples and instructions to read: Iostat commands 6 use cases on Linux

AVG-CPU:

%user:user level (application) CPU occupancy rate

%nice: The CPU occupancy rate of the user level with nice priority added

CPU occupancy of the%sys:system level (kernel)

%idle: Idle CPU resource situation

Disk Information

Device: Block Device name

Tps: The number of transfers per second by the device (I/O requests per second). Multiple individual I/O requests can be composed of a transport operation, since a transport operation can be different capacity.

BLK_READ/S, BLK_WRTN/S: The number of blocks that the device reads and writes per second. Blocks can 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

For more examples of the Vmstat command, read: Vmstat 6 usage cases in Linux
The Vmstat command provides monitoring of processes, memory, page I/O blocks, and CPUs, Vmstat can display the average or sampled value of a test result, and a sampling pattern can provide a monitoring result for different frequencies during a sampling period.

process (procs)

R: Number of processes waiting for elapsed time

B: The process of being in an uninterrupted sleep state

W: The process that is swapped out but can still run, this value is calculated

MEMORYSWPD: Number of virtual memory

Free: Number of idle memory

Buff: Amount of memory used as buffer

Swap

Si: Number of exchange from hard disk

So: The number of exchanges to the hard drive

· Io

BI: Number of blocks output to a block device

Bo: Number of blocks received from a block device

system

In: Number of interrupts per second, including clocks

CS: Number of context switches occurrences per second

CPU (% of total CPU elapsed time)

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

SY: The time the kernel code runs (System time)

ID: Idle Time

WA: Time to wait for I/O operations

m: Displays kernel memory utilization

A: Displays memory page information, including active and inactive memory pages N: Displays the header row, which is useful when using sampling mode and outputting the command results to a file. For example, Root#vmstat–n 2 10 shows 10 output with 2 second frequency


5, PS and Pstree

Good command to analyze the process.

6. Sar

Automatically collects and saves system information, crontab configures 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 restart Apache every two hours

7 * * * */sbin/service sshd start with SSH service 7:50 every day

* * * * */sbin/service sshd stop means shut down SSH service 22:50 every day

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

1 * * * * * */home/bruce/backup The first part of the 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, locate the file named *.xxx and delete the file 4 days ago.

6 */10 * * ls means 1, 11, 21, 31st of every month Yes 6:30 execute the LS command once

7, free

displaying system memory Information

-b,-k,-m and-G were displayed according to bytes, kilobytes, megabytes, gigabytes.

-l difference shows how many times the low and high memory-c {count} shows free output


8, Pmap

Pmap PID to see the memory usage of a specific process


9. lsof--List open files

For more lsof instructions please read: lsof command 10 use cases in Linux

The lsof command, like many Linux/unix system commands, is used to display all open files and processes. These open files include disk files, network sockets, pipelines, devices, and processes. The main reason for using it is that when you uninstall the file system, if there are any open files in the filesystem, the operation will typically fail, then you can find out which processes are in use by lsof, and the most common format for this command is the following:

10. tcpdump--Network Packet Analyzer

Tcpdump is the most widely used command line-network packet analyzer or packet sniffer program-to capture or filter TCP/IP packets received or transferred from a network-specific interface. It also saves the captured packages to a folder. Tcpdump can be used on all major Linux distributions.

For more tcpdump use cases, read: 12 Use cases for TCPDUMP commands on Linux systems

11, netstat--Network statistics

Netstat is a command-line tool for monitoring incoming and outgoing network packet information and interface information statistics. It is useful for system administrators to use it to monitor network performance and troubleshoot network-related issues.
12. Htop--linux Process Monitoring

Htop is a more advanced interactive and real-time Linux process monitoring tool. This command is very similar to the top command, but its functionality is richer, such as friendly user interface process management, shortcuts, vertical and horizontal view processes, and so on. Htop is a Third-party plug-in tool that you need to install on a Linux system using the Yum Package management tool.

Htop Installation Instructions: Install Htop in Linux (Linux process monitoring)


13, lotop--monitoring Linux disk I/O

Lotop is similar to the top command and the Htop program, but it has statistical capabilities for real-time monitoring and display of disk I/O. This tool is useful for precise processes and for discovering high usage read/write processes. Loptop Installation Instructions: Install Loptop in Linux

14, disk use

df-h

15. View memory Information
# Cat/proc/meminfo

16, view the current operating system kernel information
# uname-a

17. View current operating system release information
# Cat/etc/issue | grep Linux

18. View Machine Model
# Dmidecode | grep "Product Name"

19, view the network card information
# DMESG | Grep-i ETH

20. View Linux Version
Lsb_release-a

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.