cancel
Showing results for 
Search instead for 
Did you mean: 

Perl and statpack

SOLVED
Go to solution
Nicolas Dumeige
Esteemed Contributor

Perl and statpack

Hi all,

Just to get started : how do you get the stuff between two pattern for various file and process the output ?

I want to write a perl script wich take various Oracle statpack reports and produce a sum / average / top-bottom analysis of the waited events.

... or does anybody already have something alike ?

Thanks for help,

Nicolas
All different, all Unix
4 REPLIES
H.Merijn Brand (procura
Honored Contributor

Re: Perl and statpack

stuff between two patterns:

# perl -ne'/pat1/ .. /pat2/ and print'

or

# perl -ne'/pat1/ ... /pat2/ and print'

see 'man perlop' under 'range operators' for the difference between them.
I don't know about statpack, so your question is to vague for me in that respect.

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Jean-Luc Oudart
Honored Contributor

Re: Perl and statpack

Nicolas,

why don't you take the information at source i.e.in the perfstat schema as yuo would have all the relevant data ?

Regards,
Jean-Luc
fiat lux
Hein van den Heuvel
Honored Contributor
Solution

Re: Perl and statpack

Yeah.... use the source Luke! ask the data straight from the tables and have sql do the math for you.
Still, I appreciate that in several circumstances you just have the reports to work with.

Pike procura wrote, is it nice to use a 'range'. The thing to know about statspack is that the various regions are deleimited by a line starting with (in perl use anchor ^) a form-feed character (in perl special cased as \f) followed by a unique title.
So to just print the wait events you can use:

perl -ne '/^\fWai/.../^\fBac/ and print' sp.lst

In a procedure you probably will end up using something like:
while (<>) {
if (/^\fWa/.../^\fBac/) { # in the range?
s/,//g; #clean up large numbers
if (/(\d+)\s+(\d+)/) { #two numbers on the line?
$waits += $1;
$timeo += $2;
}
}
}
print "Total: $waits Waits, $timeo Timeouts\n";

hth,
Hein.




Nicolas Dumeige
Esteemed Contributor

Re: Perl and statpack

Thank all for you help,
especially Hein !

Cheers

Nicolas
All different, all Unix