Linux sar命令

Linux sar命令:收集、报告或保存系统活动信息。

Linux sar命令 功能描述

使用sar命令可以收集、报告或保存系统活动信息。可以从多个方面对Linux系统的活动进行报告,比如文件的读写情况、系统调用的使用情况、磁盘I/O、CPU利用率、内存使用状况和进程活动有关的信息等。

Linux sar命令 语法

sar [选项] [时间间隔] [次数]
Bash

命令中各选项的含义如表所示。

sar命令选项含义

Linux sar命令 示例

显示所有报告的总和

[root@rhel ]# sar -A
Bash

每2秒钟采样一次,连续采样5次,监控CPU的使用情况

[root@rhel ]# sar -u 2 5
Linux 2.6.32-358.el6.x86_64(rhel)     20130819  _x86_64_       (1 CPU)
005118    CPU    %user    %nice  %system  %iowait   %steal    %idle
005120    all     0.00     0.00     2.01     0.00     0.00    97.99
005122    all     0.50     0.00     2.00     0.00     0.00    97.50
005124    all     0.00     0.00     1.51     0.00     0.00    98.49
005126    all     0.00     0.00     1.51     0.00     0.00    98.49
005128    all     0.00     0.00     1.52     0.00     0.00    98.48
平均时间:      all     0.10     0.00     1.71     0.00     0.00    98.19
Bash

每10秒钟采样一次,连续采样3次,监控inode、文件和其他内核表的状态

[root@rhel ]# sar -v 10 3
Linux 2.6.32-358.el6.x86_64(rhel)   20130819 _x86_64_   (1 CPU)
005504dentunusd  file-nr  inode-nr   pty-nr
005514    26212     5536    22846       4
005524    26212     5536    22846       4
005534    26212     5536    22846       4
平均时间:      26212     5536    22846       4
Bash

每10秒钟采样一次,连续采样3次,监控内存使用情况

[root@rhel ]# sar -r 10 3
Linux 2.6.32-358.el6.x86_64(rhel)     20130819  _x86_64_       (1 CPU)
005720kbmemfree kbmemused  %memused  kbbuffers  kbcached  kbcommit %commit
005730   311676   700872    69.22    27432   343632   642012    20.65
005740   311676   700872    69.22    27432   343632   642012    20.65
005750   311676   700872    69.22    27432   343632   642012    20.65
平均时间:   311676   700872    69.22    27432   343632   642012    20.65
Bash

每10秒钟采样一次,连续采样3次,监控内存分页

[root@rhel ]# sar -B 10 3
Linux 2.6.32-358.el6.x86_64(rhel)     20130819  _x86_64_       (1 CPU)
005857pgpgin/s pgpgout/s fault/s majflt/s pgfree/s pgscank/s pgscand/s pgsteal/s %vmeff
005907  0.41  1602.85  3.86  0.00  48.17  0.00   0.00    0.00     0.00
005917  0.00  8.01    5.01  0.00  35.84  0.00   0.00    0.00     0.00
005927  0.00  0.00    3.11  0.00  33.70  0.00   0.00    0.00     0.00
平均时间:     0.13  531.95  3.99  0.00  39.19  0.00  0.00  0.00  0.00
Bash

每10秒钟采样一次,连续采样3次,监控I/O和传送速率

[root@rhel ]# sar -b 10 3
Linux 2.6.32-358.el6.x86_64(rhel)     20130819  _x86_64_       (1 CPU)
005947      tps     rtps     wtps  bread/s  bwrtn/s
005957     0.00     0.00     0.00     0.00     0.00
010007     1.30     0.00     1.30     0.00    14.44
010017     0.00     0.00     0.00     0.00     0.00
平均时间:     0.43     0.00     0.43     0.00     4.82
Bash

每10秒钟采样一次,连续采样3次,监控进程队列长度和平均负载状态

[root@rhel ]# sar -q 10 3
Linux 2.6.32-358.el6.x86_64(rhel)     20130819  _x86_64_       (1 CPU)
010104  runq-sz  plist-sz  ldavg-1  ldavg-5  ldavg-15
010114       0      237     0.06     0.16     0.21
010124       0      237     0.05     0.15     0.21
010134       0      237     0.04     0.15     0.20
平均时间:       0      237     0.05     0.15     0.21
Bash

每10秒钟采样一次,连续采样3次,监控系统交换活动信息

[root@rhel ]# sar -W 10 3
Linux 2.6.32-358.el6.x86_64(rhel)     20130819  _x86_64_       (1 CPU)
010253  pswpin/s pswpout/s
010303     0.00     0.00
010313     0.00     0.00
010323     0.00     0.00
平均时间:     0.00     0.00
Bash

每10秒采样一次,连续采样3次,监控设备使用情况

[root@rhel ]# sar -dp 10 3
Linux 2.6.32-358.el6.x86_64(rhel)     20130819  _x86_64_       (1 CPU)
010437   DEV  tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz  await  svctm  %util
010447   sda  0.00  0.00    0.00    0.00   0.00     0.00   0.00    0.00
010447   scd0  0.00  0.00     0.00    0.00  0.00     0.00   0.00    0.00
010447  DEV  tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz  await  svctm  %util
010457  sda   0.30  0.00    2.41    8.00     0.00    0.67  0.33   0.01
010457  scd0  0.00  0.00    0.00    0.00     0.00    0.00  0.00   0.00
010457   DEV  tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz  await  svctm  %util
010507   sda   0.20  0.00    2.41    12.00    0.00     1.50  1.50   0.03
010507  scd0   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   0.17  0.00     1.60  9.60
0.00     1.00  0.80    0.01
平均时间:     scd0   0.00  0.00     0.00  0.00     0.00     0.00  0.00    0.00
Bash

查看网络接口信息

[root@rhel ]# sar -n DEV
Linux 2.6.32-358.el6.x86_64(rhel)     20130819  _x86_64_       (1 CPU)
004511      LINUX RESTART
005002   IFACE  rxpck/s  txpck/s  rxkB/s  txkB/s  rxcmp/s  txcmp/s  rxmcst/s
010001     lo    0.03    0.03    0.00    0.00   0.00   0.00     0.00
010001    eth0   0.20    0.19    0.02    0.02   0.00   0.00     0.00
011001     lo     0.01   0.01    0.00    0.00   0.00   0.00     0.00
011001    eth0    0.20   0.17    0.02    0.03   0.00   0.00     0.00
平均时间:    IFACE  rxpck/s  txpck/s   rxkB/s   txkB/s  rxcmp/s  txcmp/s  rxmcst/s
平均时间:       lo     0.02     0.02     0.00     0.00     0.00   0.00     0.00
平均时间:     eth0     0.20     0.18     0.02     0.02     0.00   0.00     0.00
Bash

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

登录

注册