Thursday, August 30, 2007

Geek post

This is a geek post so don't bother reading any further if your not a code monkey.

We are currently investigating why some software is running slow and are looking at disk IO as a possible problem. Unix can log all sorts of things but you are lucky if they are human readable. This lill' Perl script will grep through all the the io.out logs from iostat into a csv file that you can open in Excel to graph.
Edit the regular expression to get the time - in out case its stamped Eastern Standard Time - EST
Edit the regular expression to find the device you are interested in - in this case d80


--------------------------------
#!/usr/bin/perl

#-----
# Perl code to output io files as csv
# usage: $ perl io2csv.pl io.out.* > d80.csv
#
# This little script will turn unix i.o. logs into a csv script
# from whence you can graph them
#-----

print "r/s,w/s,kr/s,kw/s,wait,actv,wsvc_t,asvc_t,%w,%b,device,dateTime\n";
# go through input one line at a time
while(<>)
{
# put input into a variable
my($line) = $_;

# remove trailing and leading spaces
chomp($line);

# regexp to get the time
if ($line =~ /EST/)
{

# get the time part of the date time into a variable (split on white
# space and get 4th element)
@dateTime = split;
$dateTime = $dateTime[3];
}

# look for data lines that are related to the mount
if ($line =~ /d80/)
{

# make white space separated data into a comma separated string
$fields = join(",",split);

# write output plus date
print "$fields,$dateTime\n";
}
}

4 comments:

unique_stephen said...

memo to self: check out:
http://www.performancewiki.com/diskio-tuning.html
and:
http://perfcap.blogspot.com/2006/11/processing-vxstat-to-read-into-r.html

Anonymous said...

Ok. I read it, I gave it my best shot. but I got nuthin'.

Will definately stick to folding the kids' socks and packing the dishwasher but it was good of me to try eh?

Steph said...

That is so easy I can't believe you can't figure that out!!

I'd explain it all to you but I don't think you'd get it. ;)

unique_stephen said...

Thanks guys,
I put it here so that somebody else might find it should they happen to goggle the problem