sysstat监控工具使用(包含pidstat,iostat,sar)

http://pagesperso-orange.fr/sebastien.godard/download.html下载sysstat
tar zxvf sysstat.tar.gz
./configure
make
make install

 


pidstat 2 5
//每隔2秒,显示5次,所有活动进程的CPU使用情况
pidstat -p 3132 2 5
//每隔2秒,显示5次,PID为3132的进程的CPU使用情况显示
pidstat -p 3132 2 5 -r
//每隔2秒,显示5次,PID为3132的进程的内存使用情况显示

 

 

iostat [ -c | -d ] [ -k ] [ -t ] [ -x [ device ] ] [ interval [ count ] ]
  各个选项及参数含义如下:
      -c:显示CPU的使用情况。
      -d:显示磁盘的使用情况。
      -k:每秒以k bytes为单位显示数据。
      -t:打印出统计信息开始执行的时间。
      -x device:指定要统计的磁盘设备名称,默认为所有的磁盘设备。
      interval:指定两次统计间隔的时间;
      count:按照“interval”指定的时间间隔统计的次数。

 iostat -d 5 2
Linux 2.6.32-5-amd64 (zw220-181)  2013年05月08日  _x86_64_ (4 CPU)

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
cciss/c0d0        3.19         3.23        64.03  161443014 3197338064

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
cciss/c0d0        0.20         0.00         0.80          0          4

 

 

 

 

sar 2 5
//每隔2秒,显示5次,CPU使用的情况
15时55分36秒     CPU     %user     %nice   %system   %iowait    %steal     %idle
15时55分38秒     all      0.00      0.00      0.25      0.00      0.00     99.75
15时55分40秒     all      0.37      0.00      0.37      0.00      0.00     99.25
15时55分42秒     all      0.37      0.00      0.62      0.00      0.00     99.00
15时55分44秒     all      0.50      0.00      0.25      0.75      0.00     98.51
15时55分46秒     all      0.00      0.00      0.00      0.00      0.00    100.00
平均时间:       all      0.25      0.00      0.30      0.15      0.00     99.30

参数说明:
CPU
 CPU编号
 
%user
 在用户模式中运行进程所花的时间
 
%nice
 运行正常进程所花的时间
 
%system
 在内核模式(系统)中运行进程所花的时间
 
%iowait
 没有进程在该CPU上执行时,处理器等待I/O完成的时间
 
%idle
 没有进程在该CPU上执行的时间
 

在多CPU Linux系统中,sar命令也可以为每个CPU分解该信息,如以下输出所示:

sar -u -P ALL 2 5
Linux 2.6.32-5-amd64 (zw220-181)  2013年05月08日  _x86_64_ (4 CPU)

15时58分10秒     CPU     %user     %nice   %system   %iowait    %steal     %idle
15时58分12秒     all      1.91      0.00      0.51      0.25      0.00     97.33
15时58分12秒       0      3.05      0.00      0.00      0.00      0.00     96.95
15时58分12秒       1      0.50      0.00      0.50      1.01      0.00     97.99
15时58分12秒       2      4.17      0.00      1.56      0.00      0.00     94.27
15时58分12秒       3      0.50      0.00      0.50      0.00      0.00     99.01

15时58分12秒     CPU     %user     %nice   %system   %iowait    %steal     %idle
15时58分14秒     all      0.25      0.00      0.12      1.23      0.00     98.40
15时58分14秒       0      0.00      0.00      0.00      3.98      0.00     96.02
15时58分14秒       1      0.00      0.00      0.00      0.00      0.00    100.00
15时58分14秒       2      0.96      0.00      0.00      1.44      0.00     97.60
15时58分14秒       3      0.00      0.00      0.50      0.00      0.00     99.50

15时58分14秒     CPU     %user     %nice   %system   %iowait    %steal     %idle
15时58分16秒     all      0.12      0.00      0.25      0.00      0.00     99.63
15时58分16秒       0      0.00      0.00      0.00      0.00      0.00    100.00
15时58分16秒       1      0.00      0.00      0.00      0.00      0.00    100.00
15时58分16秒       2      0.00      0.00      0.00      0.00      0.00    100.00
15时58分16秒       3      0.00      0.00      0.00      0.00      0.00    100.00

15时58分16秒     CPU     %user     %nice   %system   %iowait    %steal     %idle
15时58分18秒     all      0.12      0.00      0.37      0.00      0.00     99.50
15时58分18秒       0      0.50      0.00      0.50      0.00      0.00     99.00
15时58分18秒       1      0.00      0.00      0.00      0.00      0.00    100.00
15时58分18秒       2      0.00      0.00      1.49      0.00      0.00     98.51
15时58分18秒       3      0.00      0.00      0.50      0.00      0.00     99.50

15时58分18秒     CPU     %user     %nice   %system   %iowait    %steal     %idle
15时58分20秒     all      2.97      0.00      0.26      2.71      0.00     94.06
15时58分20秒       0      6.04      0.00      0.00      5.49      0.00     88.46
15时58分20秒       1      2.08      0.00      0.52      0.00      0.00     97.40
15时58分20秒       2      3.52      0.00      0.00      4.52      0.00     91.96
15时58分20秒       3      0.99      0.00      0.50      0.99      0.00     97.52

平均时间:       CPU     %user     %nice   %system   %iowait    %steal     %idle
平均时间:       all      1.05      0.00      0.30      0.83      0.00     97.82
平均时间:         0      1.83      0.00      0.10      1.83      0.00     96.23
平均时间:         1      0.50      0.00      0.20      0.20      0.00     99.09
平均时间:         2      1.69      0.00      0.60      1.20      0.00     96.51
平均时间:         3      0.30      0.00      0.40      0.20      0.00     99.11


sar是一个研究磁盘I/O的优秀工具。以下是sar磁盘I/O输出的一个示例
sar -d 5 2
Linux 2.6.32-5-amd64 (zw220-181)  2013年05月08日  _x86_64_ (4 CPU)

16时00分09秒       DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
16时00分14秒  dev104-0      0.80      0.00      9.60     12.00      0.01      8.00      6.00      0.48

16时00分14秒       DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
16时00分19秒  dev104-0     15.60      0.00   3326.40    213.23      1.37     87.64      2.26      3.52

平均时间:         DEV       tps  rd_sec/s  wr_sec/s  avgrq-sz  avgqu-sz     await     svctm     %util
平均时间:    dev104-0      8.20      0.00   1668.00    203.41      0.69     83.76      2.44      2.00

第一行-d显示磁盘I/O信息,5 2选项是间隔和迭代,就像sar数据收集器那样
字    段
 说    明
 
DEV
 磁盘设备
 
tps
 每秒传输数(或者每秒IO数)
 
rd_sec/s
 每秒512字节读取数
 
wr_sec/s
 每秒512字节写入数
 

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


sar -n DEV 5 3
Linux 2.6.32-5-amd64 (zw220-181)  2013年05月08日  _x86_64_ (4 CPU)

16时03分10秒     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
16时03分15秒        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
16时03分15秒      eth0     26.60      2.40      2.60      0.22      0.00      0.00      0.40
16时03分15秒      eth1     32.00     34.40      5.83     14.18      0.00      0.00      0.40

16时03分15秒     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
16时03分20秒        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
16时03分20秒      eth0     24.80      1.20      2.63      0.16      0.00      0.00      0.80
16时03分20秒      eth1     43.80     40.60     11.74      8.07      0.00      0.00      0.80

16时03分20秒     IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
16时03分25秒        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
16时03分25秒      eth0     22.00      1.20      2.37      0.17      0.00      0.00      1.20
16时03分25秒      eth1     41.20    116.80      4.35    153.33      0.00      0.00      1.20

平均时间:       IFACE   rxpck/s   txpck/s    rxkB/s    txkB/s   rxcmp/s   txcmp/s  rxmcst/s
平均时间:          lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00
平均时间:        eth0     24.47      1.60      2.53      0.18      0.00      0.00      0.80
平均时间:        eth1     39.00     63.93      7.31     58.53      0.00      0.00      0.80

IFACE
 LAN接口
 
rxpck/s
 每秒钟接收的数据包
 
txpck/s
 每秒钟发送的数据包
 
rxbyt/s
 每秒钟接收的字节数
 
txbyt/s
 每秒钟发送的字节数
 
rxcmp/s
 每秒钟接收的压缩数据包
 
txcmp/s
 每秒钟发送的压缩数据包
 
rxmcst/s
 每秒钟接收的多播数据包
 

sar -n EDEV 5 2
Linux 2.6.32-5-amd64 (zw220-181)  2013年05月08日  _x86_64_ (4 CPU)

16时05分38秒     IFACE   rxerr/s   txerr/s    coll/s  rxdrop/s  txdrop/s  txcarr/s  rxfram/s  rxfifo/s  txfifo/s
16时05分43秒        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
16时05分43秒      eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
16时05分43秒      eth1      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

16时05分43秒     IFACE   rxerr/s   txerr/s    coll/s  rxdrop/s  txdrop/s  txcarr/s  rxfram/s  rxfifo/s  txfifo/s
16时05分48秒        lo      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
16时05分48秒      eth0      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
16时05分48秒      eth1      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
平均时间:        eth1      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00

IFACE
 LAN接口
 
rxerr/s
 每秒钟接收的坏数据包
 
txerr/s
 每秒钟发送的坏数据包
 
coll/s
 每秒冲突数
 
rxdrop/s
 因为缓冲充满,每秒钟丢弃的已接收数据包数
 
txdrop/s
 因为缓冲充满,每秒钟丢弃的已发送数据包数
 
txcarr/s
 发送数据包时,每秒载波错误数
 
rxfram/s
 每秒接收数据包的帧对齐错误数
 
rxfifo/s
 接收的数据包每秒FIFO过速的错误数
 
txfifo/s
 发送的数据包每秒FIFO过速的错误数
 
sar -n SOCK 5 2
Linux 2.6.32-5-amd64 (zw220-181)  2013年05月08日  _x86_64_ (4 CPU)

16时06分43秒    totsck    tcpsck    udpsck    rawsck   ip-frag    tcp-tw
16时06分48秒       144        10         4         0         0        15
16时06分53秒       150        12         4         0         0        11
平均时间:         147        11         4         0         0        13

字    段
 说    明
 
totsck
 使用的套接字总数量
 
tcpsck
 使用的TCP套接字数量
 
udpsck
 使用的UDP套接字数量
 
rawsck
 使用的raw套接字数量
 
ip-frag
 使用的IP段数量
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值