Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Brendan Gregg
committed
Jun 27, 2013
1 parent
6c796bd
commit 643b55c
Showing
2 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/sbin/dtrace -s | ||
/* | ||
* httpd_latency.d Summarize HTTP server latency. | ||
* | ||
* This requires the httpd DTrace provider, which is available as mod_usdt | ||
* for Apache, and the translators. If they are in not in /usr/lib/dtrace, | ||
* you may need to invoke this with the actual location with -L, eg: | ||
* dtrace -L /opt/local/lib/dtrace -s httpdslower.d | ||
* | ||
* 26-Jun-2013 Brendan Gregg Created this. | ||
*/ | ||
|
||
#pragma D option quiet | ||
|
||
dtrace:::BEGIN | ||
{ | ||
trace("Tracing HTTP server latency... Hit Ctrl-C to end.\n"); | ||
} | ||
|
||
httpd*:::request-start | ||
{ | ||
self->ts = timestamp; | ||
} | ||
|
||
httpd*:::request-done | ||
/self->ts/ | ||
{ | ||
@["ns"] = quantize(timestamp - self->ts); | ||
self->ts = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/sbin/dtrace -s | ||
/* | ||
* httpdslower.d Show HTTP server requests slower than threshold. | ||
* | ||
* USAGE: httpdslower.d [min_ms] | ||
* eg, | ||
* httpdslower.d 10 # show requests slower than 10 ms | ||
* httpdslower.d # show all requests | ||
* | ||
* This requires the httpd DTrace provider, which is available as mod_usdt | ||
* for Apache, and the translators. If they are in not in /usr/lib/dtrace, | ||
* you may need to invoke this with the actual location with -L, eg: | ||
* dtrace -L /opt/local/lib/dtrace -s httpdslower.d | ||
* | ||
* 26-Jun-2013 Brendan Gregg Created this. | ||
*/ | ||
|
||
#pragma D option quiet | ||
#pragma D option defaultargs | ||
#pragma D option switchrate=10 | ||
|
||
dtrace:::BEGIN | ||
{ | ||
min_ns = $1 * 1000000; | ||
printf("Tracing HTTP server ops slower than %d ms\n", $1); | ||
printf("%-20s %-6s %6s %s\n", "TIME", "PID", "ms", "URL"); | ||
} | ||
|
||
node*:::http-server-request | ||
{ | ||
self->ts = timestamp; | ||
} | ||
|
||
node*:::http-server-response | ||
/self->ts && (this->delta = timestamp - self->ts) > min_ns/ | ||
{ | ||
printf("%-20Y %-6d %6d %s\n", walltimestamp, pid, | ||
this->delta / 1000000, | ||
(xlate <httpd_rqinfo_t *>((dthttpd_t *)arg0))->rq_uri); | ||
self->ts = 0; | ||
} |