Angelo's Soapbox

Wednesday Jun 17, 2009

Diving into the Depths of Drupal with DTrace

I recently presented DTrace at Sun's CommunityONE event. My presentation was focused on observing drupal using DTrace. You can see a replay of the presentation here. You can get the presentation here as well.

If you are an AMP (Apache MySQL PHP) stack user on Solaris/OpenSolaris you can benefit from DTrace. Here is a D-Script that will print the load distribution on your system. Think of it as "AMP-top" if you may! This was tested on OpenSolaris 2009.06

#!/usr/sbin/dtrace -qs

BEGIN
{
	total=mysqlcnt=httpcnt=phpcnt=javacnt=ffxcnt=othercnt=0;
	printf("%10s %10s %10s %10s %10s %10s\n","% MYSQL","% APACHE","% FIREFOX","% PHP","% Java","% OTHER");
}

php*:::request-startup
{
	inphp[pid,tid]=1;
}

php*:::request-shutdown
{
	inphp[pid,tid]=0;
}

profile-1001
{
	total++;
	(execname=="mysqld")?mysqlcnt++:\
	     (execname=="httpd")?(inphp[pid,tid]==1?phpcnt++:httpcnt++):\
	     (execname=="java")?javacnt++:\
	     (execname=="firefox-bin")?ffxcnt++:othercnt++;
}

	

tick-30s
{
	printf("%10s %10s %10s %10s %10s %10s\n","% MYSQL","% APACHE","% FIREFOX","% PHP","% Java","% OTHER");
}

tick-2s
{
	printf("%10d %10d %10d %10d %10d %10d\n",mysqlcnt*100/total,\
              httpcnt*100/total,ffxcnt*100/total, phpcnt*100/total,\
              javacnt*100/total,othercnt*100/total);
	total=mysqlcnt=httpcnt=phpcnt=ffxcnt=javacnt=othercnt=0;

}

I will post other scripts soon. I plan to twitter these scripts as well. Follow me on twitter

Comments:

Hi Angelo,
Thanks for posting this. Your video is great and I think you're a good presenter.
I'm hoping that you can answer a question I have. I know that dtrace probes can print time and function names. Is it possible to print out programming language variable values using probes? I've been trying to figure this out but not having much success. With PHP's XDebug module for example I can see the values inside objects and classes. I'd love to show off this functionality to others if dtrace supports it. BTW it's a major barrier to me fully embracing OpenSolaris as a complete development platform, and I'd like to overcome it (and see variable values in Javascript etc). I hope you can help me out here.
Many thanks!
Warm regards,
ISO-8859-1

Posted by ISO-8859-1 on June 20, 2009 at 11:04 AM EST #

Post a Comment:
  • HTML Syntax: NOT allowed

Archives
Links
Referrers