Archive
Posts in DTrace
Viewing HTTP requests with DTrace Apache Top
I worked with my friend Clay last night to add POSIX signal handlers and additional fields to the DTrace apachetop Perl script: This version more closely resembles the awesome apachetop C program, but uses mod_dtrace instead of FAM and the Apache access_log to retrieve request data. Hope folks find this useful!
$ read more →Solaris 10 Apache DTrace module
I sent the following e-mail message to the DTrace mailing list today announcing the release of mod_dtrace version 0.2a: I have been working on an Apache DTrace module for the past few weeks, and just released version 0.2a. This module integrates Dtrace probes into Apache through the Apache hook framework. These probes can be used to observe and correlate a wide-variety of application and system behavior, which I have found useful for correlating network and virtual memory events with the requests served by Apache. I have written a few scripts to show some of the things I have been able to do with mod_dtrace, and have attached [1] some screenshots to this e-mail…
$ read more →Monitoring Apache memory allocation with DTrace
The Apache web server uses an abstraction concept called a pool to simplify memory management in the Apache web server. Memory can be allocated and assigned to a pool (there are several pools, with different lifetimes depending on how long the memory needs to stick around) through numerous routines, including the apr_palloc() routine. This routine contains the following prototype: apr_palloc() and the underlying allocator routines try to allocated memory in chunks, which ensures that brk() and company aren't called excessively. To get a better idea of how often apr_palloc() requested memory from chunks already allocated (the underlying allocator uses malloc() ), I created the following D script: Wow -- apr_palloc() was called 671 times for 3 GET requests, and malloc() was called 22 times to meet the demand for memory (this is another reason why it's a good idea to comment out unused modules)…
$ read more →Adding DTrace probes to Apache
In an attempt to learn how DTrace probes and Apache work, I called up my friend Clay last week, and we sat down to integrate some probes into Apache. After looking through the Apache source code and analyzing the available documentation on statically defined probes, we determined that adding probes would be simple, but getting apache to build would be a bit tedious (luckily Clay is an autoconf/libtool expert!!). After mucking with the build process for a few hours, Clay was able to tweak the APR (Apache Portable Runtime) Makefile.in, and we were able to integrate numerous DTrace probes into Apache. The first probe we added was in the apr_palloc() routine: This probe would be helpful for figuring out which pools were accessed, and for determing the number of bytes allocated to each pool: We can also use this probe to understand how frequently apr_palloc() gets called: After toying with the memory management layer (the really interesting stuff comes from the Apache allocator() routines -- but that is a BLOG entry in and of itself), we decided to add a probe to display incoming connections: Result: %d IP Address: %x SRC Port %d ",pid, (int)copyin(arg0,4), (int)copyin(arg1,4), (short int)copyin(arg2,4)); }'` This probe will display the httpd process id that accept()'ed the connection along with the SRC port ad IP address of the client…
$ read more →Grabbing Apache versions with DTrace
While messing around with DTrace, I devised a way to extract the Apache version with a simple DTrace script (this of course can be acquired with telnet and netcat, but it's fun doing things with DTrace): This example utilizes the pid provider to catch returns from ap_get_server_version, and prints the function return value as a string (the return value is a pointer to a global variable named server_version, which contains the token definition from the ServerTokens command). I looooooooooooooves me some DTrace!
$ read more →