The SAR command is included in the Sysstat Toolkit, providing a wide range of statistical data for the system. It commands a few differences on different systems.
Common formats for the SAR command line:
in the command line, the count and interval two parameters are combined to define the sampling interval and number of times, interval is the sampling interval, is a required parameter, count is the number of samples, is optional, the default value is 1,-o File indicates that the command result is stored in a binary format in a file, where file is not a keyword and is a file name. Options is a command-line option, and there are many choices for the SAR command, which are commonly used:
-A: Sum of all reports.
-U:CPU Utilization
-V: Process, I node, file, and lock table state.
-D: Hard drive usage report.
-r: No memory pages and hard disk blocks used.
-G: Serial I/O condition.
-B: Buffer usage.
-A: File read and write.
-C: System call condition.
-R: The activity of the process.
-y: terminal equipment activity situation.
-W: System Exchange activity.
- N: Network statistics
An example is shown below.
Example one: Using the command line Sar-u T n
For example, sample every 1 seconds, 5 consecutive samples, observe the CPU usage, you need to type the following command:
[[email protected] ~]# sar-u 1 5Linux 2.6.14.7-selinux1-wr1.4aq_cgl (MSP) 01/03/0717:51:51 CPU %user %nice %system %iowait %idle17:51:52 all 0.00 0.00 0.50 0.00 99.5017:51:53 all 6.53 0.00 2.01 0.00 91.4617:51:54 all 0.51 0.00 0.51 0.00 98.9917:51:55 all 1.01 0.00 0.50 0.50 97.9917:51:56 all 4.04 0.00 1.52 0.00 94.44Average: all 2.42 0.00 1.01 0.10 96.48[[email protected] ~]#
The contents of the display include:
%usr:cpu the percentage of time in user mode.
%nice:cpu the percentage of time in low-first-level mode.
%sys:cpu the percentage of time in system mode.
%iowait:cpu the percentage of time to wait for the input output to finish.
%IDLE:CPU idle time percentage.
Example two: Using the life line SAR-V T n
For example, sampling every 2 seconds, sampling 3 times in a row, observing the status of the core table, you need to type the following command:
[Email protected] ~]# sar-v 2 317:53:50 DENTUNUSD file-sz inode-sz super-sz%super-sz Dquot-sz%dquot-sz rtsig-sz%rtsig-sz17:53:52 12947 5340 14310 0 0.00 0 0.00 0 0.0017:53:54 12948 5340 14316 0 0.00 0 0.00 0 0.0017:53:56 12948 5340 14316 0 0.00 0 0.00 0 0.00Average: 12948 5340 14314 0 0.00 0 0.00 0 0.00[[email protected] ~]#
Example three: Using the life line sar-d T n
For example, sampling every 30 seconds, sampling 5 consecutive times, reporting device usage, you need to type the following command:
# sar-d 30 5
Screen display:
sco_sv scosysv 3.2v5.0.5 i80386 10/01/2001
11:06:43 device %busy avque r+w/s blks/s avwait avserv (-D) 11:07:13 wd-0 1.47 2.75 4.67 14.73 5.50 3.1411:07:43 wd-0 0.4 3 18.77 3.07 8.66 25.11 1.4111:08:13 wd-0 0.77 2.78 2.77 7.26 4.94 2.7711:08:43 wd-0 1.10 11.18 4. 11.26 27.32 2.6811:09:13 wd-0 1.97 21.78 5.86 34.06 69.66 3.35Average wd-0 1.15 12.11 4.09 15.19 31.12 2.80
Display content includes:
The Device:sar command is monitoring the name of the block device.
%busy: The percentage of time that the transfer request takes up when the device is busy.
Avque: The average number of requests not completed when the queue is full.
R+W/S: The amount of data transmitted to or from the device per second.
BLKS/S: Number of blocks transmitted per second, 512 bytes per block.
Avwait: The average time that the transmit request waits for the queue to be idle when the queue is full.
Avserv: The average time (in milliseconds) required to complete the transfer request.
Example of four network statistics
[[email protected] ~]# sar-n SOCK 3 2 Linux 2.6.14.7-SELINUX1-WR1.4AQ_CGL (MSP) 01/03/0717:58:43 totsck tcpsck udpsck rawsck I P-FRAG17:58:46 1414 658 123 1 017:58:49 1414 658 123 1 0average:1414 658 123 1 0[[email protected] ~]#
Total number of sockets used by totsck
Number of TCP sockets used by tcpsck
Number of UDP sockets used by udpsck
Number of raw sockets used by the RAWSCK
Number of IP segments used by the Ip-frag
Example five: using Sar-b t n
For example, sampling every 5 seconds, sampling 2 times in a row, reporting the use of the buffer, you need to type the following command:
Screen display:
[Email protected] ~]# sar-b 5 2
Linux 2.6.14.7-SELINUX1-WR1.4AQ_CGL (MSP) 01/03/0718:04:24 TPs Rtps wtps bread/s bwrtn/ S18:04:29 0.00 0.00 0.00 0.00 0.0018:04:34 0.00 0.00 0.00 0.00 0.00Average: 0.00 0.00 0.00 0.00 0.00[[email Protected] ~]#
display content includes:
bread/s: The number of physical blocks per second read from the hard disk into the system buffer.
lread/s: The average number of logical blocks read from the system buffer per second.
%rcache: The percentage of logical reads in the buffer cache.
bwrit/s: The average number of physical blocks written to disk per second from the system buffer.
lwrit/s: The average number of logical blocks per second written to the system buffer.
%wcache: The percentage of logical reads in the buffer cache.
pread/s: The average number of physical reads requested per second.
pwrit/s: The average number of physical writes per second requested.
in the displayed content, the most important is the%cache and%wcache two columns, their values reflect the efficiency of the use of buffer, the value of%rcache less than 90 or the value of%wcache is less than 65, should increase the number of system buffer appropriately, Buffer number by the core parameter Nbuf control, so that the%rcache reached about 90,%wcache reached about 80. But the buffer parameter value of how much affect I/O efficiency, increase buffer, should be in the case of large memory, otherwise the system efficiency is not improved.
Example six: Using the life line SAR-G T n
For example, sampling every 30 seconds, continuously sampling 5 times, reporting the operation of serial I/O, you need to type the following command:
# SAR-G 30 5
Screen display:
SCO_SV scosysv 3.2v5.0.5 i80386 11/22/200117:07:03 ovsiohw/s ovsiodma/s ovclist/s (-G) 17:07:33 0.00 0.00 0.0017: 08:03 0.00 0.00 0.0017:08:33 0.00 0.00 0.0017:09:03 0.00 0.00 0.0017:09:33 0.00 0.00 0.00Average 0.00 0.00 0.00
Display content includes:
OVSIOHW/S: Overflow in serial I/O hardware per second.
OVSIODMA/S: Overflow in the direct input/output channel cache per second for serial I/O.
OVCLIST/S: The overflow of character queues per second.
In the displayed content, the value of each column is zero, indicating that no serial I/O overflow occurred in the system during the sampling time.
Linux Performance Test SAR command