P. 1
Fast Track to Open Solaris

Fast Track to Open Solaris

|Views: 62|Likes:
Published by Raghavan Mohan
Think Digit : Fast Track to Open Solaris
Think Digit : Fast Track to Open Solaris

More info:

Published by: Raghavan Mohan on Oct 12, 2010
Copyright:Traditional Copyright: All rights reserved

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF or read online from Scribd
See more
See less

09/20/2013

Quick Tip

You would need to install
the amp-dev package from the
Package Manager in OpenSolaris
2009.06 in order to execute these
applications. Also, you can download
these codes from the DTrace Quick
Start Guide Wiki at http://wikis.
sun.com/display/DTrace/
DTrace+Quick+Start+Guide

71

FAST TRACK- FEBRUARY 2010

Dynamic Tracing with DTrace5

Consider the database MySQL, for example.
MySQL is open source, and you can easily
discover that the name of the function that
is called when a particular SQL statement
is executed is dispatch_command(). You can
also easily determine that the SQL statement
is passed as a string in the third argument.
With only this knowledge you can write the
following very simple D script to print out the
SQL that are executed in a live running instance of

MySQL.

#!/usr/sbin/dtrace -qs
#pragma D option strsize=1024
pid$1::*dispatch_command*:entry
{

printf("%d::%s\

n",tid,copyinstr(arg2));
}

The option strsize is used to increase the size
of strings in D to handle longer SQL statements.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->