1#!/usr/sbin/dtrace -Cs
2/*
3 * kstat_types.d - Trace kstat reads with type info.
4 *                 Written using DTrace (Solaris 10 3/05)
5 *
6 * kstat is the Kernel Statistics framework, which is used by tools
7 * such as vmstat, iostat, mpstat and sar. Try running vmstat while
8 * kstat_types.d is tracing - you should see details of the kstat
9 * reads performed.
10 *
11 * 11-Feb-2006, ver 0.65
12 *
13 * USAGE:	kstat_types.d	(early release, check for updates)
14 *
15 * FIELDS:
16 *		CMD		command name
17 *		CLASS		kstat class (ks_class)
18 *		TYPE		kstat type as a string (ks_type)
19 *		MOD:INS:NAME	kstat module:instance:name
20 *
21 * COPYRIGHT: Copyright (c) 2006 Brendan Gregg.
22 *
23 * CDDL HEADER START
24 *
25 *  The contents of this file are subject to the terms of the
26 *  Common Development and Distribution License, Version 1.0 only
27 *  (the "License").  You may not use this file except in compliance
28 *  with the License.
29 *
30 *  You can obtain a copy of the license at Docs/cddl1.txt
31 *  or http://www.opensolaris.org/os/licensing.
32 *  See the License for the specific language governing permissions
33 *  and limitations under the License.
34 *
35 * CDDL HEADER END
36 *
37 * 11-Feb-2006  Brendan Gregg   Created this.
38 */
39
40#include <sys/isa_defs.h>
41
42#pragma D option quiet
43
44dtrace:::BEGIN
45{
46	printf("%-16s %-16s %-6s %s\n",
47	    "CMD", "CLASS", "TYPE", "MOD:INS:NAME");
48}
49
50fbt::read_kstat_data:entry
51{
52#ifdef _MULTI_DATAMODEL
53	self->uk = (kstat32_t *)copyin((uintptr_t)arg1, sizeof (kstat32_t));
54#else
55	self->uk = (kstat_t *)copyin((uintptr_t)arg1, sizeof (kstat_t));
56#endif
57	printf("%-16s %-16s %-6s %s:%d:%s\n", execname,
58	    self->uk->ks_class == "" ? "." : self->uk->ks_class,
59	    self->uk->ks_type == 0 ? "raw"
60	    :  self->uk->ks_type == 1 ? "named"
61	    :  self->uk->ks_type == 2 ? "intr"
62	    :  self->uk->ks_type == 3 ? "io"
63	    :  self->uk->ks_type == 4 ? "timer" : "?",
64	    self->uk->ks_module, self->uk->ks_instance, self->uk->ks_name);
65}
66