Listing 6: Perl script
#!/usr/local/bin/perl
# disk_io_rpt.pl script to extract disks busy or high svc_time
$month = $ARGV[0];
$disk = $ARGV[1];
chomp($curmon=`date +%m`);
if (${month} eq ${curmon}) {
open (IN, "/stats/disk/io/d$month.log") or die "couldnt open the \ d$month.log: $!\n"; }
else { open (IN, "zcat /stats/disk/io/d${month}.log.Z|") or die \ "couldnt zcat the d$month.log.Z: $!\n"; }
while(<IN>){
$date = $_ if !/^ /;
print $date,
" r/s w/s kr/s kw/s wait actv wsvc_t asvc_t %w %b device\n",
# uncomment the following line for busy disks
# $_ if (split /\s+/)[10] > 20 && /$disk/;}
# uncomment this line to track high svc_t
# $_ if (split /\s+/)[8]
> 50 && /$disk/;}
close IN;
#_END_
|