iostat -xzN 5 | grep "^vg\|^Dev" produces output like:

Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
vg01-root         0.00     0.00    0.00    0.20     0.00     1.60     8.00     0.00    3.00   3.00   0.06
vg05-vz           0.00     0.00    0.00    0.60     0.00     4.80     8.00     0.01    9.00   9.00   0.54
vg03-vz           0.00     0.00  281.00  128.40  5625.60  1027.20    16.25    42.35  103.54   2.44  99.94
vg02-vz2a         0.00     0.00   28.20   11.40  1416.00   112.00    38.59     0.79   19.84   5.99  23.72
Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
vg05-vz           0.00     0.00    0.00    8.60     0.00  7876.80   915.91     0.48   55.70   3.40   2.92
vg03-vz           0.00     0.00  308.20   76.20 10376.00  4433.60    38.53    11.50   30.00   2.60 100.00
vg02-vz2a         0.00     0.00   27.80   24.80   604.80   198.40    15.27     0.49    9.39   4.89  25.72
Device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
vg05-vz           0.00     0.00    0.00    1.80     0.00   585.60   325.33     0.01    5.78   4.00   0.72
vg03-vz           0.00     0.00  323.20   49.00  9283.20   497.60    26.28     3.48    9.40   2.69  99.98
vg02-vz2a         0.00     0.00   40.20   55.80  2644.80   483.20    32.58     1.14   11.86   4.12  39.58

I'd like this to display like top i.e. clear screen and start from the top on each iteration. I'm thinking if there was a way to pipe this through sed/awk/perl/whatever and every time you get ^Dev push a tput clear.

But how?

有帮助吗?

解决方案

Have you considered iotop instead?

That said, it shouldn't be too hard to hurl some rough Perl.

#!/usr/bin/perl

# Adjust options to taste.
open(IOSTAT, "iostat -d 5 |") || die;

$| = 1;
while(<IOSTAT>) {
    if (/^Dev/) { system "clear"; print; }
    if (/^vg/) { print; }
}

其他提示

Following up on Jeffrey Hantin's response, here's a one-liner version:

S_COLORS=always iostat -hz 5 | perl -pe '/avg/ && system(q[clear])'

Just let watch do the work for you:

watch -n<interval> iostat`
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top