sar/iostat/vmstat
上一篇 /
下一篇 2011-01-13 14:50:52
/ 个人分类:记录
安装过程见http://www.51testing.com/?uid-188107-action-viewspace-itemid-225762
sar:既能收集系统CPU、硬盘网络设备等动态数据,更能查看二进制数据文件等。
用法:
sar[参数选项]t [n] [-o file](t为采样间隔秒,必须有,n为采样次数,可选,默认值1)
参数说明:
-A显示所有历史数据,通过读取/var/log/sar目录下的所有文件,并把它们分门别类的显示出来;
-b通过设备的I/O中断读取设置的吞吐率;
-B报告内存或虚拟内存交换统计;
-c报告每秒创建的进程数;
-d报告物理块设备(存储设备)的写入、读取之类的信息,如果直观一点,可以和p参数共同使用,-dp
-f从一个二进制的数据文件中读取内容,比如sar -f filename;
-n分析网络设备状态的统计,后面可以接的参数有DEV、EDEV、NFS、NFSD、SOCK等。比如-n DEV
-o把统计信息以二进制格式写入一个文件,比如-o filename;
-u报告CPU利用率的参数;
-P报告每个处理器应用统计,用于多处理器机器,并且启用SMP内核才有效;
-p显示友好设备名字,以方便查看,也可以和-d和-n参数结合使用;
-r内存和交换区占用统计;
-t这个选项对从文件读取数据有用,如果没有这个参数,会以本地时间为标准读出;
-v报告inode,文件或其它内核表的资源占用信息;
-w报告系统交换活动的信息; 每少交换数据的个数;
-W报告系统交换活动吞吐信息;
-x用于监视进程的,在其后要指定进程的PID值;
-X用于监视进程的,但指定的应该是一个子进程ID;
CPU利用率:
[root@B1943 ~]#sar -u 1 5 Linux 2.6.18-53.el5 (B1943) 2011年01月13日 14时58分08秒 CPU %user %nice %system %iowait %steal %idle 14时58分09秒 all 0.00 0.00 0.00 0.00 0.00 100.00 14时58分10秒 all 0.50 0.00 0.00 0.00 0.00 99.50 14时58分11秒 all 0.00 0.00 0.00 0.00 0.00 100.00 14时58分12秒 all 0.00 0.00 0.00 0.00 0.00 100.00 14时58分13秒 all 0.00 0.00 0.00 0.00 0.00 100.00 Average: all 0.10 0.00 0.00 0.00 0.00 99.90 |
%usr cpu用户模式下时间(百分比)
%sys cpu系统模式下时间(百分比)
%nice表示CPU在用户层优先级的百分比,0表示正常;
%iowait cpu等待输入/输出完成(时间百分比)
%idle cpu空闲时间(百分比)
将动态信息写入文件中:
[root@localhost ~]#sar -u 1 5 > sar000.txt
[root@localhost ~]# cat sar000.txt
也可以输出到一个二进制的文件中,然后通过sar来查看;
[root@localhost ~]#sar -u 1 5 -o sar002
[root@localhost ~]# sar -f sar002
网络设备的吞吐情况:
[root@B1943 ~]#sar -n DEV 2 5 |grep eth0 15时04分12秒 eth0 6.97 1.00 0.54 0.07 0.00 0.00 0.00 15时04分14秒 eth0 7.50 1.50 0.71 0.16 0.00 0.00 0.00 15时04分16秒 eth0 6.00 1.50 0.43 0.16 0.00 0.00 0.00 15时04分18秒 eth0 7.50 1.50 0.58 0.16 0.00 0.00 0.00 15时04分20秒 eth0 7.50 1.50 0.50 0.16 0.00 0.00 0.00 Average: eth0 7.09 1.40 0.55 0.14 0.00 0.00 0.00 |
IFACE:设备名;
rxpck/s:每秒收到的包;
rxbyt/s:每秒收到的所有包的体积;
txbyt/s:每秒传输的所有包的体积;
rxcmp/s:每秒收到数据切割压缩的包总数;
txcmp/s:每秒传输的数据切割压缩的包的总数;
rxmcst/s:每秒收到的多点传送的包。
iostat:
用法:
iostat [ -c | -d ] [ -k ] [ -t ] [ -V ] [ -x [ device ] ] [ interval [ count ] ]> outputfile
其中,-c为汇报CPU的使用情况;-d为汇报磁盘的使用情况;-k表示每秒按kilobytes字节显示数据;-x可获得更多信息;interval指每次统计间隔的时间;count指按照这个时间间隔统计的次数。
[root@B1943 ~]# iostat -d -k -x Linux 2.6.18-53.el5 (B1943) 2011年01月13日 Device: rrqm/s wrqm/s r/s w/s rkB/s wkB/s avgrq-sz avgqu-sz await svctm %util sda 0.02 4.10 0.11 1.77 2.11 23.45 27.24 0.00 1.15 0.63 0.12 |
rrqm/s:每秒这个设备相关的读取请求有多少被Merge了(当系统调用需要读取数据的时候,VFS将请求发到各个FS,如果FS发现不同的读取请求读取的是相同Block的数据,FS会将这个请求合并Merge);
wrqm/s:每秒这个设备相关的写入请求有多少被Merge了。
rsec/s:每秒读取的扇区数;
wsec/:每秒写入的扇区数。
r/s:The number of read requests that were issued to the device per second;
w/s:The number of write requests that were issued to the device per second;
await:每一个IO请求的处理的平均时间(单位是微秒)。这里可以理解为IO的响应时间,一般地系统IO响应时间应该低于5ms,如果大于10ms就比较大了。
%util:在统计时间内所有处理IO时间,除以总共统计时间。例如,如果统计间隔1秒,该设备有0.8秒在处理IO,而0.2秒闲置,那么该设备的%util = 0.8/1 = 80%,
所以该参数暗示了设备的繁忙程度。一般地,如果该参数是100%表示设备已经接近满
负荷运行了(当然如果是多磁盘,即使%util是100%,因为磁盘的并发能力,所以磁
盘使用未必就到了瓶颈)。
[root@B1943 ~]# iostat -d -k Linux 2.6.18-53.el5 (B1943) 2011年01月13日 Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn sda 1.88 2.11 23.45 1122861 12458568 |
tps:该设备每秒的传输次数(Indicate the number of transfers per second that were issued to the device.)。“一次传输”意思是“一次I/O请求”。多个逻辑请求可能会被合并为“一次I/O请求”。“一次传输”请求的大小是未知的。
kB_read/s:每秒从设备(drive expressed)读取的数据量;
kB_wrtn/s:每秒向设备(drive expressed)写入的数据量;
kB_read:读取的总数据量;
kB_wrtn:写入的总数量数据量;这些单位都为Kilobytes。
iostat -cdx 1 >outfile
cat outfile
vmstat: 也可以输出到文件vmstat > outputfile
[root@B1943 ~]# vmstat procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ r b swpd free buff cache si so bi bo in cs us sy id wa st 0 0 0 4812568 199472 2125952 0 0 1 12 18 10 0 0 100 0 0 |
Procs
r: The number of processes waiting for run time.
b: The number of processes in uninterruptable sleep.
w: The number of processes swapped out but otherwise runnable.Memory
swpd: the amount of virtual memory used (kB).
free: the amount of idle memory (kB).
buff: the amount of memory used as buffers (kB).
Swap
si: Amount of memory swapped in from disk (kB/s).
so: Amount of memory swapped to disk (kB/s).
IO
bi: Blocks sent to a block device (blocks/s).
bo: Blocks received from a block device (blocks/s).
System
in: The number of interrupts per second, including the clock.
cs: The number of context switches per second.
CPU
These are percentages of total CPU time.
us: user time
sy: system time
id: idle time
收藏
举报
TAG:
iostat
sar
vmstat