Linux SAR Command detailed

Source: Internet
Author: User
Tags switches cpu usage nfsd

Reference Link: http://lovesoo.org/linux-sar-command-detailed.html

common formats for SAR commands

SAR [Options] [-A] [-o file] t [n]

which

T is the sampling interval, n is the number of samples, the default value is 1;

-o file means that the command result is stored in a binary format in a file, and file is a filename.

Options is a command-line option, and the SAR command is commonly used as follows:

-A: Sum of all reports

-U: Output statistics about 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: Display statistics for I/O and transfer rates

-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 situation

-W: Output system Exchange activity information

1. CPU Resource Monitoring

For example, sampling every 10 seconds, sampling 3 times in a row, observing CPU usage, and storing the sample results in binary form in the file test in the current directory, type the following command:

Output Item Description:

Cpu:all represents the average of the statistics for 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%iowait value is too high, it indicates that 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, at which time the memory capacity should be increased

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 a binary file test, you would type the following SAR command:

Sar-u-F Test

2. Inode, file, and other kernel table monitoring

For example, sampling every 10 seconds, sampling 3 times in a row, observing the status of the core table, you need to type the following command:

Sar-v 10 3

The screen appears 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: Number of unused entries in the directory cache

FILE-NR: The number of file handles (files handle) used

INODE-NR: Number of uses of the index node handle (inode handle)

PTY-NR: Number of Pty used

3. Memory and swap space monitoring

For example, sampling every 10 seconds, sampling 3 times in a row, monitoring memory paging:

Sar-r 10 3

The screen appears as follows:

Output Item Description:

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: 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).

4. Memory Paging Monitoring

For example, sampling every 10 seconds, sampling 3 times in a row, monitoring memory paging:

Sar-b 10 3

The screen appears 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 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 free queue

PGSCANK/S: Number of pages scanned per second by KSWAPD

PGSCAND/S: Number of pages scanned directly per second

PGSTEAL/S: The number of pages per second that are purged from the cache to meet memory requirements

%vmeff: Percentage of pages purged per second (pgsteal) in total scan page (Pgscank+pgscand)

5. I/O and transfer rate monitoring

For example, sampling every 10 seconds, sampling 3 times in a row, reporting the use of the buffer, you need to type the following command:

Sar-b 10 3

The screen appears as follows:

18:51:05 TPs Rtps Wtps bread/s bwrtn/s

18:51:15 0.00 0.00 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 0.00 0.00

average:0.64 0.00 0.64 0.00 7.59

Output Item Description:

TPS: Total I/O transfers per second for physical devices

Rtps: Total amount of data read from physical devices per second

Wtps: The total amount of data written to the physical device per second

BREAD/S: The amount of data read from the physical device per second, in blocks/s

BWRTN/S: The amount of data written to the physical device per second, in blocks/s

6. Process Queue Length and average load status monitoring

For example, sampling every 10 seconds, sampling 3 times in a row, monitoring process queue length and average load status:

Sar-q 10 3

The screen appears 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 for last 1 minutes (systems load average)

Ldavg-5: System average load over the last 5 minutes

Ldavg-15: System average load over the last 15 minutes

7. System Exchange activity Information monitoring

For example, samples are sampled every 10 seconds, sampled 3 times in a row, monitoring system exchange activity information:

Sar-w 10 3

The screen appears 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: Number of swap pages per second system swapped in (Swap page)

PSWPOUT/S: Number of swap pages per second system swapped out (Swap page)

8:sar-n #统计网络信息

The #sar-N option uses 6 different switches: DEV,EDEV,NFS,NFSD,SOCK,IP,EIP,ICMP,EICMP,TCP,ETCP,UDP,SOCK6,IP6,EIP6,ICMP6,EICMP6 and UDP6, The dev Displays the network interface information, Edev displays statistics about network errors, NFS Statistics active NFS Client information, NFSD statistics Server for NFS, sock displays socket information, all shows all 5 switches. They can be used alone or together.

Sar-n DEV 1 1: Statistics per interval 1 seconds, total statistics 1 times, the following average is the average after multiple statistics

#IFACE the name of the local NIC interface

#rxpck/S Packet accepted per second

#txpck/S database sent per second

#rxKB/S Packet size accepted per second in kilobytes

#txKB/S Packet size sent per second in kilobytes

#rxcmp/s compressed packets accepted per second

#txcmp/s Compressed package sent per second

#rxmcst/s Multicast packets received per second

Sar-n Edev 1 1 #统计网络设备通信失败信息:

#IFACE NIC Name

#rxerr/s corrupted packets received per second

#txerr/s number of packet errors sent per second

#coll/s The number of collisions (collisions) that occur per second when sending packets, this is in half-duplex mode

#rxdrop/s The number of network packets discarded per second by the receiving end of the NIC device as a result of the buffer full

#txdrop/s The number of network packets dropped per second by the network device sender when the buffer is full

#txcarr/s The number of carrier errors per second that occur when sending packets

#rxfram the number of frames per second that occurred when the packet was received

#rxfifo the number of times a buffer overflow error occurred per second when receiving a packet

#txfifo the number of times a buffer overflow error occurred per second when a packet occurred

Sar-n SOCK 1 1 #统计socket连接信息

#totsck The total number of sockets currently in use

#tcpsck The total number of sockets for TCP that are currently being used

#udpsck The total number of sockets that are currently being used by UDP

#rawsck Total number of skcket currently being used in raw

#if-frag The number of current IP shards

#tcp-TW number of connections in time-wait state in TCP sockets

####### #如果你使用FULL关键字, the equivalent of the aforementioned Dev, Edev and sock

Sar-n TCP 1 3 #TCP连接的统计

#active/s new active connection

#passive/s New passive connection

#iseg/S accepted segments

#oseg the/S output segment

1.10.5:sar-n Usage Summary

-N DEV: Network interface statistics.-n edev :  network interface error. -n IP : IP  datagram statistics. -n EIP : IP  error statistics. -n TCP : TCP  statistical information. -n etcp : TCP  error statistics. -n SOCK : socket used.   
9. Monitoring of equipment usage

For example, sampling every 10 seconds, sampling 3 consecutive times, reporting device usage, you need to type the following command:

# sar-d 10 3–p

The screen appears 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 0.00 0.00 0.00 0.00 0.00

17:46:04 SDA 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

17:46:04 vg_livedvd-lv_root 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

17:46:04 Vg_livedvd-lv_swap 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00

which

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-0

TPS: Number of times per second from physical disk I/O. Multiple logical requests are merged into one I/O disk request, and the size of one transfer is indeterminate.

RD_SEC/S: Number of Read sectors per second.

WR_SEC/S: Number of Write sectors per second.

Avgrq-sz: The average data size (sector) per 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 the CPU, the higher the ratio, the more saturated the description.

1. When the value of Avgqu-sz is low, the equipment utilization is higher.

2. When the value of%util is close to 1%, it indicates that the device bandwidth is already full.

To determine the system bottleneck, it is sometimes necessary to combine several SAR command options.

Suspected CPU bottlenecks, sar-u and sar-q can be used to view

Suspect memory bottlenecks and can be viewed with Sar-b, sar-r, sar-w, etc.

Suspected I/O bottlenecks and can be viewed with Sar-b, sar-u, sar-d, etc.

11: Common Command Summary, due to different versions and platforms, some commands may not or show inconsistent results:

Default monitoring:Sar5 5 //CpuAndIowaitStats status (1)Sar-B5 5 //IoTransfer rate(2)Sar-B5 5 // Page exchange rate(3)Sar-C5 5 // Rate of process creation(4)Sar-D5 5 // Active information for block devices(5)Sar-N DEV5 5 // Status information for network devices(6)Sar-N SOCK5 5 //SOCKThe Use situation(7)Sar-n All5 5 // All network status information(8)Sar-P All5 5 // eachCpuThe Usage status information andIowaitStats status (9)Sar-Q5 5 // The length of the queue (number of processes waiting to run) and the state of the payload(10)Sar-R5 5 // Memory andSwapUse of space(11)Sar-R5 5 // Memory statistics (allocation and release of memory pages, system per second asBUFFERUse memory pages, per secondCacheto the memory page)(12)Sar-U5 5 //CpuThe use of the situation andIowaitInformation (same as default monitoring)(13)Sar-V5 5 //Inode,File and other kernel tablesdThe status information(14)Sar-W5 5 // The number of context exchanges per second(15)Sar-W5 5 //SWAPExchange statistics (monitoring status is the same asIostatOfSi so)(16)Sar-X2906 5 5 //  shows the specified process ( 2906cpu occupancy, running in which cpu  (17< Span class= "pun" >)  SAR -y 5  5 // TTY  device activity status  (18  output to file (-of               /span>                

Linux SAR Command detailed

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.