Linux系统管理工具之sar

sar是后台进程sadc的前端显示工具,安装名为"sysstat"的包后,sadc就会自动从内核搜集报告并保存。
html


sar -u 查看CPU使用率
前端


[root@localhost bss]# sar -ulinux

Linux 2.6.32-573.el6.i686 (localhost.localdomain)       11/06/2015      _i686_  (1 CPU)shell


11:40:01 AM     CPU     %user     %nice   %system   %iowait    %steal     %idle缓存

11:50:01 AM     all      0.03      0.00      0.10      0.09      0.00     99.79网络

12:00:01 PM     all      0.03      0.00      0.16      0.12      0.00     99.69dom

Average:        all      0.03      0.00      0.09      0.08      0.00     99.80
ide


%user : 用户模式下消耗的CPU时间的比例;工具

%nice:经过nice改变了进程调度优先级的进程,在用户模式下消耗的CPU时间的比例;spa

%system:系统模式下消耗的CPU时间的比例;

%iowait:CPU等待磁盘I/O而致使空闲状态消耗时间的比例;

%steal:利用Xen等操做系统虚拟化技术时,等待其余虚拟CPU计算占用的时间比例;

%idle:CPU没有等待磁盘I/O等的空闲状态消耗的时间比例;

这里

若是 %iowait 的值太高,表示硬盘存在I/O瓶颈 

若是 %idle 的值高但系统响应慢时,有多是 CPU 等待分配内存,此时应加大内存容量

若是 %idle 的值持续低于 10,则系统的 CPU 处理能力相对较低,代表系统中最须要解决的资源是 CPU。


sar -q 查看平均负荷


[root@localhost bss]# sar -q

Linux 2.6.32-573.el6.i686 (localhost.localdomain)       11/06/2015     _i686_   (1 CPU)


11:40:01 AM   runq-sz  plist-sz   ldavg-1   ldavg-5  ldavg-15

11:50:01 AM         0       130      0.00      0.00      0.00

12:00:01 PM         0       130      0.04      0.01      0.00

Average:            0       130      0.00      0.00      0.00


runq-sz:   运行队列的长度(等待运行的进程数)                                      
plist-sz:   进程列表中进程(processes)和线程(threads)的数量                     
ldavg-1:   最后1分钟的系统平均负载(System load average)                          
ldavg-5:   过去5分钟的系统平均负载                                                 
ldavg-15: 过去15分钟的系统平均负载


sar -r 查看内存使用状况


[root@localhost bss]# sar -r

Linux 2.6.32-573.el6.i686 (localhost.localdomain)       11/06/2015      _i686_  (1 CPU)


11:40:01 AM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit

11:50:01 AM     86072    424652     83.15     16116    171184    277192     17.78

12:00:01 PM     85948    424776     83.17     16364    171188    277192     17.78

Average:        84048    426676     83.54     17651    171528    277022     17.77


kbmemfree:空闲物理内存量;

kbmemused:使用中的物理内存量;

%memused:物理内存量使用率;

kbbuffers:内核中做为缓冲区使用的物理内存容量;

kbcacheed:内核中做为缓存使用的物理内存容量;

kbswpfree:交换区的空闲容量;

kbswpused:使用中的交换区容量;


sar -w 查看页面交换发生情况


[root@localhost bss]# sar -w

Linux 2.6.32-573.el6.i686 (localhost.localdomain)       11/06/2015      _i686_  (1 CPU)


11:40:01 AM    proc/s   cswch/s

11:50:01 AM      0.01    114.81

12:00:01 PM      0.01    115.76

Average:         0.02    113.87


sar -b 查看I/O和传送速率的统计信息


[root@localhost bss]# sar -b

Linux 2.6.32-573.el6.i686 (localhost.localdomain)       11/06/2015      _i686_  (1 CPU)


11:40:01 AM       tps      rtps      wtps   bread/s   bwrtn/s

11:50:01 AM      0.62      0.00      0.62      0.00      5.52

12:00:01 PM      0.61      0.00      0.61      0.00      5.29

Average:         0.63      0.01      0.61      0.48      5.40


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


sar -n DEV 输出网络设备状态的统计信息(网卡流量)


[root@localhost bss]# sar -n DEV

Linux 2.6.32-573.el6.i686 (localhost.localdomain)       11/06/2015      _i686_  (1 CPU)


11:40:01 AM     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s

11:50:01 AM        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

11:50:01 AM      eth0      2.43      2.02      0.19      1.96      0.00      0.00      0.02

Average:           lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00

Average:         eth0      1.74      1.23      0.14      1.15      0.00      0.00      0.02


rxpck/s:每秒钟接收的数据包

txpck/s:每秒钟发送的数据包
rxbyt/s:每秒钟接收的字节数
txbyt/s:每秒钟发送的字节数

rxcmp/s:每秒钟接收的压缩数据包
txcmp/s:每秒钟发送的压缩数据包
rxmcst/s:每秒钟接收的多播数据包


默认状况下是对过去时间段进行数据统计,通常从最近的0:00开始显示。若是想继续查看一天前的报告,能够用-f选项指定保存在/var/log/sa目录下的日志文件。


转自:http://www.cnblogs.com/xiekeli/archive/2012/04/29/2476197.html

      http://itlab.idcquan.com/linux/set/924513.html

相关文章
相关标签/搜索