1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
#!@@PERL@@ -w
# -*- perl -*-
=head1 NAME
iostat - Plugin for watching io-bound traffic (in KiloBytes) on disks
=head1 CONFIGURATION
No configuration
=head1 NOTES
=head2 DESCRIPTION
This version of iostat will report back the amount of I/O on a per
disk basis. It includes the vpaths in it's report. The I/O for a
vpath is the sum of the reads/writes of all the hdisks assosciated
with it. It uses /usr/bin/iostat.
=head2 RESTRICTIONS
Not restricted to a particular user.
You will have to enable disk accounting for this to work correctly.
You can do this through 'smitty chgsys -> Continuously maintain DISK
I/O history', change this to true, or you can do it at the command
line with this command "chdev -l sys0 -a iostat='true'".
Note: If you have virtual paths, typical when gigabit fiber cards are
installed and attached to an ESS (Shark) or some sort of large disk
array, this will combine the I/O for all hdisks associated with a
vpath so you get global statistics for a vpath. This is to avoid
having a list of hdisks that spans multiple pages.
=head1 AUTHOR
Unknown author
=head1 LICENSE
GPLv2
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=cut
use strict;
use POSIX;
my($arg) = shift;
if($arg && $arg eq "autoconf") {
if ( (-e "/usr/bin/iostat" && -X "/usr/bin/iostat") &&
(-e '/usr/sbin/lspv' && -X '/usr/sbin/lspv') ) {
print "yes\n";
exit 0;
} else {
print "no (Need /usr/bin/iostat and /usr/sbin/lspv)\n";
exit 0;
}
}
if($arg && $arg eq "config")
{
print "graph_title IOstat\n";
print "graph_args --base 1024 --logarithmic\n";
print "graph_vlabel KB / \${graph_period}\n";
print "graph_category disk\n";
my(@info) = getDiskIO("disk only");
my($line);
foreach $line (@info)
{
print "$line.label $line\n";
print "$line.type COUNTER\n";
print "$line.max 100000\n";
}
exit 0;
}
my(@info) = getDiskIO('');
my($line);
foreach $line (@info)
{print "$line";}
@info = processVPaths();
foreach $line (@info)
{print "$line";}
sub getDiskIO
{
my($diskOnly) = @_;
my($line,@lineArray,@diskArray,$writes,$reads,$diskLine);
if($diskOnly && $diskOnly eq 'disk only')
{
open DISKLIST, "/usr/sbin/lspv|egrep 'hdisk|vpath'|grep -v none|";
while($line = <DISKLIST>)
{
@lineArray = split(/ +/,$line);
push(@diskArray,"$lineArray[0]_read","$lineArray[0]_write");
}
}
else
{
open DISKLIST, "/usr/sbin/lspv|grep hdisk|grep -v none|";
while($line = <DISKLIST>)
{
@lineArray = split(/ +/,$line);
$diskLine = `/usr/bin/iostat|grep $lineArray[0]`;
@lineArray = split(/ +/,$diskLine);
$writes = $lineArray[5];
chomp($writes);
$reads = $lineArray[4];
chomp($reads);
push(@diskArray,"$lineArray[0]_read.value $reads\n","$lineArray[0]_write.value $writes\n");
}
}
return @diskArray
}
sub processVPaths
{
open DISKLIST, "/usr/sbin/lspv|grep vpath|";
my($line,$hdiskLine,@diskArray,$reads,$writes);
while($line = <DISKLIST>)
{
my(@vpathArr) = split(/ +/,$line);
my($vpathNum) = substr($vpathArr[0],index($vpathArr[0],"h")+1);
open VPATHINFO, "/usr/bin/datapath query device $vpathNum|grep hdisk|";
$reads = 0;
$writes = 0;
while($hdiskLine = <VPATHINFO>)
{
my(@hdiskInfo) = split(/ +/,$hdiskLine);
my($hdisk) = substr($hdiskInfo[2],index($hdiskInfo[2],"/")+1);
my($diskLine) = `/usr/bin/iostat|grep $hdisk`;
my(@lineArray) = split(/ +/,$diskLine);
$reads += $lineArray[4];
$writes += $lineArray[5];
}
push(@diskArray,$vpathArr[0]."_read.value $reads\n",$vpathArr[0]."_write.value $writes\n");
}
return @diskArray;
}
sub printArray
{
my($array,$spacer,$useNums,@labels) = @_;
my($item,);
my($count) = 0;
foreach $item (@{$array})
{
if($useNums == 1)
{print $count.substr($spacer,0,length($spacer)-length($count)).$item."\n";}
else
{print $labels[$count].substr($spacer,0,length($spacer)-length($labels[$count])).$item."\n";}
$count++;
}
}
|