您的位置:首页 > 其它

SAR系统性能检测工具

2011-08-23 15:35 330 查看
/**

* sar man手册简译, 欢迎大家补充、指正

* Author: cnscn

* Time  : 2006-10-17 09:10

*

*/

sar ---  收集、报告或保存系统活动信息 Collect, report, or save system activity information

Options:

  -A    列出保存的当天的所有活动的文件内容, 等同于-bBcdqrRuvwWy -I SUM -n FULL -P ALL

  -b    报告I/O和传送速率统计。这个参数仅用于2.5及以后内核。可显示以下字段

        tps        每秒从物理磁盘I/O的次数。多个逻辑请求会被合并为一个I/O磁盘请求。一次传输的大小是不确定的

         rtps      每秒的读请求数

         wtps      每秒的写请求数

         bread/s   每秒读磁盘的数据块数(in blocks  1 block = 512B, 2.4以后内核)

         bwrtn/s   每秒写磁盘的数据块数(in blocks  1 block = 512B, 2.4以后内核)

  -B     显示内核页统计。 可显示如下字段

         pgpgin/s

         pgpgout/s

         fault/s

         majflt/s

  -c     显示进程创建活动, 显示如下字段

         proc/s    每秒进程创建数

  -d m n  报告每个块设备的活动情况(2.4及以后内核)

         m 每m秒采样一次

         n 共采样n次

         sar -d 30 5

         Average:          DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util

                          dev8-0    2.39     16.37     35.99     21.88      0.00      0.85      0.66      0.16

         tps             显示指定设备的每秒I/O流量,多个逻辑请求可以合并为一个物理请求,流量为不确定大小

         rd_sec/s        从设备读取的扇区数,(1扇区=512B)

         wr_sec/s        写入设备的扇区数

         avgrq-sz        流出设备的扇区数

         avgqu-sz        流出设备的平均队列长度

         await           从设备流出的平均I/O请时间,包括请求在队列和服务时的时间

         svctm           平均I/O请求的服务时间

         %util           I/O请求的CPU时间百分比,当数字接近100%时,设备出现饱和

  -H

  -h

  -i interval    

选取尽可能接近interval所标识的数量的记录数 (Select data records at  seconds as close as

possible to the number specified by the interval parameter)

  -q    报告队列长度和平均负载,可列出下列字段

        runq-sz    执行中的队列长度(等待运行的进程数)

        plist-sz   进程列表中的进程数

        ldavg-1    最后一分钟的系统负载

        ldavg-5    最后5分钟的系统负载

        ldavg-15   最后15�种拥南低掣涸�

  -r    报告memory和swap使用统计,可列出如下字段

        kbmemfree  可用的内存数(kB)

        kbmemused  应用中的内存数,但不包括内核使用的内存(kB)

        %memused   内存的使用百分比

        kbcached   内核用于cache的内存数(kB)

        kbswpfree

        kbswpused

        %swpused

        kbswpcad   用于cache的swap内存数(kB)

  -R    报告内存活动,可列出如下字段

        frmpg/s    每秒空闲的内存页数,负值表示系统已经分配了的内存页数。注意:依据机器体系的不同,内存页的大小有4kB或8kB

        bufpg/s    每秒系统用于buffers的附加的内存页数。负值表示较少的页数用于系统buffers

        campg/s    每秒系统用于cached的附加的内存页数。负值表示较少的页数用于系统cached

  -t

  -u  列出cpu的使用情况,可列出下列字段

       %user      用户层

       %nice   用户层

       %system  系统层

      

%iowait  系统有外部磁盘I/O请求时的cpu(s)的空闲时间百分不(Percentage of %time that the CPU

or CPUs were idle during which the system had an outstanding disk I/O

request)

       %idle      系统没有外部磁盘I/O请求时的cpu(s)的空闲时间百分不(Percentage

of time that the CPU or CPUs were idle and the system did not have an

outstanding disk I/O request)

  -v   报告文件或其它内核表的inode的状态,可列出如下字段

       dentunusd   Number of unused cache entries in the directory cache.

       file-sz     已经使用了的文件句柄数 Number of used file handles

       inode-sz    Number of allocated disk quota entries.

       super-sz    内核已经分配了的超级块的句柄 Number of super block handlers allocated by the kernel

      

%super-sz   Percentage of allocated super block handlers with regard to

the maximum  number  of  super block handlers that Linux can allocate.

       dquot-sz    已经分配了的磁盘限额入口数 Number of allocated disk quota entries.

      

%dquot-sz   Percentage  of  allocated  disk  quota entries with regard

to the maximum number of cached disk quota entries that can be

allocated.

       rtsig-sz    队列中RT信号数 Number of queued RT signals.

       %rtsig-sz   Percentage of queued RT signals with regard to the maximum number of RT signals that can be queued.

  -V  列出版本号和用法

  -w  报告系统交换活动,列出如下字段

    cswch/s      系统每秒交换活动的次数 Total number of context switches per second

  -W 报告swapping活动信息,可列出如下字段

    pswpin/s     每秒系统带来的交换页数 Total number of swap pages the system brought in per second.

      pswpout/s    系统每秒带出、拿出的交换页数

  -y

  -n {DEV|EDEV|SOCK|FULL}

     报告网络活动统计

     DEV    指定列出所有网络设备的活动统计,可列出如下字段

            IFACE      网络接口卡设备名,如eth0

            rxpck/s    每秒收到的包数

            txpck/s    每秒传输的包数

            rxbyt/s    每秒收到的数据字节数

            txbyt/s    每秒传输的数据字节数

            rxcmp/s    每秒收到的压缩包数

            txcmp/s    每秒传输的压缩包数

            rxmcst/s   每秒收到的多播包数

     EDEV  指定列出所有网设备失败包的情况,可列出如下字段

           IFACE       网络接口卡设备名

           rxerr/s     每秒收到的总的失败包数

           txerr/s     每秒钟传输时的错误包数

           coll/s      每秒钟传输时的冲突包数

           rxdrop/s    每秒钟收到的包中由于Linux空间缺乏而丢弃的包数

           txdrop/s    每秒钟传输过程中由于Linux空间缺乏而丢弃的包数

           txcarr/s    每秒钟传输过程中的carrier-errors的数目

           rxfram/s    每秒钟收到的帧序列错误数

           rxfifo/s    每秒钟FIFO泛滥错误包数

           txfifo/s    每秒钟传输时FIFO泛滥的错误包数

     NFS   列出NFS客户端活动报告。 列出如下字段

           call/s      每秒成功的RPC请求数

           retrans/s   (由于server超时)每秒需重新传输的RPC请求数

           read/s      每秒成功的RPC的read请求数

           write/s     每秒成功的RPC的write请求数

           access/s    每秒成功的RPC的access请求数

           getatt/s    每秒成功的RPC的getattr请求数

     NFSD  列出NFS服务端活动报告。列出如下字段

           totsck      总的socktes数

           tcpsck      当前应用中的tcp sockets数

           udpsck      当前应用中的udp sockets数

           rawsck      当前应用中的RAW sockets数

           ip-frag     当前应用中的IP帧数

     FULL  等于指定-n选项的所有参数

  -x {pid|SELF|ALL}

  -X {pid|SELF|ALL}

  -I {irq|SUM|ALL|XALL}

     报告中断统计资料。

     irq    是中断号,指定多个-I irq参数可以观看到多个相关中断的情况

     SUM    指定显示每秒中接收到的所有中断情况

     ALL    指定显示所有中断的前16个中断情况

     XALL   指定显示所有中断包括潜在的APIC中断源

  -P {cpu|ALL}

     如果缺省-P则报告系统内的所有CPU的统计。如果参数为ALL,则报告每一个CPU和所有CPU的统计数据

     [root@localhost ~]# sar -P 0

     Linux 2.6.17-1.2187_FC5smp (localhost.localdomain)      2006年10月17日

     08时30分01秒       CPU     %user     %nice   %system   %iowait     %idle

     08时40分01秒         0      6.24      0.00      0.64      0.02     93.10

     [root@localhost ~]# sar -P 1

     Linux 2.6.17-1.2187_FC5smp (localhost.localdomain)      2006年10月17日

     08时30分01秒       CPU     %user     %nice   %system   %iowait     %idle

     08时40分01秒         1      7.66      0.00      0.60      0.03     91.71

  -o [filename]

     把报告输出到文件,否则显示到屏幕. 如果忽略filename,那么系统将把输出添加到/var/log/sa/sadd定时生成文件内(dd代表当前日期)

  -f [filename]

     从filename中提取预先保存在文件内的记录,并显示到屏幕上. 缺省filename则从/var/log/sa/sadd内提取

  -s [hh:mm:ss]

    

设置报告的开始时间, Set  the starting time of the data, causing the sar command

to extract records time-tagged at, or following, the time specified.

The default starting time is  08:00.   Hours  must  be  given  in

24-hour format. This option can be used only when data are read from a

file (option -f )

  -e [hh:mm:ss]

    

设置报告的结束时间, The default ending time is 18:00:00.This  option  can  be 

used  only when data are read from or written to a file (options -f or

-o )

     [interval]    选择记录的时间间隔(秒)

     [count]       

     sar 向标准输出列出选择的活动的累积数量。在多帐户系�衬冢ǜ嬉�ount(数量)和interval(时间间隔)参数,以指定秒数为时间间隔的指定的次数信息.

     如果interval参数指定为0,则sar显示系统启动以来的平均时间统计。

     如果count参数指定为0,则报告将不连续不断的进行。

     如果不指定参数,则仅显示CPU的活动,如果CPU使用率接近100% (user + nice + system), 则显示出CPU局限

     [root@localhost ~]# sar

     08时26分00秒       LINUX RESTART

     08时30分02秒       CPU     %user     %nice   %system   %iowait     %idle

     08时40分01秒       all      6.07      0.00     33.86      7.94     52.13

     08时50分01秒       all      2.26      0.00     28.32      0.77     68.66

     09时00分01秒       all      0.44      0.00     26.75      0.29     72.52

     09时10分01秒       all      0.97      0.00     26.87      0.05     72.12

     09时20分01秒       all      1.39      0.00     27.13      0.06     71.43

     Average:           all      2.22      0.00     28.58      1.82     67.38

    如果需要多个样本和报告,那么可以如下所做

    sar -o data.file interval count >/dev/null 2>&1 &

    [root@localhost ~]# sar -u 2 5 报告CPU的使用情况,每2秒钟一次共输出5行

    09时01分53秒       CPU     %user     %nice   %system   %iowait     %idle

    09时01分55秒       all     36.41      0.00      2.49     47.38     13.72

    09时01分57秒       all     38.40      0.00     18.20     36.91      6.48

    09时01分59秒       all     32.50      0.00      4.50     52.00     11.00

    09时02分01秒       all     44.00      0.00     48.50      7.25      0.25

    09时02分03秒       all     36.91      0.00     30.42     27.93      4.74

    Average:          all     37.64      0.00     20.82     34.30      7.24

    sar -I 14 -o int14.file 2 10

       每2秒报告一次14号中断的情况,共输出10行,并把结果保存到文件int14.file内

       Report  statistics  on  IRQ  14 for each 2 seconds. 10 lines are displayed.  Data are stored in a file called int14.file.

    sar -r -n DEV -f /var/log/sa/sa16

     列出每天保存在/var/log/sa/sa16内的内存、交换分区、网络活动情况

     Display memory, swap space and network statistics saved in daily data file ’sa16’.

    sar -A

      列出保存的当天的活动文件内容

      Display all the statistics saved in current daily data file



-------------------



sar 命令参数实例补充

2009-11-11 23:06

CPU监控

sar -u 3 100

11:26:36 AM       CPU     %user     %nice   %system   %iowait    %steal     %idle

11:26:37 AM       all      0.00      0.00      0.25      0.00      0.00     99.75

11:26:38 AM       all      0.00      0.00      0.00      0.50      0.00     99.50

11:26:39 AM       all      0.00      0.00      0.00      0.00      0.00    100.00

Average:          all      0.00      0.00      0.08      0.17      0.00     99.75

sar -u输出显示CPU信息。-u选项是sar的默认选项。该输出以百分比显示CPU的使用情况。表3-2解释该输出。

表3-2                                                      sar -u字段
字    段说    明
CPU
CPU编号
%user
在用户模式中运行进程所花的时间
%nice
运行正常进程所花的时间
%system
在内核模式(系统)中运行进程所花的时间
%iowait
没有进程在该CPU上执行时,处理器等待I/O完成的时间
%idle
没有进程在该CPU上执行的时间
磁盘I/O监控

第一行-d显示磁盘I/O信息,1 3选项是间隔和迭代,就像sar数据收集器那样。表3-3列出了字段和说明。

表3-3                                                       sar -d字段
字    段说    明
DEV
磁盘设备
tps
每秒传输数(或者每秒IO数)
rd_sec/s
每秒512字节读取数
wr_sec/s
每秒512字节写入数
tps:每秒到物理磁盘的传送数.1个传送就是1个I/O请求.多个逻辑请求可以被合并成1个I/O请求.1个传送的大小是不确定的.

rd_sec/s、wr_sec/s:512只是一个测量单位,不表示所有磁盘I/O均使用512字节块。DEV列 是dev#-#格式的磁盘设备,其中第一个#是设备主编号,第二个#是次编号或者连续编号。对于大于2.5的内核,sar使用次编号。例如,在sar -d输出中看到的dev3-0和dev3-1。它们对应于/dev/hda和/dev/hdal。请看/dev中的以下各项:

sar -d 1 3

11:30:05 AM       DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util

11:30:06 AM    dev8-0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:30:06 AM   dev8-16      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:30:06 AM       DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util

11:30:07 AM    dev8-0      2.00      0.00     24.00     12.00      0.01      7.00      7.00      1.40

11:30:07 AM   dev8-16      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:30:07 AM       DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util

11:30:08 AM    dev8-0      6.00      0.00     56.00      9.33      0.09     14.83      3.67      2.20

11:30:08 AM   dev8-16      6.00      0.00     96.00     16.00      0.05      8.50      5.17      3.10

Average:          DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util

Average:       dev8-0      2.67      0.00     26.67     10.00      0.03     12.88      4.50      1.20

Average:      dev8-16      2.00      0.00     32.00     16.00      0.02      8.50      5.17      1.03

网卡流量统计

sar提供四种不同的语法选项来显示网络信息。-n选项使用四个不同的开关:DEV、EDEV、SOCK和FULL。DEV显示网络接口信 息,EDEV显示关于网络错误的统计数据,SOCK显示套接字信息,FULL显示所有三个开关。它们可以单独或者一起使用。表3-4显示通过-n DEV选项报告的字段。

表3-4                                                  sar -n DEV字段
字    段说   明
IFACE
LAN接口
rxpck/s
每秒钟接收的数据包
txpck/s
每秒钟发送的数据包
rxbyt/s
每秒钟接收的字节数
txbyt/s
每秒钟发送的字节数
rxcmp/s
每秒钟接收的压缩数据包
txcmp/s
每秒钟发送的压缩数据包
rxmcst/s
每秒钟接收的多播数据包
以下是使用-n DEV选项的sar输出:

sar -n DEV 1 3

11:31:24 AM     IFACE   rxpck/s   txpck/s   rxbyt/s   txbyt/s   rxcmp/s   txcmp/s  rxmcst/s

11:31:25 AM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:31:25 AM      eth0     10.00      6.00    870.00    564.00      0.00      0.00      0.00

11:31:25 AM      eth1      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:31:25 AM      sit0      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:31:25 AM     IFACE   rxpck/s   txpck/s   rxbyt/s   txbyt/s   rxcmp/s   txcmp/s  rxmcst/s

11:31:26 AM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:31:26 AM      eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:31:26 AM      eth1      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:31:26 AM      sit0      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:31:26 AM     IFACE   rxpck/s   txpck/s   rxbyt/s   txbyt/s   rxcmp/s   txcmp/s  rxmcst/s

11:31:27 AM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:31:27 AM      eth0      3.96      6.93    320.79    815.84      0.00      0.00      0.00

11:31:27 AM      eth1      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:31:27 AM      sit0      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:        IFACE   rxpck/s   txpck/s   rxbyt/s   txbyt/s   rxcmp/s   txcmp/s  rxmcst/s

Average:           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:         eth0      4.65      4.32    396.68    461.13      0.00      0.00      0.00

Average:         eth1      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:         sit0      0.00      0.00      0.00      0.00      0.00      0.00      0.00
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息