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 * $Id: kstat_types.d 3 2007-08-01 10:50:08Z brendan $ 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 * 11-Feb-2006 " " Last update. 39 */ 40 41#include <sys/isa_defs.h> 42 43#pragma D option quiet 44 45dtrace:::BEGIN 46{ 47 printf("%-16s %-16s %-6s %s\n", 48 "CMD", "CLASS", "TYPE", "MOD:INS:NAME"); 49} 50 51fbt::read_kstat_data:entry 52{ 53#ifdef _MULTI_DATAMODEL 54 self->uk = (kstat32_t *)copyin((uintptr_t)arg1, sizeof (kstat32_t)); 55#else 56 self->uk = (kstat_t *)copyin((uintptr_t)arg1, sizeof (kstat_t)); 57#endif 58 printf("%-16s %-16s %-6s %s:%d:%s\n", execname, 59 self->uk->ks_class == "" ? "." : self->uk->ks_class, 60 self->uk->ks_type == 0 ? "raw" 61 : self->uk->ks_type == 1 ? "named" 62 : self->uk->ks_type == 2 ? "intr" 63 : self->uk->ks_type == 3 ? "io" 64 : self->uk->ks_type == 4 ? "timer" : "?", 65 self->uk->ks_module, self->uk->ks_instance, self->uk->ks_name); 66} 67