DTrace allows you to instrument any live running application in
production without the need of extra coding, application
recompile or even an application restart. All you need is that
the application is running on an OS that supports DTrace. Today
Solaris, OpenSolaris, OS X and FreeBSD are a few that have DTrace
built in.
For example here is a D-script that instrument MySQL to observe
the SQL statements that is being executed in production. Just a 3
line script like this can be extremely useful to observe a live
MySQL database
#!/usr/sbin/dtrace -qs
pid$1::*dispatch_command*:entry
{
printf("%d::%s\n",tid,copyinstr(arg2));
}
You need to pass the pid of the mysql process as the first
argument to this script.
Here is a sample output from the script. We are observing the SQL
statements that are executed to bring up the SugarCRM login
screen.
…
[Read more]