DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone >

Decode Timestamp Bind Variables In Oracle 10046 Traces Files

Snippets Manager user avatar by
Snippets Manager
·
Mar. 25, 09 · · Code Snippet
Like (0)
Save
Tweet
1.57K Views

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.

Popular on DZone

  • Building a Login Screen With React and Bootstrap
  • A First Look at CSS When and Else Statements
  • Upsert in SQL: What Is an Upsert, and When Should You Use One?
  • Why Performance Projects Fail

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo