In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "the usage of sar command under linux". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Detailed explanation of linux sar command
August 21, 2012? CentOS, Linux? 4053 words in total? The font size is small, medium and large? One comment? Read it 41015 times
Sar (System Activity Reporter system activity report) is one of the most comprehensive system performance analysis tools on Linux, which can report system activities from many aspects, including: reading and writing of files, usage of system calls, disk ID O, CPU efficiency, memory usage, process activities and IPC-related activities. This paper mainly introduces the sar command by taking CentOS 6.3x64 system as an example.
Common format of sar command
Sar [options] [- A] [- o file] t [n]
Where:
T is the sampling interval, n is the number of samples, and the default value is 1
-o file means to store the result of the command in a file in binary format, where file is the file name.
Options is a command line option, and the common options for sar commands are as follows:
-A: the sum of all reports
-u: output statistics on CPU usage
-v: output statistics for inode, files, and other kernel tables
-d: output activity information for each block device
-r: output memory and swap space statistics
-b: displays statistics for Ihammer O and transfer rate
-a: reading and writing of documents
-c: output process statistics, number of processes created per second
-R: output statistics for memory pages
-y: terminal device activity
-w: output system exchange activity information
1. CPU resource monitoring
For example, to sample every 10 seconds, for 3 consecutive times, to observe the usage of CPU, and to store the sampling results in the file test in the current directory in binary form, type the following command:
Sar-u-o test 10 3
The screen displays as follows:
17:06:16 CPU user nice system iowait steal idle
17:06:26 all 0.00 0.00 0.20 0.00 0.00 99.80
17:06:36 all 0.00 0.00 0.20 0.00 0.00 99.80
17:06:46 all 0.00 0.00 0.10 0.00 0.00 99.90
Average: all 0.00 0.00 0.17 0.00 0.00 99.83
Output item description:
CPU:all indicates that the statistics are the average of all CPU.
% user: displays the percentage of total time spent using CPU running at the user level (application).
% nice: the percentage of total CPU time spent on nice operations displayed at the user level.
% system: the percentage of total time spent running CPU at the core level (kernel).
% iowait: displays the percentage of total CPU time spent waiting for the IUnip O operation.
% steal: the percentage that the hypervisor (hypervisor) waits for the virtual CPU while serving another virtual process.
% idle: displays the percentage of total CPU time occupied by CPU idle time.
1. If the value of% iowait is too high, it indicates that there is a bottleneck in the hard disk.
two。 If the value of% idle is high but the system response is slow, it is possible that CPU is waiting to allocate memory. At this time, the memory capacity should be increased.
3. If the value of% idle is consistently lower than 1, the CPU processing capacity of the system is relatively low, indicating that the resource that needs to be solved most in the system is CPU.
To view the contents of the binary file test, type the following sar command:
Sar-u-f test
2. Inode, file and other kernel table monitoring
For example, to observe the status of the core table by sampling every 10 seconds for 3 consecutive times, type the following command:
Sar-v 10 3
The screen displays as follows:
17:10:49 dentunusd file-nr inode-nr pty-nr
17:10:59 6301 5664 12037 4
17:11:09 6301 5664 12037 4
17:11:19 6301 5664 12037 4
Average: 6301 5664 12037 4
Output item description:
Dentunusd: the number of unused entries in the directory cache
File-nr: number of file handles (file handle) used
Inode-nr: number of index node handles (inode handle) used
Pty-nr: number of pty used
3. Memory and swap space monitoring
For example, sample every 10 seconds, sample 3 times in a row, and monitor memory paging:
Sar-r 10 3
The screen displays as follows:
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 a percentage of kbmemused and total memory (excluding swap).
Kbbuffers and kbcached: these two values are buffer and cache in the free command.
Kbcommit: guarantee the memory needed by the current system, that is, the memory needed to ensure that it does not overflow (RAM+swap).
% commit: this value is a percentage of kbcommit to total memory (including swap).
4. Memory paging monitoring
For example, sample every 10 seconds, sample 3 times in a row, and monitor memory paging:
Sar-B 10 3
The screen displays as follows:
Output item description:
Pgpgin/s: indicates the number of bytes per second 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 missing pages generated by the system per second, that is, the sum of primary and secondary missing pages (major + minor)
Majflt/s: the number of main missing pages generated per second.
Pgfree/s: the number of pages placed in the idle queue per second
Pgscank/s: number of pages scanned by kswapd per second
Pgscand/s: the number of pages directly scanned per second
Pgsteal/s: the number of pages cleared from cache per second to meet memory requirements
% vmeff: percentage of pages cleared per second (pgsteal) to total scanned pages (pgscank+pgscand)
5. Icano and transfer rate monitoring
For example, to report buffer usage by sampling every 10 seconds for 3 consecutive times, type the following command:
Sar-b 10 3
The screen displays as follows:
18:51:05 tps rtps wtps bread/s bwrtn/s
18:51:15 0.00 0.00 0.00
18:51:25 1.92 0.00 1.92 0.00 22.65
18:51:35 0.00 0.00 0.00
Average: 0.64 0.00 0.64 0.00 7.59
Output item description:
Tps: the total amount of Istroke O transmissions per second of physical devices
Rtps: the total amount of data read from the physical device per second
Wtps: the total amount of data written to the physical device per second
Bread/s: the amount of data read from a physical device per second, in blocks per second
Bwrtn/s: the amount of data written to the physical device per second, in blocks per second
6. Monitoring of process queue length and average load status
For example, sample every 10 seconds, sample 3 times in succession, and monitor the queue length and average load status of the process:
Sar-Q 10 3
The screen displays as follows:
19:25:50 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15
19:26:00 0 259 0.00 0.00 0.00
19:26:10 0 259 0.00 0.00 0.00
19:26:20 0 259 0.00 0.00 0.00
Average: 0 259 0.00 0.00 0.00
Output item description:
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: average system load in the last minute (System load average)
Ldavg-5: average system load over the past 5 minutes
Ldavg-15: average system load over the past 15 minutes
7. System exchange activity information monitoring
For example, sampling every 10 seconds, sampling 3 times in a row, and the monitoring system exchanges activity information:
Sar-W 10 3
The screen displays as follows:
19:39:50 pswpin/s pswpout/s
19:40:00 0.00 0.00
19:40:10 0.00 0.00
19:40:20 0.00 0.00
Average: 0.00 0.00
Output item description:
Pswpin/s: the number of swap pages (swap page) swapped in by the system per second
Pswpout/s: the number of swap pages (swap page) swapped out by the system per second
8. Equipment usage monitoring
For example, to report device usage by sampling every 10 seconds for 3 consecutive times, type the following command:
# sar-d 10 3-p
The screen displays as follows:
17:45:54 DEV tps rd_sec/s wr_sec/s avgrq-sz avgqu-sz await svctm util
17:46:04 scd0 0.00 0.00 0.00
17:46:04 sda 0.00 0.00 0.00
17:46:04 vg_livedvd-lv_root 0.00 0.00 0.00
17:46:04 vg_livedvd-lv_swap 0.00 0.00 0.00
Where:
The parameter-p can print out the disk device names such as sda,hdc. If the parameter-p is not used, the device node may be dev8-0dev22-0.
Tps: the number of times per second from the physical disk. Multiple logical requests will be merged into a single disk request, and the size of a transfer is uncertain.
Rd_sec/s: the number of times sectors are read per second.
Wr_sec/s: the number of times sectors are written per second.
Avgrq-sz: the average data size (sector) of each device Istroke O operation.
Avgqu-sz: the average length of the disk request queue.
Await: the average elapsed time of each request, including the waiting time of the request queue, from the request disk operation to the completion of the system processing, in milliseconds (1 second = 1000 milliseconds).
Svctm: the average time the system processes each request, excluding the time spent in the request queue.
% util:I/O requests as a percentage of CPU, the higher the ratio, the more saturated it is.
1. When the value of avgqu-sz is low, the utilization of the device is higher.
two。 When the value of% util is close to 1%, the device bandwidth is full.
To determine the bottleneck of the system, it sometimes requires a combination of several sar command options
It is suspected that there is a bottleneck in CPU. You can check it with sar-u and sar-Q.
Memory bottleneck is suspected. Check it with sar-B, sar-r, sar-W, etc.
It is suspected that there is a bottleneck in IBG O, which can be checked by sar-b, sar-u and sar-d.
This is the end of the introduction of "the usage of the sar command under linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.