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 * 18-Feb-2006, ver 0.71
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 */
41
42#pragma D option quiet
43
44/*
45 * Print header
46 */
47dtrace:::BEGIN
48{
49	printf("Tracing... Hit Ctrl-C to end.\n");
50}
51
52/*
53 * DNLC return
54 */
55fbt:genunix:dnlc_lookup:return
56{
57	this->code = arg1 == 0 ? 0 : 1;
58	@Result[execname, pid] = lquantize(this->code, 0, 1, 1);
59}
60
61/*
62 * Print report
63 */
64dtrace:::END
65{
66	printa(" CMD: %-16s PID: %d\n%@d\n", @Result);
67}
68