| Simple, but painting with a very broad brush |
- Kill all httpd processes
- Restart httpd with, for example,
strace -f /usr/bin/httpd -d /Web
|
| A little more targetted
|
- Back up your apache configuration
- Reconfigure apache to only prefork one child
- Kill and restart apache
- strace that single child - be sure to follow forks with -f.
- Restore the original apache configuration
- Kill and restart apache
|
| Pretty targetted, if all you need is a single CGI script
|
- Assume your cgi script is named /Web/cgi-bin/foobar
- mv /Web/cgi-bin/foobar /Web/cgi-bin/foobar.orig
- Create a wrapper script named /Web/cgi-bin/foobar
that simply does:
|
| Targetting everything at a high level of detail, one file per apache process. You may need to do some
grep'ing and/or guessing to get to the right output file - IE, the one that's truly relevant to what you
need to scrutinze.
|
- mkdir /some/unique/directory
- cd /some/unique/directory
- for pid in $(ps -ef | grep '[/]usr/local/apache-2.0.55/bin/httpd' | awk ' { print $2 }'); do echo pid is $pid; truss -f -o "$pid.out" -p "$pid" & done
- Inspect the files in your newly created directory as needed
|
A quick note on terminology: open() is typically a system call.
fopen is probably never a system call - instead, it is a function in
the C library that wraps open(), making open() easier to use. Then
there's the system() function - like fopen(), it isn't really a
system call, despite its name. Rather, it is a C library function
that typically will wrap the fork() and exec*() system calls.
More specifically, a system call is the lowest-level interface
between an application program and a system's kernel - it's
basically an application saying "kernel, please do such and so for
me", and will normally entail a context switch from the
application to the kernel, and back. That's why a program that
does a buhzillion write() system calls with teensy (say, 1 byte)
values, is much slower than a program that writes data in 64K
blocks - the latter program will perform far fewer system calls,
and hence require far fewer (expensive, in terms of performance)
context switches.
Sort of similar things to possibly document in the future:
- ltrace/sotruss
- Dynamic Probes/Linux Trace Toolkit/DTrace


Back to Dan's tech tidbits