xref: /netbsd-src/external/cddl/dtracetoolkit/dist/Kernel/dnlcps.d (revision c29d51755812ace2e87aeefdb06cb2b4dac7087a)
1 #!/usr/sbin/dtrace -s
2 /*
3  * dnlcps.d - DNLC stats by process.
4  *            Written in DTrace (Solaris 10 3/05).
5  *
6  * The DNLC is the Directory Name Lookup Cache. Filename lookups often
7  * return a hit from here, before needing to traverse the regular file
8  * system cache or go to disk.
9  *
10  * dnlcps.d prints DNLC statistics by process.
11  *
12  * $Id: dnlcps.d,v 1.1.1.1 2015/09/30 22:01:09 christos Exp $
13  *
14  * USAGE:	dnlcps.d        # wait several seconds, then hit Ctrl-C
15  *
16  * FIELDS:
17  *		PID             Process ID
18  *		CMD          	Command name
19  *		value        	0 == miss, 1 == hit
20  *		count        	number of occurrences
21  *
22  * COPYRIGHT: Copyright (c) 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  * 27-Mar-2004	Brendan Gregg	Created this.
39  * 14-Jun-2005	   "      "	Rewrote this a lot.
40  * 18-Feb-2006	   "      "	Last update.
41  */
42 
43 #pragma D option quiet
44 
45 /*
46  * Print header
47  */
48 dtrace:::BEGIN
49 {
50 	printf("Tracing... Hit Ctrl-C to end.\n");
51 }
52 
53 /*
54  * DNLC return
55  */
56 fbt:genunix:dnlc_lookup:return
57 {
58 	this->code = arg1 == 0 ? 0 : 1;
59 	@Result[execname, pid] = lquantize(this->code, 0, 1, 1);
60 }
61 
62 /*
63  * Print report
64  */
65 dtrace:::END
66 {
67 	printa(" CMD: %-16s PID: %d\n%@d\n", @Result);
68 }
69