Linux Common Performance Tools

Source: Internet
Author: User
Tags cpu usage

I. wget file download use wget to download a single file: wget URL to download and save with a different file name: Wget-o wordpress.zip urlwget speed limit download: wget--limit-rate=300k URL using wget breakpoint continuation: wget-c URL using wget background download: wget-b url (View download progress: tail-f wget-log) test download link: wget--spider URL Download specified format file: Wget-r-a.pdf U Rlftp Download: wget--ftp-user=username--ftp-password=password URL Second,SCP cross-Machine remote copy copies files from a distance to a local directory: $SCP [email protected]:/opt/soft/demo.tar/opt/soft/copied from a distance to Local: $SCP-R [email protected]:/opt/ soft/test/opt/soft/upload local file to remote machine specified directory: $SCP/opt/soft/demo.tar [email protected]:/opt/soft/scptest upload local directory to remote machine specified directory: $ Scp-r/opt/soft/test [email protected]:/opt/soft/scptest. Sar SAR is an abbreviation for the system activity Reporter (Systems Activities report). The SAR tool samples the current state of the system and then expresses the current operational state of the system by calculating the data and scale. It is characterized by a continuous sampling of the system, the acquisition of a large number of sampling data, sampling data and analysis of the results can be stored in the file, the required load is very small. The SAR is one of the most comprehensive system performance analysis tools on Linux, which can be used to report the activities of the systems from 14 aspects, including the reading and writing of the files, the usage of the system calls, the serial port, CPU efficiency, memory usage, process activities and IPC related activities. View CPU Usage: Sar-u 1 2 (the next two parameters represent the frequency of the monitoring, such as 1 and 2 in the example, which is sampled once per second, with a total of two samples)
    • %user the percentage of CPU time consumed in user mode;
    • %nice the percentage of CPU time consumed in user mode by changing the process scheduling priority process through nice
    • %system the proportion of CPU time consumed in the system mode;
    • %iowait the percentage of time that the CPU waits for disk I/O to consume idle state;
    • %steal uses operating system virtualization technologies such as Xen to wait for the percentage of time that other virtual CPUs compute to occupy;
    • %idle CPU idle time ratio;
To view the average CPU load: Sar-q 1 2
    • Runq-sz: Length of the run queue (number of processes waiting to run)
    • Plist-sz: Number of processes (processes) and threads (threads) in the process list
    • Ldavg-1: System average load for last 1 minutes
    • Ldavg-5: System average load over the last 5 minutes
    • Ldavg-15: System average load over the last 15 minutes
Query Memory: Sar-r 1 2
    • Kbmemfree: This value is basically the same as the free value in the command, so it does not include buffer and cache space.
    • Kbmemused: This value is basically the same as the used value in the free command, so it includes buffer and cache space.
    • %memused: Physical memory usage, this value is a percentage of kbmemused and total memory (excluding swap).
    • Kbbuffers and kbcached: These two values are the buffer and cache in the free command.
    • Kbcommit: Ensure that the current system requires memory (RAM+SWAP) in order to ensure that it does not overflow.
    • %commit: This value is a percentage of kbcommit and total memory (including swap).
Query page Exchange: SAR-W 1 3
    • PSWPIN/S: Number of swap pages per second system swapped in (Swap page)
    • PSWPOUT/S: Number of swap pages per second system swapped out (Swap page)
The Freefree tool is used to query the available memory of the system, shows the number of unused and used memory in the current system, and can also display memory buffers used by the kernel.
    • Total: Memory Totals
    • Used: Number of memory already in use
    • Free: The number of idle memory
    • Shared: not currently obsolete
    • Buffers buffer: Number of cache memory
The amount of memory that the program actually eats: The total amount of memory that used-buff/cache in MEM can divert: the Free + Buff/cache swap in mem: That's what we typically call virtual memory.    When memory is used to a certain value, it starts swapping (how to view the rating Cat/proc/meminfo) the difference between page cache and buffer cache? In short, page cache is used to cache file data, and buffer cache is used to cache disk data. In the case of a file system, the data is cached to the page cache. If the disk is read and written directly using tools such as DD, the data is cached to buffer cache. Free-s #周期性的查询内存使用情况, execute commands every 10s five, Iostat

It is used to monitor system input and CPU usage, which is characterized by reporting disk activity statistics and also reporting CPU usage.

Note: If the value of%iowait is too high, the hard disk has an I/O bottleneck. A high%idle value indicates that the CPU is more idle. If the%idle value is high but the system responds slowly, it is possible that the CPU waits for the allocated memory, and the memory capacity should be increased at this time. If the%idle value continues below 10, the system's CPU processing power is relatively low, indicating that the most resource to be addressed in the system is the CPU.
    • TPS: The number of transmissions per second of the device;
    • KB_READ/S: The amount of data read from the device (drive expressed) per second;
    • KB_WRTN/S: The amount of data written to the device (drive expressed) per second;
    • Kb_read: The total amount of data read; Kb_wrtn: The amount of total data written;
Liu, Vmstat

Displays the virtual memory status, but he can report on the status of the system running, such as process, memory, I/O, etc.

Procs (Process)
R: The number of processes running in the queue, this value can also determine whether to increase the CPU. (longer than 1)
B: The number of processes waiting for IO.

Memory (RAM)
SWPD: Using virtual memory size, if the value of SWPD is not 0, but the value of Si,so is 0 for a long time, this situation does not affect system performance.
Free: The size of the idle physical memory.
Buff: The amount of memory used as a buffer.
Cache: As the memory size of the buffer, if the cache value is large, the number of files in the cache, if the frequently accessed files can be cached, then the disk read IO bi will be very small.

Swap
Si: Writes from the swap area to the memory size per second, and the disk is transferred into memory.
So: The amount of memory written to the swap area per second is transferred from memory to disk.
Note: When memory is sufficient, these 2 values are 0, and if these 2 values are longer than 0 o'clock, system performance will be affected and both disk IO and CPU resources will be consumed. Some friends see that free memory is very small or close to 0 o'clock, think that memory is not enough, not to see this, but also to combine SI and so, if it is very small, but Si and so are very few (mostly 0), then do not worry, the system performance will not be affected.

IO (now the size of the Linux version block is 1KB)
BI: Number of blocks read per second
Bo: Number of blocks written per second
Note: When the random disk reads and writes, these 2 values are larger (such as exceeding 1024k), you can see the CPU in the IO waiting value will be greater.

System (Systems)
In: Number of interrupts per second, including clock interrupts.
CS: The number of context switches per second.
Note: The larger the 2 values above, the greater the CPU time that is consumed by the kernel.

CPU (expressed as a percentage)
US: Percentage of user Process Execution time
When the value of us is higher, it means that the user process consumes more CPU time, but if it is used over a long period of 50%, then we should consider optimizing the program algorithm or accelerating it.
Sy: Percentage of kernel system Process Execution (System time)
When the value of SY is high, it indicates that the system kernel consumes more CPU resources, this is not a benign performance, we should check the cause.
Wa:io Wait Time percentage
When the value of WA is high, it indicates that IO waits are serious, which may be caused by a large number of random accesses to the disk, or there may be bottlenecks (block operations) on the disk.

ID: Percentage of idle time

Seven, top

It can view the whole operation of the system in real time, and it is a utility tool which synthesizes the performance and operation information of multi-party information monitoring system, and is the task Manager under Linux. The interactive interface provided by the top command can be managed with a hotkey. The hotkeys are as follows:

  • Q: Exit the top command
  • <space>: Refresh Now
  • S: Set Refresh time interval
  • C: Show command full mode
  • T:: Show or hide process and CPU status information
  • M: Show or hide memory status information
  • L: Show or hide uptime information
  • F: Increase or decrease the process display flag
  • S: Cumulative mode, the CPU time occupied by the completed or exited subprocess is accumulated to the parent process's mite+
  • P: Ranked by%CPU usage rate
  • T: Rank by mite+
  • M: Ranked by%mem
  • U: Specify display user process
  • R: Modify Process Renice Value
  • Kkill: Process
  • I: Show only running processes
  • W: Save settings for top to file ^/.TOPRC, the next boot will automatically call the settings of the TOPRC file.
  • H: Help command.
  • Q: Exit

Note: It is emphasized that the most frequently used is P, T, M, because top is usually used, and we want to see which processes are consuming the most CPU resources and memory; Note: You can change the sort order right or left by using SHIFT + > or SHIFT + < If you only need to view memory: Free command available. View only uptime information (first line), the uptime command is available;

First line

      • 11:57:12: System Current time
      • , 2:45: How much time has the system been booting to now?
      • 3 Users: current 3 user Online
      • Load average:0.19, 0.17, 0.14: System 1-minute, 5-minute, 15-minute CPU load information

Second line

      • tasks: task;
      • 205 Total: Well understood, there are currently 205 tasks, that is, 205 processes.
      • 2 Running:2 a process is running
      • 203 sleeping:203 a process sleep
      • 0 stopped: Number of processes stopped
      • 0 Zombie: Number of zombie processes

Third line

      • CPU (s): Indicates that this line shows CPU overall information
      • 9.1%us: The user-state process consumes a percentage of CPU time and does not contain the CPU time that the Renice value is a negative task consumes.
      • 1.3%sy: Percentage of CPU time consumed by the kernel
      • 0.0%ni: The percentage of CPU that has changed the priority of the process
      • 89.6%id: Percentage of idle CPU time
      • 0.0%wa: Percentage of CPU time waiting for I/O
      • 0.0%hi:cpu% Hard Interrupt Time
      • 0.0%si:cpu Soft Interrupt Time percentage
      • Note: This shows that the data is the average of all CPUs, if you want to see the processing of each CPU, press 1, fold, press 1 again;

Line Four

      • Men: The Meaning of memory
      • Total: Amount of physical memory
      • Used: The amount of physical memory used
      • Free: Idle amount of physical memory
      • Buffers: The amount of physical memory used as the kernel cache

Line Five

      • Swap: Swap space
      • Total: Swap area totals
      • Used: Amount of swap area used
      • Free: Amount of idle swap area
      • Cached: Total buffer swap Area

Process information

      • PID: ID of the process
      • USER: Process Owner
      • PR: The priority level of the process, the smaller the higher the priority is executed
      • Ninice: Value
      • VIRT: Virtual memory consumed by the process
      • RES: The physical memory occupied by the process
      • SHR: Shared memory used by the process
      • S: The state of the process. s for hibernation, R for running, Z for Zombie, n for the process priority value is negative
      • %CPU: Process Consuming CPU utilization
      • %MEM: The percentage of physical memory and total memory used by the process
      • Time+: The total CPU time that is consumed after the process is started, which is the cumulative value of the CPU usage time.
      • Command: Process start name
Viii. Conclusion

The blogger is just a Linux rookie. Faith first Bo Hou yuan principle, see these knowledge, first write down, then specific use of time to delve into it. Caishuxueqian, said the wrong place, also please correct me, welcome to discuss. Also found on GitHub on a Linux command search tool, very useful, introduced to you: https://jaywcjlove.github.io/linux-command/

Linux Common Performance Tools

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.