Apache Webserver Diagnostics
December 7, 2010Couple Options / utilities can help with debugging transient problems:
o Curl
o Dtrace
Check the error_log when Apache misbehaves
$ kill -SIGSEGV `pgrep httpd | tail -1`
$ tail -100 error_log
Curl
· Versatile command line utility that can be used to debug web-based problems
· Curl contains several advanced options to print protocol headers and connection errors
· Invaluable utility for locating misbehaving servers and applications
$ curl -v –user-agent “CURL DEBUG (`date`)” -H “X-foo: yikes” http://daemons.net
DTrace
· Dynamic tracing facility introduced in Solaris
· Can dynamically instrument applications and the Solaris kernel down to the instruction level
· Utilizes 30k+ probes distributed throughout the Solaris kernel
· Designed to be used on production systems
· No overhead when probes aren’t enabled
Dtrace script organization
· Dtrace scripts contain one or more probes, an optional predicate, and an optional action to perform (the default action is trace()):
Provider:module:function:name
/ predicate /
{
action();
}
Dtrace example #1
· Viewing system calls by Apache process
$ dtrace -n ‘syscall:::entry
/execname == “httpd”/
{
@calls[probefunc] = count();
}’
Dtrace example #2
· Watching Logical Apache I/O operations syscall::write:entry
/ execname == “httpd” /
{
printf(“Apache wrote (%s) to fd %d (%sn”, probefunc, arg0,
fds[arg0].fi_pathname);
}
syscall::read:entry
/ execname == “httpd” /
{
printf(“Apache read (%s) from fd %d (%s)n”, probefunc, arg0,
fds[arg0].fi_pathname);
}
www.bestitdocuments.com