Decode Timestamp Bind Variables In Oracle 10046 Traces Files
Join the DZone community and get the full member experience.
Join For Free// Using code described there
// http://www.mydatabasesupport.com/forums/oracle-server/4889-perl-program-decode-memory-dump-timestamps-10046-trace-files.html
# Type of string search
# Bind#3
# oacdty=180 mxl=11(28) mxlc=00 mal=00 scl=09 pre=00
# oacflg=01 fl2=1000000 frm=00 csi=00 siz=0 off=196
# kxsbbbfp=0e3becd8 bln=11 avl=07 flg=01
# value=
#Dump of memory from 0x0E3BECD8 to 0x0E3BECDF
#E3BECD0 13016D78 00010109 [xm......]
#
# oacdty=180 mxl=11(28) mxlc=00 mal=00 scl=09 pre=00
# oacflg=01 fl2=1000000 frm=00 csi=00 siz=0 off=80
# kxsbbbfp=0ebc69bc bln=11 avl=07 flg=01
# value=
#Dump of memory from 0x0EBC69BC to 0x0EBC69C3
#EBC69B0 13016D78 [xm..]
#EBC69C0 00010101 [....]
#
sub oratimestamp {
my ($a,$b) = @_;
@months=("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
my($dy,$mo,$yr,$cy)=map{hex$_}$a=~/(..)(..)(..)(..)/;
my($fs0,$ss,$mi,$hr)=map{hex$_}$b=~/(..)(..)(..)(..)/;
$hr--;
$ampm = $hr > 11 ? "pm" : "am";
$hr = 12 if $hr == 0;
$hr -=12 if $hr > 12;
return sprintf("%02d %s %4d %02d:%02d:%02d%s",$dy,$months[$mo-1],(100*($cy-100)+($yr-100)),$hr,($mi-1),($ss-1),$ampm);
}
sub decode {
my $dump = shift;
my ($a,$b,$fill);
if ( $dump =~ /\S+\s+(\S{8})\s+(\S{8}).+(\n.*)/ ) {
($a,$b) = ($1,$2);
$fill=$3;
} else {
($a,$b) = $dump =~ /\S+\s+(\S{8}).+\n\S+\s+(\S{8})/; #
$fill="";
}
return "\"".&oratimestamp($a,$b)."\"".$fill;
}
open FH,"$ARGV[0]" or die "erreur d'ouverture de $ARGV[0]";
read FH,$file,1024*1024*100; # 100 Mb max
$file =~ s/(Bind#\d+\n oacdty=180.+\n.+\n.+\n value=)\nDump of memory from.+\n(.+\n.+)/$1.&decode($2)/ge;
print $file;
close FH
Opinions expressed by DZone contributors are their own.
Comments