Skip to content

Commit d64a692

Browse files
committed
Import last shipped version (0.99) of the DTraceToolkit from Brendan Gregg.
1 parent e706a6b commit d64a692

File tree

1,006 files changed

+78391
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,006 files changed

+78391
-0
lines changed

Apps/Readme

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Apps - Specific Application based analysis
2+
3+
These are DTrace scripts that are written to analyse a particular
4+
application or applictaion layer protocol. For example, Apache or NFS
5+
scripts would appear here.

Apps/httpdstat.d

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#!/usr/sbin/dtrace -s
2+
/*
3+
* httpdstat.d - realtime httpd statistics. Uses DTrace.
4+
*
5+
* $Id: httpdstat.d 2 2007-08-01 10:01:43Z brendan $
6+
*
7+
* USAGE: httpdstat.d [interval [count]]
8+
*
9+
* interval seconds
10+
* count number of samples
11+
*
12+
* FIELDS:
13+
* TIME Time, string
14+
* NUM Number of connections
15+
* GET Number of "GET"s
16+
* POST Number of "POST"s
17+
* HEAD Number of "HEAD"s
18+
* TRACE Number of "TRACE"s
19+
*
20+
* All of the statistics are printed as a value per interval (not per second).
21+
*
22+
* NOTE: This version does not process subsequent operations on keepalives.
23+
*
24+
* IDEA: Ryan Matteson (who first wrote a solution to this).
25+
*
26+
* COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
27+
*
28+
* CDDL HEADER START
29+
*
30+
* The contents of this file are subject to the terms of the
31+
* Common Development and Distribution License, Version 1.0 only
32+
* (the "License"). You may not use this file except in compliance
33+
* with the License.
34+
*
35+
* You can obtain a copy of the license at Docs/cddl1.txt
36+
* or http://www.opensolaris.org/os/licensing.
37+
* See the License for the specific language governing permissions
38+
* and limitations under the License.
39+
*
40+
* CDDL HEADER END
41+
*
42+
* 20-Nov-2005 Brendan Gregg Created this.
43+
*/
44+
45+
#pragma D option quiet
46+
#pragma D option defaultargs
47+
48+
inline int SCREEN = 21;
49+
50+
/*
51+
* Program Start
52+
*/
53+
dtrace:::BEGIN
54+
{
55+
num = 0; get = 0; head = 0; post = 0; trac = 0;
56+
lines = SCREEN + 1;
57+
secs = $1 ? $1 : 1;
58+
counts = $2 ? $2 : -1;
59+
first = 1;
60+
}
61+
62+
profile:::tick-1sec
63+
{
64+
secs--;
65+
}
66+
67+
/*
68+
* Print Header
69+
*/
70+
dtrace:::BEGIN,
71+
profile:::tick-1sec
72+
/first || (secs == 0 && lines > SCREEN)/
73+
{
74+
printf("%-20s %6s %6s %5s %5s %5s\n", "TIME",
75+
"NUM", "GET", "POST", "HEAD", "TRACE");
76+
lines = 0;
77+
first = 0;
78+
}
79+
80+
/*
81+
* Track Accept Events
82+
*/
83+
syscall::accept:return
84+
/execname == "httpd"/
85+
{
86+
self->buf = 1;
87+
}
88+
89+
syscall::read:entry
90+
/self->buf/
91+
{
92+
self->buf = arg1;
93+
}
94+
95+
/*
96+
* Tally Data
97+
*/
98+
syscall::read:return
99+
/self->buf && arg0/
100+
{
101+
this->str = (char *)copyin(self->buf, arg0);
102+
this->str[4] = '\0';
103+
get += stringof(this->str) == "GET " ? 1 : 0;
104+
post += stringof(this->str) == "POST" ? 1 : 0;
105+
head += stringof(this->str) == "HEAD" ? 1 : 0;
106+
trac += stringof(this->str) == "TRAC" ? 1 : 0;
107+
num++;
108+
self->buf = 0;
109+
}
110+
111+
/*
112+
* Print Output
113+
*/
114+
profile:::tick-1sec
115+
/secs == 0/
116+
{
117+
printf("%-20Y %6d %6d %5d %5d %5d\n", walltimestamp,
118+
num, get, post, head, trac);
119+
num = 0; get = 0; head = 0; post = 0; trac = 0;
120+
secs = $1 ? $1 : 1;
121+
lines++;
122+
counts--;
123+
}
124+
125+
/*
126+
* End
127+
*/
128+
profile:::tick-1sec
129+
/counts == 0/
130+
{
131+
exit(0);
132+
}

Apps/nfswizard.d

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/usr/sbin/dtrace -s
2+
/*
3+
* nfswizard.d - nfs client activity wizard.
4+
* Written using DTrace (Solaris 10 3/05).
5+
*
6+
* This examines activity caused by NFS client processes on the same server
7+
* that you are running this script on. A detailed report is generated
8+
* to explain various details of NFS client activity, including response
9+
* times and file access.
10+
*
11+
* $Id: nfswizard.d 3 2007-08-01 10:50:08Z brendan $
12+
*
13+
* USAGE: nfswizard.d # hit Ctrl-C to end sample
14+
*
15+
* COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg.
16+
*
17+
* CDDL HEADER START
18+
*
19+
* The contents of this file are subject to the terms of the
20+
* Common Development and Distribution License, Version 1.0 only
21+
* (the "License"). You may not use this file except in compliance
22+
* with the License.
23+
*
24+
* You can obtain a copy of the license at Docs/cddl1.txt
25+
* or http://www.opensolaris.org/os/licensing.
26+
* See the License for the specific language governing permissions
27+
* and limitations under the License.
28+
*
29+
* CDDL HEADER END
30+
*
31+
* 02-Dec-2005 Brendan Gregg Created this.
32+
* 20-Apr-2006 " " Last update.
33+
*/
34+
35+
#pragma D option quiet
36+
37+
dtrace:::BEGIN
38+
{
39+
printf("Tracing... Hit Ctrl-C to end.\n");
40+
scriptstart = walltimestamp;
41+
timestart = timestamp;
42+
}
43+
44+
io:nfs::start
45+
{
46+
/* tally file sizes */
47+
@file[args[2]->fi_pathname] = sum(args[0]->b_bcount);
48+
49+
/* time response */
50+
start[args[0]->b_addr] = timestamp;
51+
52+
/* overall stats */
53+
@rbytes = sum(args[0]->b_flags & B_READ ? args[0]->b_bcount : 0);
54+
@wbytes = sum(args[0]->b_flags & B_READ ? 0 : args[0]->b_bcount);
55+
@events = count();
56+
}
57+
58+
io:nfs::done
59+
/start[args[0]->b_addr]/
60+
{
61+
/* calculate and save response time stats */
62+
this->elapsed = timestamp - start[args[0]->b_addr];
63+
@maxtime = max(this->elapsed);
64+
@avgtime = avg(this->elapsed);
65+
@qnztime = quantize(this->elapsed / 1000);
66+
}
67+
68+
dtrace:::END
69+
{
70+
/* print header */
71+
printf("NFS Client Wizard. %Y -> %Y\n\n", scriptstart, walltimestamp);
72+
73+
/* print read/write stats */
74+
printa("Read: %@d bytes ", @rbytes);
75+
normalize(@rbytes, 1000000);
76+
printa("(%@d Mb)\n", @rbytes);
77+
printa("Write: %@d bytes ", @wbytes);
78+
normalize(@wbytes, 1000000);
79+
printa("(%@d Mb)\n\n", @wbytes);
80+
81+
/* print throughput stats */
82+
denormalize(@rbytes);
83+
normalize(@rbytes, (timestamp - timestart) / 1000000);
84+
printa("Read: %@d Kb/sec\n", @rbytes);
85+
denormalize(@wbytes);
86+
normalize(@wbytes, (timestamp - timestart) / 1000000);
87+
printa("Write: %@d Kb/sec\n\n", @wbytes);
88+
89+
/* print time stats */
90+
printa("NFS I/O events: %@d\n", @events);
91+
normalize(@avgtime, 1000000);
92+
printa("Avg response time: %@d ms\n", @avgtime);
93+
normalize(@maxtime, 1000000);
94+
printa("Max response time: %@d ms\n\n", @maxtime);
95+
printa("Response times (us):%@d\n", @qnztime);
96+
97+
/* print file stats */
98+
printf("Top 25 files accessed (bytes):\n");
99+
printf(" %-64s %s\n", "PATHNAME", "BYTES");
100+
trunc(@file, 25);
101+
printa(" %-64s %@d\n", @file);
102+
}

0 commit comments

Comments
 (0)