sar

To Enable SAR

1. /etc/default/sysstat

ENABLED="true"

2. /etc/init.d/sysstat start

2.14. The sar command complains with the following message: Requested activities not available in file [...]

This error message means that you are trying to extract non-existent activities from the data file. Usually sadc reads all the available activities from the system and stores them in the data file. However, to prevent data files from taking too much space on disk, some activities must be explicitly set on the command line to be read by sadc.

To tell sadc that an optional activity should be collected, use switch -S followed by the keyword corresponding to that activity

(see sadc(8) manual page).

/etc/default/sysstat

     -S { INT | DISK | SNMP | IPV6 | POWER | XDISK | ALL | XALL }
          Specify which  optional activities should  be collected
          by sadc.  Some activities  are optional to prevent data
          files  from   growing  too  large.    The  INT  keyword
          indicates  that  sadc should  collect  data for  system
          interrupts.   The  DISK  keyword  indicates  that  sadc
          should collect  data for  block devices.  The  SNMP and
          IPV6 keywords indicate  respectively that SNMP and IPv6
          statistics  should  be collected  by  sadc.  The  POWER
          keyword  indicates  that   sadc  should  collect  power
          management statistics.   The ALL keyword  is equivalent
          to specifying all the  keywords above and therefore all
          previous activities are collected.

          The XDISK keyword  is an extension to the  DISK one and
          indicates that partition statistics should be collected
          by  sadc in  addition to  disk statistics.  This option
          works  only with  kernels 2.6.25  and later.   The XALL
          keyword  is equivalent to  specifying all  the keywords
          above (including keyword  extensions) and therefore all
          possible activities are collected.

          Important  note:  The  activities  (including  optional
          ones) saved in an existing data file prevail over those
          selected with  option -S.  As  a consequence, appending
          data to an existing data  file will result in option -S
          being ignored.

As of this writing, optional activities are: interrupts, disks, SNMP, IPv6 and power management statistics.

IMPORTANT NOTES: 1) The list of activities that are saved in a file can no longer be modified once the file has been created. So it is important to use the proper options the first time sadc is called (whether via a crontab, a script like sa1(8) or even the script used to insert a RESTART message when the machine is rebooted). 2) With versions of sysstat older than 8.1.3, multiple switches (eg. -I and -d) had to be used with sadc to indicate which activities had to be collected. Other activities could not be saved into a file at all even if you specified the relevant options on the command line. Process statistics (-x and -X options in old sysstat versions) were such activities. 3) If the sar command complains with the error message: "Requested activities not available" (without mentioning "in file"), it means that you are trying to display activities that the kernel itself is unable to provide (please see question 2.18 below).

options

Common Options

sar -V: show version
justin@Justin:~$ sar -V
sysstat 版本 9.0.6.1
(C) Sebastien Godard (sysstat <at> orange.fr)
sar [interverl [count]]

interval: 采样频率

两种模式:

justin@Justin:~$ sar 3
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

14时16分55秒     CPU     %user     %nice   %system   %iowait    %steal     %idle
14时16分58秒     all      2.68      0.00      5.03      2.01      0.00     90.27
14时17分01秒     all      1.99      0.00      2.99      0.00      0.00     95.02
14时17分04秒     all      4.41      0.00      8.47      1.02      0.00     86.10
14时17分07秒     all      1.34      0.00      4.03      0.00      0.00     94.63
-o: output in binary
-f: extract from file
-h Display a short help message then exit.
-e [ hh:mm:ss ] / -s [ hh:mm:ss ]

Set the ending time of the report. The default ending time is 18:00:00. Hours must be given in 24-hour format. This option can be used when data are read from or written to a file (options -f or -o ).

查看各个时间段的日志

-c: comment included

汇总输出:

-A 等价于 -bBcdqrRuvwWy -I SUM -I XALL -n ALL -P ALL

Power

-m Power management
justin@Justin:~$ sar -m 3 2
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

15时23分28秒     CPU       MHz
15时23分31秒     all   2394.49
15时23分34秒     all   2394.49
平均时间:     all   2394.49

CPU

sar -u

查看系统cpu整体负载情况

justin@Justin:~$ sar -u 3
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

14时17分52秒     CPU     %user     %nice   %system   %iowait    %steal     %idle
14时17分55秒     all      1.68      0.00      4.03      0.00      0.00     94.30
14时17分58秒     all      1.99      0.00      2.66      0.00      0.00     95.35
14时18分01秒     all      2.33      0.00      5.00      0.00      0.00     92.67
14时18分04秒     all      5.35      0.00      7.02      0.00      0.00     87.63
Metrics:

若 %iowait 的值过高,表示硬盘存在I/O瓶颈 若 %idle 的值高但系统响应慢时,有可能是 CPU 等待分配内存,此时应加大内存容量 若 %idle 的值持续低于 10,则系统的 CPU 处理能力相对较低,表明系统中最需要解决的资源是 CPU。

sar -P
justin@Justin:~$ sar -P 0 3
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

14时20分44秒     CPU     %user     %nice   %system   %iowait    %steal     %idle
14时20分47秒       0      2.00      0.00      7.33      0.00      0.00     90.67
14时20分50秒       0      2.68      0.00      5.69      0.00      0.00     91.64

如果一个单线程应用,反应迟缓,但是系统整体的cpu使用率不高,可以针对单个CPU查看信息: -P 0

cpu的计数从零开始。

sar -q 运行队列
justin@Justin:~$ sar -q 3 2
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

14时47分59秒   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15
14时48分02秒         1       292      0.00      0.03      0.06
14时48分05秒         0       292      0.00      0.03      0.06
平均时间:         0       292      0.00      0.03      0.06

类似uptime:

justin@Justin:~$ uptime
 14:46:15 up  2:40,  3 users,  load average: 0.00, 0.05, 0.07
sar -w: context switch and process
justin@Justin:~$ sar -w 3 2
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

15时09分29秒    proc/s   cswch/s
15时09分32秒      0.00    933.78
15时09分35秒      0.00   1282.61
平均时间:      0.00   1108.19

Disk

sar -p -d
justin@Justin:~$ sar -p -d 3
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

justin@Justin:~$ sar -p -d 3 2
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

14时26分48秒       DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
14时26分51秒       sda      0.33      0.00      2.67      8.00      0.00      0.00      0.00      0.00
14时26分51秒       sdb      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
14时26分51秒       sdc      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
14时26分51秒       sdd      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
14时26分51秒       sde      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
14时26分51秒  dev254-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

14时26分51秒       DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
14时26分54秒       sda      1.68      0.00     21.48     12.80      0.00      0.00      0.00      0.00
14时26分54秒       sdb      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
14时26分54秒       sdc      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
14时26分54秒       sdd      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
14时26分54秒       sde      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
14时26分54秒  dev254-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

平均时间:       DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
平均时间:       sda      1.00      0.00     12.04     12.00      0.00      0.00      0.00      0.00
平均时间:       sdb      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
平均时间:       sdc      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
平均时间:       sdd      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
平均时间:       sde      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
平均时间:  dev254-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

avarage: 汇总时间

Memory

-r: Report memory utilization
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

14时31分56秒 kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit
14时31分59秒     58584    951544     94.20     52116    484240   1202524     60.43
14时32分02秒     58584    951544     94.20     52132    484232   1202676     60.43
平均时间:     58584    951544     94.20     52124    484236   1202600     60.43

%commit = kbcommit / (swap + memory)

-R: memory statistics
justin@Justin:~$ sar -R 3 2
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

14时40分10秒   frmpg/s   bufpg/s   campg/s
14时40分13秒    832.51      0.00     -0.35
14时40分16秒    -20.67      2.00     -2.00
平均时间:    393.48      1.03     -1.20
-W: swap
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

15时48分13秒  pswpin/s pswpout/s
15时48分16秒      0.00      0.00
15时48分19秒      0.00      0.00
平均时间:      0.00      0.00

pswpin/s Total number of swap pages the system brought in per second.

pswpout/s Total number of swap pages the system brought out per second.

pswpin/s 每秒系统换入的交换页面(swap page)数量 pswpout/s 每秒系统换出的交换页面(swap page)数量

-B: Page/swap
justin@Justin:~$ sar -B  3
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

15时40分38秒  pgpgin/s pgpgout/s   fault/s  majflt/s  pgfree/s pgscank/s pgscand/s pgsteal/s    %vmeff
15时40分41秒      0.00      7.97     30.23      0.00     67.44      0.00      0.00      0.00      0.00

pgpgin/s Total number of kilobytes the system paged in from disk per second. Note: With old kernels (2.2.x) this value is a number of blocks per second (and not kilobytes).

pgpgout/s Total number of kilobytes the system paged out to disk per second. Note: With old kernels (2.2.x) this value is a number of blocks per second (and not kilobytes).

fault/s Number of page faults (major + minor) made by the system per second. This is not a count of page faults that generate I/O, because some page faults can be resolved without I/O.

majflt/s Number of major faults the system has made per second, those which have required loading a memory page from disk.

pgfree/s Number of pages placed on the free list by the system per second.

pgscank/s Number of pages scanned by the kswapd daemon per second.

pgscand/s Number of pages scanned directly per second.

pgsteal/s Number of pages the system has reclaimed from cache (pagecache and swapcache) per second to satisfy its memory demands.

%vmeff Calculated as pgsteal / pgscan, this is a metric of the efficiency of page reclaim. If it is near 100% then almost every page coming off the tail of the inactive list is being reaped. If it gets too low (e.g. less than 30%) then the virtual memory is having some difficulty. This field is displayed as zero if no pages have been scanned during the interval of time.

IO

-b: block io
justin@Justin:~$ sar -b 3 2
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

14时42分58秒       tps      rtps      wtps   bread/s   bwrtn/s
14时43分01秒      0.34      0.00      0.34      0.00      5.39
14时43分04秒      0.67      0.00      0.67      0.00      8.03
平均时间:      0.50      0.00      0.50      0.00      6.71

输出项说明: tps 每秒钟物理设备的 I/O 传输总量 rtps 每秒钟从物理设备读入的数据总量 wtps 每秒钟向物理设备写入的数据总量 bread/s 每秒钟从物理设备读入的数据量,单位为 块/s bwrtn/s 每秒钟向物理设备写入的数据量,单位为 块/s

File System

-v: file system stat
justin@Justin:~$ sar -v 3 2
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

15时55分02秒 dentunusd   file-nr  inode-nr    pty-nr
15时55分05秒     17535      6304     10335         6
15时55分08秒     17535      6304     10335         6
平均时间:     17535      6304     10335         6

Interrupt

-I {irq|SUM|ALL|XALL} 输出指定中断的统计信息。
irq 指定中断号 SUM 指定输出每秒接收到的中断总数 ALL 指定输出前16个中断 XALL 指定输出全部的中断信息
justin@Justin:~$ sar -I ALL 3 2
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

16时01分24秒      INTR    intr/s
16时01分27秒         0      0.00
16时01分27秒         1      0.45
16时01分27秒         2      0.00
16时01分27秒         3      0.00
16时01分27秒         4      0.00
16时01分27秒         5      0.00
16时01分27秒         6      0.00
16时01分27秒         7      0.00
16时01分27秒         8      0.00
16时01分27秒         9      0.00
16时01分27秒        10      0.00
16时01分27秒        11      0.00
16时01分27秒        12      0.00
16时01分27秒        13      0.00
16时01分27秒        14      0.00
16时01分27秒        15     18.83

justin@Justin:~$ sar -I SUM 3 2
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

16时02分11秒      INTR    intr/s
16时02分14秒       sum    271.00
16时02分17秒       sum    302.72
平均时间:       sum    286.70

查看所有中断: cat /proc/interrupts

            CPU0
   0:         67   IO-APIC-edge      timer
   1:      29270   IO-APIC-edge      i8042
   3:          1   IO-APIC-edge
   4:          1   IO-APIC-edge
   6:          5   IO-APIC-edge      floppy
   7:          0   IO-APIC-edge      parport0
   8:          4   IO-APIC-edge      rtc0
   9:          0   IO-APIC-fasteoi   acpi
  12:      56164   IO-APIC-edge      i8042
  14:          0   IO-APIC-edge      ata_piix
  15:     145327   IO-APIC-edge      ata_piix
  17:      82939   IO-APIC-fasteoi   BusLogic BT-958
  18:     359583   IO-APIC-fasteoi   eth0
  19:        232   IO-APIC-fasteoi   uhci_hcd:usb1, Ensoniq AudioPCI
 NMI:          0   Non-maskable interrupts
 LOC:    2821563   Local timer interrupts
 SPU:          0   Spurious interrupts
 PMI:          0   Performance monitoring interrupts
 PND:          0   Performance pending work
 RES:          0   Rescheduling interrupts
 CAL:          0   Function call interrupts
 TLB:          0   TLB shootdowns
 TRM:          0   Thermal event interrupts
 THR:          0   Threshold APIC interrupts
 MCE:          0   Machine check exceptions
 MCP:         48   Machine check polls
 ERR:          0
 MIS:          0

Network

-n {DEV|EDEV|NFS|NFSD|SOCK|ALL} 分析输出网络设备状态统计信息。 DEV 报告网络设备的统计信息 EDEV 报告网络设备的错误统计信息 NFS 报告 NFS 客户端的活动统计信息 NFSD 报告 NFS 服务器的活动统计信息 SOCK 报告网络套接字(sockets)的使用统计信息 ALL 报告所有类型的网络活动统计信

-n {DEV|EDEV|NFS|NFSD|SOCK|ALL} 分析输出网络设备状态统计信息。 DEV 报告网络设备的统计信息 EDEV 报告网络设备的错误统计信息 NFS 报告 NFS 客户端的活动统计信息 NFSD 报告 NFS 服务器的活动统计信息 SOCK 报告网络套接字(sockets)的使用统计信息 ALL 报告所有类型的网络活动统计信息

详细见netstat

-n DEV
justin@Justin:~$ sar -n DEV 3 1
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

15时33分06秒     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
15时33分09秒        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
15时33分09秒      eth0     24.75      0.00      2.33      0.00      0.00      0.00      0.00
15时33分09秒      pan0      0.00      0.00      0.00      0.00      0.00      0.00      0.00

With the DEV keyword, statistics from the network devices are reported. The following values are displayed:

IFACE Name of the network interface for which statistics are reported.

rxpck/s Total number of packets received per second.

txpck/s Total number of packets transmitted per second.

rxkB/s Total number of kilobytes received per second.

txkB/s Total number of kilobytes transmitted per second.

rxcmp/s Number of compressed packets received per second (for cslip etc.).

txcmp/s Number of compressed packets transmitted per second.

rxmcst/s Number of multicast packets received per second.

-n EDEV
justin@Justin:~$ sar -n EDEV 3 2
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

16时12分19秒     IFACE   rxerr/s   txerr/s    coll/s  rxdrop/s  txdrop/s  txcarr/s  rxfram/s  rxfifo/s  txfifo/s
16时12分22秒        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
16时12分22秒      eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
16时12分22秒      pan0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

16时12分22秒     IFACE   rxerr/s   txerr/s    coll/s  rxdrop/s  txdrop/s  txcarr/s  rxfram/s  rxfifo/s  txfifo/s
16时12分25秒        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
16时12分25秒      eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
16时12分25秒      pan0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

平均时间:     IFACE   rxerr/s   txerr/s    coll/s  rxdrop/s  txdrop/s  txcarr/s  rxfram/s  rxfifo/s  txfifo/s
平均时间:        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
平均时间:      eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
平均时间:      pan0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

With the EDEV keyword, statistics on failures (errors) from the network devices are reported. The following values are displayed:

IFACE Name of the network interface for which statistics are reported.

rxerr/s Total number of bad packets received per second.

txerr/s Total number of errors that happened per second while transmitting packets.

coll/s Number of collisions that happened per second while transmitting packets.

rxdrop/s Number of received packets dropped per second because of a lack of space in linux buffers.

txdrop/s Number of transmitted packets dropped per second because of a lack of space in linux buffers.

txcarr/s Number of carrier-errors that happened per second while transmitting packets.

rxfram/s Number of frame alignment errors that happened per second on received packets.

rxfifo/s Number of FIFO overrun errors that happened per second on received packets.

txfifo/s Number of FIFO overrun errors that happened per second on transmitted packets.

-n ALL
justin@Justin:~$ sar -n ALL 3 2
Linux 2.6.32-justin-1 (Justin)  2012年03月07日  _i686_  (1 CPU)

16时12分49秒     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
16时12分52秒        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
16时12分52秒      eth0     23.41      0.00      2.20      0.00      0.00      0.00      0.00
16时12分52秒      pan0      0.00      0.00      0.00      0.00      0.00      0.00      0.00

16时12分49秒     IFACE   rxerr/s   txerr/s    coll/s  rxdrop/s  txdrop/s  txcarr/s  rxfram/s  rxfifo/s  txfifo/s
16时12分52秒        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
16时12分52秒      eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
16时12分52秒      pan0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

16时12分49秒    call/s retrans/s    read/s   write/s  access/s  getatt/s
16时12分52秒      0.00      0.00      0.00      0.00      0.00      0.00

16时12分49秒   scall/s badcall/s  packet/s     udp/s     tcp/s     hit/s    miss/s   sread/s  swrite/s saccess/s sgetatt/s
16时12分52秒      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

16时12分49秒    totsck    tcpsck    udpsck    rawsck   ip-frag    tcp-tw
16时12分52秒       630        14        12         0         0         0

16时12分49秒    irec/s  fwddgm/s    idel/s     orq/s   asmrq/s   asmok/s  fragok/s fragcrt/s
16时12分52秒     18.73      0.00     18.73      0.00      0.00      0.00      0.00      0.00

16时12分49秒 ihdrerr/s iadrerr/s iukwnpr/s   idisc/s   odisc/s   onort/s    asmf/s   fragf/s
16时12分52秒      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

16时12分49秒    imsg/s    omsg/s    iech/s   iechr/s    oech/s   oechr/s     itm/s    itmr/s     otm/s    otmr/s  iadrmk/s iadrmkr/s  oadrmk/s oadrmkr/s
16时12分52秒      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

16时12分49秒    ierr/s    oerr/s idstunr/s odstunr/s   itmex/s   otmex/s iparmpb/s oparmpb/s   isrcq/s   osrcq/s  iredir/s  oredir/s
16时12分52秒      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

16时12分49秒  active/s passive/s    iseg/s    oseg/s
16时12分52秒      0.00      0.00      0.00      0.00

16时12分49秒  atmptf/s  estres/s retrans/s isegerr/s   orsts/s
16时12分52秒      0.00      0.00      0.00      0.00      0.00

16时12分49秒    idgm/s    odgm/s  noport/s idgmerr/s
16时12分52秒     17.39      0.00      0.00      0.00

16时12分49秒   tcp6sck   udp6sck   raw6sck  ip6-frag
16时12分52秒         7         2         0         0

16时12分49秒   irec6/s fwddgm6/s   idel6/s    orq6/s  asmrq6/s  asmok6/s imcpck6/s omcpck6/s fragok6/s fragcr6/s
16时12分52秒      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

16时12分49秒 ihdrer6/s iadrer6/s iukwnp6/s  i2big6/s  idisc6/s  odisc6/s  inort6/s  onort6/s   asmf6/s  fragf6/s itrpck6/s
16时12分52秒      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

16时12分49秒   imsg6/s   omsg6/s   iech6/s  iechr6/s  oechr6/s  igmbq6/s  igmbr6/s  ogmbr6/s igmbrd6/s ogmbrd6/s irtsol6/s ortsol6/s  irtad6/s inbsol6/s onbsol6/s  inbad6/s  onbad6/s
16时12分52秒      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

16时12分49秒   ierr6/s idtunr6/s odtunr6/s  itmex6/s  otmex6/s iprmpb6/s oprmpb6/s iredir6/s oredir6/s ipck2b6/s opck2b6/s
16时12分52秒      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

16时12分49秒   idgm6/s   odgm6/s noport6/s idgmer6/s
16时12分52秒      0.00      0.00      0.00      0.00

TTY

[root@cnetos5 ~]# sar -y
Linux 2.6.18-53.el5 (cnetos5)   01/22/2008

12:00:01 AM       TTY   rcvin/s   xmtin/s framerr/s prtyerr/s     brk/s   ovrun/s
12:10:01 AM         0      0.00      0.00      0.00      0.00      0.00      0.00
12:10:01 AM         1      0.00      0.00      0.00      0.00      0.00      0.00
12:20:01 AM         0      0.00      0.00      0.00      0.00      0.00      0.00
12:20:01 AM         1      0.00      0.00      0.00      0.00      0.00      0.00
12:30:01 AM         0      0.00      0.00      0.00      0.00      0.00      0.00
12:30:01 AM         1      0.00      0.00      0.00      0.00      0.00      0.00
………………
Average:            0      0.00      0.00      0.00      0.00      0.00      0.00
Average:            1      0.00      0.00      0.00      0.00      0.00      0.00

输出项说明:
TTY     TTY 串行设备号
rcvin/s         每秒接收的中断数量
xmtin/s         每秒传送的中断数量
framerr/s       每秒发生的帧错误数(frame error)量
prtyerr/s       每秒发生的奇偶校验错误(parity error)数量
brk/s   每秒发生的暂停(break)数量
ovrun/s         每秒发生的溢出错误(overrun error)数量

Note

要判断一个系统瓶颈问题,有时需要几个 sar 命令选项结合起来使用,例如:

怀疑CPU存在瓶颈,可用 sar -u 和 sar -q 等来查看 怀疑内存存在瓶颈,可用 sar -B、sar -r 和 sar -W 等来查看 怀疑I/O存在瓶颈,可用 sar -b、sar -u 和 sar -d 等来查看

Wiki comments powered by Disqus