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



  Free Tech Webinars  

Archives
Links
Referrers