[英]Script for monitoring disk i/o rates on Linux
I need a for monitoring ALL disk i/o rates on Linux using bash, awk, sed. 我需要使用bash,awk,sed来监控Linux上的所有磁盘i / o速率。 The problem is that it must return one row per time interval (so this one row should contain:
tps
, kB_read/s
, kB_wrtn/s
, kB_read
, kB_wrtn
, but summarized per all disks). 问题是它必须每个时间间隔返回一行(因此这一行应包含:
tps
, kB_read/s
, kB_wrtn/s
, kB_read
, kB_wrtn
,但是按所有磁盘汇总)。 Natural choice here is of course: 这里的自然选择当然是:
-d -k -p $interval $loops
To limit it to all disks I use: 要将其限制为我使用的所有磁盘:
-d -k -p `parted -l | grep Disk | cut -f1 -d: | cut -f2 -d' '`
Now the nice trick to summarize columns: 现在总结列的好方法:
-d -k -p `parted -l | grep Disk | cut -f1 -d: | cut -f2 -d' '` > /tmp/jPtafDiskIO.txt
echo `date +"%H:%M:%S"`,`awk 'FNR>2' /tmp/jPtafDiskIO.txt | awk 'BEGIN {FS=OFS=" "}NR == 1 { n1 = $2; n2 = $3; n3 = $4; n4 = $5; n5 = $6; next } { n1 += $2; n2 += $3; n3 += $4; n4 += $5; n5 += $6 } END { print n1","n2","n3","n4","n5 }'` >> diskIO.log
I am almost there, however this (running in the loop) makes being invoked each time from beginning, so I don't get the statistics from interval to interval, but always averages (so each invoke brings me pretty the same output). 我几乎在那里,但是这个(在循环中运行)使得每次从开始都被调用,所以我不从间隔到间隔获得统计数据,但总是平均值(因此每次调用都会给我带来相同的输出)。
I know it sounds complicated, but maybe somebody has an idea? 我知道这听起来很复杂,但也许有人有想法? Maybe totally different approach?
也许完全不同的方法? Thx.
谢谢。
EDIT: 编辑:
Sample input (/tmp/jPtafDiskIO.txt): 示例输入(/tmp/jPtafDiskIO.txt):
> Linux 2.6.18-194.el5 (hostname) 08/25/2012
>
> Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
> sda 0.00 0.00 0.00 35655 59
> sda2 0.00 0.00 0.00 67 272
> sda1 0.00 0.00 0.00 521 274
> sdb 52.53 0.56 569.40 20894989
> 21065384388 sdc 1.90 64.64 10.93
> 2391333384 404432217 sdd 0.00 0.00 0.04
> 17880 1343028
Output diskIO.log: 输出diskIO.log:
16:53:12,54.43,65.2,580.37,2412282496,21471160238
为什么不使用iotop
http://guichaz.free.fr/iotop/ ?
dstat
might be what you're looking for. dstat
可能就是你要找的东西。 It has a lot of things it can report on, with some common ones displayed by default. 它有许多可以报告的内容,默认显示一些常见的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.