Common linux commands for Performance Testing

Source: Internet
Author: User
Tags superuser permission

Common linux commands for Performance Testing

Common linux commands for performance testing.

1. uptime

  1. [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

    For more examples of TOP commands, refer to the 12 Use Cases of top commands on Linux.

    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 is the size of the SWAp zone where the content already exists. 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

    For more iostat examples and instructions, refer to the six Use Cases of the iostat command on Linux.

    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

    For more examples of using the vmstat command, see the six Use Cases of vmstat in Linux.

    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

     

    View the memory image information of a process (report memory map of a process) # pmap usage pmap [options] PID [PID...] options:-x, -- extended show details // display the extended format-X show even more details WARNING: format changes according to/proc/PID/smaps-XX show everything the kernel provides-c, -- read-rc read the default rc-C, -- read-rc-from = Read the rc from file-n, -- create-rc create new default rc-N, -- create-rc-to = Create new rc to file NOTE: pid arguments are not allowed with-n,-N-d, -- device show the device format // display the device format-q, -- quiet do not display header and footer // do not display the header and tail line-p, -- show-path show path in the mapping-A, -- range = [, ] Limit results to the given range
    -H, -- help display this help and exit-V, -- version output version information and exit // display version
    Extended format and device format domain: Address: start address of map image start Address Kbytes: size of map in kilobytes image size (KB) RSS: resident set size in kilobytes resident set size (keep memory size) (KB) Dirty: dirty pages (both shared and private) in kilobytes Dirty page size (KB) Mode: permissions on map: r = read, w = write, x = execute, s = shared, p = private (copy on write) Mapping: file backing the map, or '[anon]' for allocated memory, or '[stack]' for the program stack. for files that occupy memory, [anon] indicates the allocated memory, and [stack] indicates the program stack Offset: offset into the file Offset Device: device name (major: minor) indicates the Device name.
    # Pmap-x 5002 5002:/opt/jvm/java8/bin/java-Dorg. mortbay. util. URI. charset = UTF-8-Xmx6008331k-Xms6008331k-XX: MaxPermSize = 512 m-Djava. library. path =/opt/app /.. /libswt/linux/x86_64 /...... e. enc Address Kbytes RSS Dirty Mode Mapping 0000000000400000 4 4 0 r-x -- java 0000000000600000 4 4 4 rw --- java 000000000120d000 132 24 24 rw --- [anon] 0000000651400000 6015488 573320 573320 rw --- [anon] ...... listen 7fffa449f000 132 44 44 rw --- [stack] Listen 7fffa45fe000 8 4 0 r-x -- [anon] ffffffffff600000 4 0 0 r-x -- [anon] ---------------- ------- total kB 12052840 856168 806504
    # Pmap-d pid 5002:/opt/jvm/java8/bin/java-Dorg. mortbay. util. URI. charset = UTF-8-Xmx6008331k-Xms6008331k-XX: MaxPermSize = 512 m-Djava. library. path =/opt/app /.. /libswt/linux/x86_64 /...... address Kbytes Mode Offset Device Mapping 0000000000400000 4 r-x -- 0000000000000000 0fd: 00000 java 0000000000600000 4 rw --- 0000000000000000 0fd: 00000 java 000000000120d000 132 rw --- 0000000000000000 000:00000 [anon] ...... listen 132 rw --- 0000000000000000 000:00000 [stack] Listen 7fffa45fe000 8 r-x -- 0000000000000000 000:00000 [anon] ffffffff600000 4 r-x -- 0000000000000000 000:00000 [anon] mapped: 12014504 K writeable/private: 6589148 K shared: 38336 K
    The value mapped in the last line indicates the size of the virtual address space mapped by the process, that is, the virtual memory size pre-allocated by the process, that is, the ps-output vsz writeable/private: the size of the private address space occupied by the process, that is, the memory size actually used by the process shared: the memory size shared by the process and other processes
    Show only the last row: # pmap-d 5002 | tail-1 mapped: 12014504 K writeable/private: 6589148 K shared: 38336 K
    Display the last line of the loop. Try to monitor the memory usage of the process: # while true; do pmap-d 5002 | tail-1; sleep 3; done

     

    9. LSOF -- list opened files

    For more instructions on how to use lsof, refer to the 10 Use Cases of lsof commands in Linux.

    Like many Linux/Unix system commands, lsof is used to display all opened files and processes. These open files include disk files, network sockets, pipelines, devices, and processes. The main reason for using it is that when the file system is detached, if there is any open file in the file system, the Operation will usually fail, then lsof can be used to find out which processes are in use, the most common format of this command is as follows:


    10. TCPDUMP-network packet Analyzer

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

    For more use cases of tcpdump, see the following 12 Use Cases of the tcpdump command in Linux:

    11. NETSTAT-network statistics

    Netstat is a command line tool used to monitor incoming and outgoing network packet information and interface information statistics. The system administrator can use it to monitor network performance and troubleshoot network problems.


    12. HTOP-Linux Process Monitoring

    Htop is a more advanced interactive and real-time Linux Process Monitoring Tool. This command is similar to the top command, but has more functions, such as friendly user interface process management, shortcut keys, vertical and horizontal view processes. Htop is a third-party plug-in tool. You must use the YUM software package management tool to install it on Linux.

    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 the statistical function to monitor and display disk I/O in real time. This tool is very useful for precise processes and for discovering high-usage read/write processes.

    Loptop installation instructions: Install loptop in Linux

    14. disk usage

    Df-h

    15. view memory information
    # Cat/proc/meminfo

    16. view the kernel information of the current operating system
    # Uname-

    17. view the released version of the current operating system
    # Cat/etc/issue | grep Linux

    18. view the Machine Model
    # Dmidecode | grep "Product Name"

    19. View Nic Information
    # Dmesg | grep-I eth

    20. view the linux version
    Lsb_release-
     

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.