The common options for the Linux SAR command verbose SAR command are as follows:-A: Sum of all reports-u: Output CPU Usage Statistics-V: Output inode, Statistics for files and other kernel tables-D: Outputs the activity information for each block device-r: Statistics for output memory and swap space-B: Statistics showing I/O and transfer rate-A: file read and Write status-C: Output process statistics, Number of processes created per second-R: Output memory page statistics-y: TERMINAL equipment Activity Condition-w: Output system Exchange activity information 1. CPU resource monitoring For example, sampling every 10 seconds, sampling 3 times in a row, observing the CPU usage, and storing the sampled results in binary form in the file test in the current directory, type the following command: Sar-u-O Test 10 3 screen is displayed as follows: 17:06:16 CPU%user %nice%system%iowait%steal%idle17:06:26 all 0.00 0.00 0.20 0.00 0.00 99.8017:06:36 All 0.00 0.00 0.20 0.00 0.00 99.8017 : 06:46 All 0.00 0.00 0.10 0.00 0.00 99.90average:all 0.00 0.00 0.17 0.00 0.00 99.83 Output Item Description: Cpu:all indicates that the statistic is the average of all CPUs. %user: Displays the percentage of total CPU time that is running at the user level (application). %nice: The percentage of total CPU time that is displayed at the user level for the nice operation. %system: The percentage of total CPU time that is used to run at the core level (kernel). %iowait: Displays the percentage of total CPU time that is used to wait for I/O operations. %steal: The percentage of the hypervisor (hypervisor) that waits for a virtual CPU to serve another virtual process. %idle: Shows the percentage of CPU idle time that takes up the total CPU time. 1. If the value of%iowait is too high, the hard disk has an I/O bottleneck 2. If the value of the%idle 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 by 3. If the value of%idle is consistently below 1, the system has a relatively low CPU capacity, indicating that the most necessary resource to be addressed in the system is the CPU. If you want to view the contents of the binary file test, you would type the following SAR command: Sar-u-F test 2. Inode, file, and other kernel table monitoring for example, every 5 secondsSample once, 3 consecutive samples, observe the status of the core table, you need to type the following command: SAR-V 5 3 screen is displayed as follows: 17:10:49 DENTUNUSD file-nr inode-nr pty-nr17:10:59 6301 5664 12037 417:11:0 9 6301 5664 12037 417:11:19 6301 5664 12037 4average:6301 5664 12037 4 Output Item Description: DENTUNUSD: Number of entries not used in the directory cache FILE-NR: File handle Andle) INODE-NR: Number of uses of the index node handle (inode handle) PTY-NR: Pty number of 3 used. Memory and swap space monitoring for example, sample every 10 seconds, 3 consecutive samples, monitoring memory paging: SAR-R 10 3 Output Item Description: Kbmemfree: This value is basically the same as the free value in the free 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: This value is kbmemused and total memory (excluding swap ). Kbbuffers and kbcached: These two values are buffer and cache.kbcommit in the free command: the memory required to ensure that the current system is needed (RAM+SWAP).% Commit: This value is a percentage of kbcommit and total memory (including swap). 4. Memory paging Monitoring For example, sampling every 10 seconds, 3 consecutive samples, monitoring memory paging: Sar-b 3 Output Description: pgpgin/s: Number of bytes per second swapped from disk or swap to memory (KB) pgpgout/ S: Indicates the number of bytes per second from memory to disk or swap (KB) FAULT/S: The number of pages per second that the system generates, that is, the sum of the primary and secondary page faults (major + minor) majflt/s: The number of main pages generated per second. pgfree/ S: Number of pages per second that are placed in the idle queue pgscank/s: Number of pages scanned by KSWAPD per second pgscand/s: number of pages scanned directly per second pgsteal/s: The number of pages that are purged from the cache every second to meet memory needs%vmeff: Pages purged per second ( Pgsteal)% of Total Scan page (Pgscank+pgscand) &nbsP;5. I/O and transfer rate monitoring For example, sample every 10 seconds, 3 consecutive samples, report the use of the buffer, you need to type the following command: Sar-b 10 3 screen is displayed as follows: 18:51:05 TPS Rtps Wtps bread/s bwrtn/s18:51:15 0.00 0.00 0.00 0.00 0.0018:51:25 1.92 0.00 1.92 0.00 22.6518:51:35 0.00 0.00 0.00 0.00 0.00average:0.64 0.00 0.64 0.00 7.59 Output Items Description: TPS: Total I/O transfer per second for physical devices Rtps: Total amount of data read from physical device per second Wtps: Total amount of data written to physical device per second bread/s: The amount of data read from physical devices per second, in blocks/sbwrtn/ S: The amount of data written to the physical device per second, in block/S6. Process Queue Length and average load status monitoring For example, sampling every 10 seconds, sampling 3 consecutive times, monitoring process queue length and average load status: Sar-q 10 3 The screen is shown as follows: 19:25:50 runq-sz Plist-sz ldavg-1 ldavg-5 LDAVG-1519:26:00 0 259 0.00 0.00 0.0019:26:10 0 259 0.00 0.00 0.0019:26:20 0 259 0.00 0.00 0.00average:0 259 0.00 0.00 0. 00 Output Item Description: Runq-sz: The 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: The last 1 minutes of the system load Average) ldavg-5: Average system load of the last 5 minutes ldavg-15: System average load of the last 15 minutes 7. System Exchange activity information monitoring For example, sampling every 10 seconds, 3 consecutive samples, monitoring system exchange activity information: SAR- w 10 3 screen is displayed as follows: 19:39:50 PSWPIN/S PSWPOUT/S19 : 40:00 0.00 0.0019:40:10 0.00 0.0019:40:20 0.00 0.00average:0.00 0.00 Output Item Description: PSWPIN/S: Number of swap pages per second system swapped in (Swap page) pswpout/ S: System swap per secondNumber of swap pages (Swap page) 8. Device usage Monitoring For example, sampling every 10 seconds, sampling 3 times in a row, reporting device usage, you need to type the following command: # sar-d 10 3–p screen is displayed as follows:17:45:54 dev tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm %util17:46:04 scd0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0017:46:04 sda 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0017:46:04 vg_livedvd-lv_root 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.0017:46:04 vg_livedvd-lv_swap 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 Where: Parameter-P can print out the name of the disk device such as SDA,HDC, if not the parameter-p, the device node may be Dev8-0,dev22-0tps: the number of times per second from the physical disk I/O. Multiple logical requests are merged into one I/O disk request, The size of one transfer is indeterminate. RD_SEC/S: The number of read sectors per second. WR_SEC/S: Number of Write sectors per second. Avgrq-sz: The average data size (sector) for each device I/O operation. Avgqu-sz: The average length of the disk request queue. Await: The average elapsed time of each request, including the request queue wait time, in milliseconds (1 seconds =1000 milliseconds), from the request disk operation to the completion of the system processing. SVCTM: The average time that the system processes each request, excluding the time consumed in the request queue.%UTIL:I/O requests account for the percentage of CPU, The larger the ratio, the more saturated the description. 1. When the value of Avgqu-sz is low, the equipment utilization is high. 2. When the value of%util is close to 1%, it indicates that the device bandwidth is already full. To determine the system bottleneck, sometimes it takes several SAR command options to suspect a CPU bottleneck, use sar-u and sar-q to view suspected memory bottlenecks, use Sar-b, Sar-r, and sar-w to view suspected I/O bottlenecks, available sar-b, SA R-u and sar-d to view
Linux SAR Command detailed