]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - cddl/contrib/dtracetoolkit/Disk/hotspot.d
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / cddl / contrib / dtracetoolkit / Disk / hotspot.d
1 #!/usr/sbin/dtrace -s
2 /*
3  * hotspot.d - plot disk event by location, look for hotspots.
4  *             Written in DTrace (Solaris 10 3/05).
5  *
6  * This simple DTrace script determines if disk activity is occuring in
7  * the one place - a "hotspot". This helps us understand the system's usage
8  * of a disk, it does not imply that the existance or not of a hotspot is
9  * good or bad (often may be good, less seeking).
10  *
11  * $Id: hotspot.d 3 2007-08-01 10:50:08Z brendan $
12  *
13  * USAGE:       hotspot.d       # hit Ctrl-C to end
14  *
15  * FIELDS:
16  *              Disk            disk instance name
17  *              Major           driver major number
18  *              Minor           driver minor number
19  *              value           location, by megabyte
20  *              count           number of I/O operations
21  *
22  * COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg.
23  *
24  * CDDL HEADER START
25  *
26  *  The contents of this file are subject to the terms of the
27  *  Common Development and Distribution License, Version 1.0 only
28  *  (the "License").  You may not use this file except in compliance
29  *  with the License.
30  *
31  *  You can obtain a copy of the license at Docs/cddl1.txt
32  *  or http://www.opensolaris.org/os/licensing.
33  *  See the License for the specific language governing permissions
34  *  and limitations under the License.
35  *
36  * CDDL HEADER END
37  *
38  * 07-May-2005  Brendan Gregg   Created this.
39  * 20-Apr-2006     "      "     Last update.
40  */
41
42 #pragma D option quiet
43
44 inline int DISK_MB_MAX = 1000000;       /* max size of a single disk */
45 inline int REPORT_SCALE_MB = 1000;      /* output step size for report */
46
47 /*
48  * Print header
49  */
50 dtrace:::BEGIN
51 {
52         printf("Tracing... Hit Ctrl-C to end.\n");
53 }
54
55 /*
56  * Process disk event
57  */
58 io:::start
59 {
60         this->mb = args[0]->b_blkno / 2048;
61         @Block[args[1]->dev_statname, args[1]->dev_major, args[1]->dev_minor] =
62             lquantize(this->mb, 0, DISK_MB_MAX, REPORT_SCALE_MB);
63 }
64
65 /*
66  * Print final report
67  */
68 dtrace:::END
69 {
70         printa("Disk: %s   Major,Minor: %d,%d\n%@d\n", @Block);
71 }