diff options
Diffstat (limited to 'cddl/contrib/dtracetoolkit/Kernel')
-rw-r--r-- | cddl/contrib/dtracetoolkit/Kernel/Readme | 3 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Kernel/cpudists | 184 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Kernel/cputimes | 203 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Kernel/cswstat.d | 74 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Kernel/dnlcps.d | 68 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Kernel/dnlcsnoop.d | 92 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Kernel/dnlcstat | 162 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Kernel/kstat_types.d | 66 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Kernel/modcalls.d | 10 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Kernel/priclass.d | 67 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Kernel/pridist.d | 66 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Kernel/putnexts.d | 38 | ||||
-rwxr-xr-x | cddl/contrib/dtracetoolkit/Kernel/whatexec.d | 79 |
13 files changed, 1112 insertions, 0 deletions
diff --git a/cddl/contrib/dtracetoolkit/Kernel/Readme b/cddl/contrib/dtracetoolkit/Kernel/Readme new file mode 100644 index 0000000..3c5d6b3 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Kernel/Readme @@ -0,0 +1,3 @@ +Kernel - Kernel based analysis + + These are scripts to monitor kernel activity. diff --git a/cddl/contrib/dtracetoolkit/Kernel/cpudists b/cddl/contrib/dtracetoolkit/Kernel/cpudists new file mode 100755 index 0000000..b708216 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Kernel/cpudists @@ -0,0 +1,184 @@ +#!/usr/bin/sh +# +# cpudists - print CPU time distributions by Kernel/Idle/Processes. +# Written using DTrace (Solaris 10 3/05). +# +# $Id: cpudists 3 2007-08-01 10:50:08Z brendan $ +# +# USAGE: cpudists [-ahV] [-t top] [interval [count]] +# +# -a # print all processes +# -V # don't print timestamps +# -t num # print top num only +# eg, +# cpudists 1 # print every 1 second +# cpudists -a 10 # print all processes every 10 secs +# +# +# FIELDS: +# value The following or the process name, +# IDLE Idle time - CPU running idle thread +# KERNEL Kernel time - Kernel servicing interrupts, ... +# PROCESS Process time - PIDs running on the system +# count Number of occurances at least this duration (ns) +# +# NOTES: +# * This takes into account multiple CPU servers, the total +# seconds consumed will be a multiple of the CPU count and interval. +# +# SEE ALSO: cputimes +# +# COPYRIGHT: Copyright (c) 2005 Brendan Gregg. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at Docs/cddl1.txt +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# CDDL HEADER END +# +# Author: Brendan Gregg [Sydney, Australia] +# +# 27-Apr-2005 Brendan Gregg Created this. +# 22-Sep-2005 " " Fixed key corruption bug. +# 22-Sep-2005 " " Last update. +# + + +############################## +# --- Process Arguments --- +# +opt_all=0; opt_time=1; opt_top=0; top=0; interval=1; count=1 + +while getopts aht:V name +do + case $name in + a) opt_all=1 ;; + V) opt_time=0 ;; + t) opt_top=1; top=$OPTARG ;; + h|?) cat <<-END >&2 + USAGE: cpudists [-ahV] [-t top] [interval [count]] + cpudists # default output + -a # print all processes + -V # don't print times + -t num # print top num only + END + exit 1 + esac +done +shift `expr $OPTIND - 1` + +if [ "$1" -gt 0 ]; then + interval=$1; count=-1; shift +fi +if [ "$1" -gt 0 ]; then + count=$1; shift +fi + + +################################# +# --- Main Program, DTrace --- +# +/usr/sbin/dtrace -n ' + #pragma D option quiet + + /* + * Command line arguments + */ + inline int OPT_all = '$opt_all'; + inline int OPT_time = '$opt_time'; + inline int OPT_top = '$opt_top'; + inline int TOP = '$top'; + inline int INTERVAL = '$interval'; + inline int COUNTER = '$count'; + + /* Initialise variables */ + dtrace:::BEGIN + { + cpustart[cpu] = 0; + counts = COUNTER; + secs = INTERVAL; + } + + /* Flag this thread as idle */ + sysinfo:unix:idle_enter:idlethread + { + idle[cpu] = 1; + } + + /* Save kernel time between running threads */ + sched:::on-cpu + /cpustart[cpu]/ + { + this->elapsed = timestamp - cpustart[cpu]; + @Procs["KERNEL"] = quantize(this->elapsed); + } + + /* Save the elapsed time of a thread */ + sched:::off-cpu, + sched:::remain-cpu, + profile:::profile-1sec + /cpustart[cpu]/ + { + /* determine the name for this thread */ + program[cpu] = pid == 0 ? idle[cpu] ? "IDLE" : "KERNEL" : + OPT_all ? execname : "PROCESS"; + + /* save elapsed */ + this->elapsed = timestamp - cpustart[cpu]; + @Procs[program[cpu]] = quantize(this->elapsed); + cpustart[cpu] = timestamp; + } + + /* Record the start time of a thread */ + sched:::on-cpu, + sched:::remain-cpu + { + idle[cpu] = 0; + cpustart[cpu] = timestamp; + } + + profile:::tick-1sec + { + secs--; + } + + /* Print time */ + profile:::tick-1sec + /secs == 0 && OPT_time/ + { + printf("%Y,\n", walltimestamp); + } + + /* Print report */ + profile:::tick-1sec + /secs == 0/ + { + OPT_top ? trunc(@Procs, TOP) : 1; + printa("%16s %@16d\n", @Procs); + trunc(@Procs); + secs = INTERVAL; + counts--; + } + + /* End of program */ + profile:::tick-1sec + /counts == 0/ + { + exit(0); + } + + /* cleanup for Ctrl-C */ + dtrace:::END + { + trunc(@Procs); + } +' + diff --git a/cddl/contrib/dtracetoolkit/Kernel/cputimes b/cddl/contrib/dtracetoolkit/Kernel/cputimes new file mode 100755 index 0000000..881bf90 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Kernel/cputimes @@ -0,0 +1,203 @@ +#!/usr/bin/sh +# +# cputimes - print CPU time consumed by Kernel/Idle/Processes. +# Written using DTrace (Solaris 10 3/05). +# +# $Id: cputimes 3 2007-08-01 10:50:08Z brendan $ +# +# This program accurately measures time consumed by the kernel, but in +# doing so creates extra kernel load of it's own. The extra kernel +# activity can be measured by running one cputimes and then another, and +# comparing the difference in kernel consumed time. This method can be +# used to estimate the load created by other DTrace scripts. +# +# USAGE: cputimes [-ahTV] [-t top] [interval [count]] +# +# -a # print all processes +# -T # print totals +# -V # don't print timestamps +# -t num # print top num lines only +# eg, +# cputimes 1 # print every 1 second +# cputimes -a 10 # print all processes every 10 secs +# cputimes -at 8 5 # print top 8 lines every 5 secs +# +# +# FIELDS: +# THREADS The following or the process name, +# IDLE Idle time - CPU running idle thread +# KERNEL Kernel time - Kernel servicing interrupts, ... +# PROCESS Process time - PIDs running on the system +# TIME (ns) Sum of the CPU time, ns (nanoseconds) +# +# NOTES: +# * This takes into account multiple CPU servers, the total +# seconds consumed will be a multiple of the CPU count and interval. +# +# SEE ALSO: cpudists +# Heisenberg's uncertainty principle. +# +# COPYRIGHT: Copyright (c) 2005 Brendan Gregg. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at Docs/cddl1.txt +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# CDDL HEADER END +# +# Author: Brendan Gregg [Sydney, Australia] +# +# 27-Apr-2005 Brendan Gregg Created this. +# 22-Sep-2005 " " Fixed a key corruption bug. +# 22-Sep-2005 " " Last update. +# + + +############################## +# --- Process Arguments --- +# +opt_all=0; opt_time=1; opt_top=0; opt_totals=0 +top=0; interval=1; count=1 + +while getopts aht:TV name +do + case $name in + a) opt_all=1 ;; + T) opt_totals=1 ;; + V) opt_time=0 ;; + t) opt_top=1; top=$OPTARG ;; + h|?) cat <<-END >&2 + USAGE: cputimes [-ahTV] [-t top] [interval [count]] + cputimes # default output + -a # print all processes + -T # print totals + -V # don't print times + -t num # print top num lines only + eg, + cputimes 1 # print every 1 second + cputimes -a 10 # all processes per 10 sec + cputimes -at 8 5 # top 8 lines every 5 secs + END + exit 1 + esac +done +shift `expr $OPTIND - 1` + +if [ "$1" -gt 0 ]; then + interval=$1; count=-1; shift +fi +if [ "$1" -gt 0 ]; then + count=$1; shift +fi + + +################################# +# --- Main Program, DTrace --- +# +/usr/sbin/dtrace -n ' + #pragma D option quiet + + /* + * Command line arguments + */ + inline int OPT_all = '$opt_all'; + inline int OPT_time = '$opt_time'; + inline int OPT_totals = '$opt_totals'; + inline int OPT_top = '$opt_top'; + inline int TOP = '$top'; + inline int INTERVAL = '$interval'; + inline int COUNTER = '$count'; + + /* Initialise variables */ + dtrace:::BEGIN + { + cpustart[cpu] = 0; + counts = COUNTER; + secs = INTERVAL; + } + + /* Flag this thread as idle */ + sysinfo:unix:idle_enter:idlethread + { + idle[cpu] = 1; + } + + /* Save kernel time between running threads */ + sched:::on-cpu + /cpustart[cpu]/ + { + this->elapsed = timestamp - cpustart[cpu]; + @Procs["KERNEL"] = sum(this->elapsed); + } + + /* Save the elapsed time of a thread */ + sched:::off-cpu, + sched:::remain-cpu, + profile:::profile-1sec + /cpustart[cpu]/ + { + /* determine the name for this thread */ + program[cpu] = pid == 0 ? idle[cpu] ? "IDLE" : "KERNEL" : + OPT_all ? execname : "PROCESS"; + + /* save elapsed */ + this->elapsed = timestamp - cpustart[cpu]; + @Procs[program[cpu]] = sum(this->elapsed); + cpustart[cpu] = timestamp; + } + + /* Record the start time of a thread */ + sched:::on-cpu, + sched:::remain-cpu + { + idle[cpu] = 0; + cpustart[cpu] = timestamp; + } + + + profile:::tick-1sec + { + secs--; + } + + /* Print time */ + profile:::tick-1sec + /secs == 0/ + { + OPT_time ? printf("%Y,\n", walltimestamp) : 1; + printf("%16s %16s\n", "THREADS", "TIME (ns)"); + } + + /* Print report */ + profile:::tick-1sec + /secs == 0/ + { + OPT_top ? trunc(@Procs, TOP) : 1; + printa("%16s %@16d\n", @Procs); + trunc(@Procs); + secs = INTERVAL; + counts--; + } + + /* End of program */ + profile:::tick-1sec + /counts == 0/ + { + exit(0); + } + + /* cleanup for Ctrl-C */ + dtrace:::END + { + trunc(@Procs); + } +' + diff --git a/cddl/contrib/dtracetoolkit/Kernel/cswstat.d b/cddl/contrib/dtracetoolkit/Kernel/cswstat.d new file mode 100755 index 0000000..98ca83c --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Kernel/cswstat.d @@ -0,0 +1,74 @@ +#!/usr/sbin/dtrace -s +/* + * cswstat.d - context switch time stat. + * Uses DTrace (Solaris 10 03/05) + * + * This prints a context switch count and consumed time for context + * switching every second. + * + * $Id: cswstat.d 15 2007-09-11 09:09:25Z brendan $ + * + * USAGE: cswstat.d + * + * FIELDS: + * TIME Current time + * NUM Number of context switches + * CSWTIME(us) Time consumed context switching, us + * AVGTIME(us) Average context switch time, us + * + * THANKS: Toomas Soome + * + * COPYRIGHT: Copyright (c) 2005 Brendan Gregg. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at Docs/cddl1.txt + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * CDDL HEADER END + * + * 17-May-2005 Brendan Gregg Created this. + * 03-Nov-2005 " " Last update. + */ + +#pragma D option quiet + +dtrace:::BEGIN +{ + /* print header */ + printf("%-20s %8s %12s %12s\n", "TIME", "NUM", "CSWTIME(us)", + "AVGTIME(us)"); + times = 0; + num = 0; +} + +sched:::off-cpu +{ + /* csw start */ + num++; + start[cpu] = timestamp; +} + +sched:::on-cpu +/start[cpu]/ +{ + /* csw end */ + times += timestamp - start[cpu]; + start[cpu] = 0; +} + +profile:::tick-1sec +{ + /* print output */ + printf("%20Y %8d %12d %12d\n", walltimestamp, num, times/1000, + num == 0 ? 0 : times/(1000 * num)); + times = 0; + num = 0; +} diff --git a/cddl/contrib/dtracetoolkit/Kernel/dnlcps.d b/cddl/contrib/dtracetoolkit/Kernel/dnlcps.d new file mode 100755 index 0000000..d3c3e58 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Kernel/dnlcps.d @@ -0,0 +1,68 @@ +#!/usr/sbin/dtrace -s +/* + * dnlcps.d - DNLC stats by process. + * Written in DTrace (Solaris 10 3/05). + * + * The DNLC is the Directory Name Lookup Cache. Filename lookups often + * return a hit from here, before needing to traverse the regular file + * system cache or go to disk. + * + * dnlcps.d prints DNLC statistics by process. + * + * $Id: dnlcps.d 3 2007-08-01 10:50:08Z brendan $ + * + * USAGE: dnlcps.d # wait several seconds, then hit Ctrl-C + * + * FIELDS: + * PID Process ID + * CMD Command name + * value 0 == miss, 1 == hit + * count number of occurrences + * + * COPYRIGHT: Copyright (c) 2006 Brendan Gregg. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at Docs/cddl1.txt + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * CDDL HEADER END + * + * 27-Mar-2004 Brendan Gregg Created this. + * 14-Jun-2005 " " Rewrote this a lot. + * 18-Feb-2006 " " Last update. + */ + +#pragma D option quiet + +/* + * Print header + */ +dtrace:::BEGIN +{ + printf("Tracing... Hit Ctrl-C to end.\n"); +} + +/* + * DNLC return + */ +fbt:genunix:dnlc_lookup:return +{ + this->code = arg1 == 0 ? 0 : 1; + @Result[execname, pid] = lquantize(this->code, 0, 1, 1); +} + +/* + * Print report + */ +dtrace:::END +{ + printa(" CMD: %-16s PID: %d\n%@d\n", @Result); +} diff --git a/cddl/contrib/dtracetoolkit/Kernel/dnlcsnoop.d b/cddl/contrib/dtracetoolkit/Kernel/dnlcsnoop.d new file mode 100755 index 0000000..1150f45 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Kernel/dnlcsnoop.d @@ -0,0 +1,92 @@ +#!/usr/sbin/dtrace -s +/* + * dnlcsnoop.d - snoop DNLC activity. + * Written in DTrace (Solaris 10 3/05). + * + * The DNLC is the Directory Name Lookup Cache. Filename lookups often + * return a hit from here, before needing to traverse the regular file + * system cache or go to disk. + * + * $Id: dnlcsnoop.d 3 2007-08-01 10:50:08Z brendan $ + * + * USAGE: dnlcsnoop.d # wait several seconds, then hit Ctrl-C + * + * FIELDS: + * PID Process ID + * CMD Command name + * TIME Elapsed time for lookup, us + * HIT DNLC hit Y/N + * PATH Path for DNLC lookup + * + * COPYRIGHT: Copyright (c) 2005, 2006 Brendan Gregg. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at Docs/cddl1.txt + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * CDDL HEADER END + * + * 27-Mar-2004 Brendan Gregg Created this. + * 14-Jun-2005 " " Rewrote this a lot. + * 20-Apr-2006 " " Last update. + */ + +#pragma D option quiet + +/* + * Print header + */ +dtrace:::BEGIN +{ + printf("%6s %-12s %5s %3s %s\n", + "PID", "CMD", "TIME", "HIT", "PATH"); +} + +/* + * DNLC lookup + */ +fbt:genunix:dnlc_lookup:entry +{ + /* store path */ + self->path = stringof(args[0]->v_path); + + /* check for trailing "/" */ + this->len = strlen(self->path); + self->join = *(char *)(args[0]->v_path + this->len - 1) == '/' ? + "" : "/"; + + /* store lookup name */ + self->name = stringof(arg1); + + /* store start time */ + self->start = timestamp; +} + +/* + * DNLC return + */ +fbt:genunix:dnlc_lookup:return +/self->start/ +{ + /* calculate elapsed time */ + this->elapsed = (timestamp - self->start) / 1000; + + /* print output */ + printf("%6d %-12.12s %5d %3s %s%s%s\n", + pid, execname, this->elapsed, arg1 == 0 ? "N" : "Y", + self->path, self->join, self->name); + + /* clear variables */ + self->path = 0; + self->join = 0; + self->name = 0; + self->start = 0; +} diff --git a/cddl/contrib/dtracetoolkit/Kernel/dnlcstat b/cddl/contrib/dtracetoolkit/Kernel/dnlcstat new file mode 100755 index 0000000..b29e8c2 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Kernel/dnlcstat @@ -0,0 +1,162 @@ +#!/usr/bin/sh +# +# dnlcstat - DNLC statistics. +# Written in DTrace (Solaris 10 3/05). +# +# The DNLC is the Directory Name Lookup Cache. Filename lookups often +# return a hit from here, before needing to traverse the regular file +# system cache or go to disk. +# +# $Id: dnlcstat 3 2007-08-01 10:50:08Z brendan $ +# +# USAGE: dnlcstat [interval [count]] +# +# FIELDS: +# +# %hit hit percentage for this sample +# hit number of DNLC hits in this sample +# miss number of DNLC misses in this sample +# +# SEE ALSO: CacheKit, http://www.brendangregg.com/cachekit.html +# (contains a dnlcstat written in Perl, which uses less CPU) +# +# COPYRIGHT: Copyright (c) 2005 Brendan Gregg. +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License, Version 1.0 only +# (the "License"). You may not use this file except in compliance +# with the License. +# +# You can obtain a copy of the license at Docs/cddl1.txt +# or http://www.opensolaris.org/os/licensing. +# See the License for the specific language governing permissions +# and limitations under the License. +# +# CDDL HEADER END +# +# 27-Mar-2004 Brendan Gregg Created this. +# 14-Jun-2005 " " Updated style. +# 14-Jun-2005 " " Last update. +# + +############################## +# --- Process Arguments --- +# + +### default values +interval=1; count=-1 + +### check arguments +if [ "$1" = "-h" -o "$1" = "--help" ]; then + cat <<-END >&2 + USAGE: dnlcstat [interval [count]] + dnlcstat # 1 second samples, infinite + eg, + dnlcstat 1 # print every 1 second + dnlcstat 5 6 # print every 5 seconds, 6 times + END + exit 1 +fi + +### argument logic +if [ "$1" -gt 0 ]; then + interval=$1; count=-1; shift +fi +if [ "$1" -gt 0 ]; then + count=$1; shift +fi +if [ $interval -eq 0 ]; then + interval=1 +fi + + +################################# +# --- Main Program, DTrace --- +# +/usr/sbin/dtrace -n ' + #pragma D option quiet + + /* + * Command line arguments + */ + inline int INTERVAL = '$interval'; + inline int COUNTER = '$count'; + inline int SCREEN = 21; + + int hits; /* hits */ + int misses; /* misses */ + + /* + * Initialise variables + */ + dtrace:::BEGIN + { + lines = SCREEN + 1; + counts = COUNTER; + secs = INTERVAL; + first = 1; + } + + /* + * Print header + */ + dtrace:::BEGIN, + tick-1sec + /first || (secs == 0 && lines > SCREEN)/ + { + printf("%10s %8s %8s\n","dnlc %hit","hit","miss"); + lines = 0; + first = 0; + } + + /* + * Probe DNLC lookups + */ + fbt:genunix:dnlc_lookup:return + { + hits += arg1 == 0 ? 0 : 1; + misses += arg1 == 0 ? 1 : 0; + } + + profile:::tick-1sec + { + secs--; + } + + + /* + * Print output line + */ + profile:::tick-1sec + /secs == 0/ + { + /* calculate hit percent */ + this->divide = misses + hits == 0 ? 1 : misses + hits; + ratio = hits * 100 / this->divide; + + /* print output */ + printf("%10d %8d %8d\n",ratio,hits,misses); + + /* clear counters */ + hits = 0; + misses = 0; + + /* process counts */ + secs = INTERVAL; + counts--; + lines++; + + } + + /* + * End + */ + profile:::tick-1sec + /counts == 0/ + { + exit(0); + } +' + diff --git a/cddl/contrib/dtracetoolkit/Kernel/kstat_types.d b/cddl/contrib/dtracetoolkit/Kernel/kstat_types.d new file mode 100755 index 0000000..119bc77 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Kernel/kstat_types.d @@ -0,0 +1,66 @@ +#!/usr/sbin/dtrace -Cs +/* + * kstat_types.d - Trace kstat reads with type info. + * Written using DTrace (Solaris 10 3/05) + * + * kstat is the Kernel Statistics framework, which is used by tools + * such as vmstat, iostat, mpstat and sar. Try running vmstat while + * kstat_types.d is tracing - you should see details of the kstat + * reads performed. + * + * $Id: kstat_types.d 3 2007-08-01 10:50:08Z brendan $ + * + * USAGE: kstat_types.d (early release, check for updates) + * + * FIELDS: + * CMD command name + * CLASS kstat class (ks_class) + * TYPE kstat type as a string (ks_type) + * MOD:INS:NAME kstat module:instance:name + * + * COPYRIGHT: Copyright (c) 2006 Brendan Gregg. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at Docs/cddl1.txt + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * CDDL HEADER END + * + * 11-Feb-2006 Brendan Gregg Created this. + * 11-Feb-2006 " " Last update. + */ + +#include <sys/isa_defs.h> + +#pragma D option quiet + +dtrace:::BEGIN +{ + printf("%-16s %-16s %-6s %s\n", + "CMD", "CLASS", "TYPE", "MOD:INS:NAME"); +} + +fbt::read_kstat_data:entry +{ +#ifdef _MULTI_DATAMODEL + self->uk = (kstat32_t *)copyin((uintptr_t)arg1, sizeof (kstat32_t)); +#else + self->uk = (kstat_t *)copyin((uintptr_t)arg1, sizeof (kstat_t)); +#endif + printf("%-16s %-16s %-6s %s:%d:%s\n", execname, + self->uk->ks_class == "" ? "." : self->uk->ks_class, + self->uk->ks_type == 0 ? "raw" + : self->uk->ks_type == 1 ? "named" + : self->uk->ks_type == 2 ? "intr" + : self->uk->ks_type == 3 ? "io" + : self->uk->ks_type == 4 ? "timer" : "?", + self->uk->ks_module, self->uk->ks_instance, self->uk->ks_name); +} diff --git a/cddl/contrib/dtracetoolkit/Kernel/modcalls.d b/cddl/contrib/dtracetoolkit/Kernel/modcalls.d new file mode 100755 index 0000000..0386a7a --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Kernel/modcalls.d @@ -0,0 +1,10 @@ +#!/usr/sbin/dtrace -s +/* + * modcalls.d - kernel function calls by module. DTrace OneLiner. + * + * This is a DTrace OneLiner from the DTraceToolkit. + * + * $Id: modcalls.d 3 2007-08-01 10:50:08Z brendan $ + */ + +fbt:::entry { @calls[probemod] = count(); } diff --git a/cddl/contrib/dtracetoolkit/Kernel/priclass.d b/cddl/contrib/dtracetoolkit/Kernel/priclass.d new file mode 100755 index 0000000..92275dc --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Kernel/priclass.d @@ -0,0 +1,67 @@ +#!/usr/sbin/dtrace -s +/* + * priclass.d - priority distribution by scheduling class. + * Written using DTrace (Solaris 10 3/05) + * + * This is a simple DTrace script that samples at 1000 Hz the current + * thread's scheduling class and priority. A distribution plot is printed. + * + * With priorities, the higher the priority the better chance the thread + * has of being scheduled. + * + * This idea came from the script /usr/demo/dtrace/pri.d, which + * produces similar output for priority changes, not samples. + * + * $Id: priclass.d 3 2007-08-01 10:50:08Z brendan $ + * + * USAGE: priclass.d # hit Ctrl-C to end sampling + * + * FIELDS: + * value process priority + * count number of samples of at least this priority + * + * Also printed is the scheduling class, + * + * TS time sharing + * IA interactive + * RT real time + * SYS system + * FSS fair share schedular + * + * BASED ON: /usr/demo/dtrace/pri.d + * + * SEE ALSO: DTrace Guide "profile Provider" chapter (docs.sun.com) + * dispadmin(1M) + * + * PORTIONS: Copyright (c) 2006 Brendan Gregg. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at Docs/cddl1.txt + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * CDDL HEADER END + * + * 12-Feb-2006 Brendan Gregg Created this. + * 22-Apr-2006 " " Last update. + */ + +#pragma D option quiet + +dtrace:::BEGIN +{ + printf("Sampling... Hit Ctrl-C to end.\n"); +} + +profile:::profile-1000hz +{ + @count[stringof(curlwpsinfo->pr_clname)] + = lquantize(curlwpsinfo->pr_pri, 0, 170, 10); +} diff --git a/cddl/contrib/dtracetoolkit/Kernel/pridist.d b/cddl/contrib/dtracetoolkit/Kernel/pridist.d new file mode 100755 index 0000000..1b6d3eb --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Kernel/pridist.d @@ -0,0 +1,66 @@ +#!/usr/sbin/dtrace -s +/* + * pridist.d - process priority distribution. + * Written using DTrace (Solaris 10 3/05) + * + * This is a simple DTrace script that samples at 1000 Hz which process + * is on the CPUs, and what the priority is. A distribution plot is printed. + * + * With priorities, the higher the priority the better chance the process + * (actually, thread) has of being scheduled. + * + * This idea came from the script /usr/demo/dtrace/profpri.d, which + * produces similar output for one particular PID. + * + * $Id: pridist.d 3 2007-08-01 10:50:08Z brendan $ + * + * USAGE: pridist.d # hit Ctrl-C to end sampling + * + * FIELDS: + * CMD process name + * PID process ID + * value process priority + * count number of samples of at least this priority + * + * BASED ON: /usr/demo/dtrace/profpri.d + * + * SEE ALSO: + * DTrace Guide "profile Provider" chapter (docs.sun.com) + * dispadmin(1M) + * + * PORTIONS: Copyright (c) 2005 Brendan Gregg. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at Docs/cddl1.txt + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * CDDL HEADER END + * + * 13-Jun-2005 Brendan Gregg Created this. + * 22-Apr-2006 " " Last update. + */ + +#pragma D option quiet + +dtrace:::BEGIN +{ + printf("Sampling... Hit Ctrl-C to end.\n"); +} + +profile:::profile-1000hz +{ + @Count[execname, pid] = lquantize(curlwpsinfo->pr_pri, 0, 170, 5); +} + +dtrace:::END +{ + printa(" CMD: %-16s PID: %d\n%@d\n", @Count); +} diff --git a/cddl/contrib/dtracetoolkit/Kernel/putnexts.d b/cddl/contrib/dtracetoolkit/Kernel/putnexts.d new file mode 100755 index 0000000..cb99a72 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Kernel/putnexts.d @@ -0,0 +1,38 @@ +#!/usr/sbin/dtrace -s +/* + * putnexts.d - stream putnext() tracing with stacks. Solaris, DTrace. + * + * This shows who is calling putnext() to who, by listing the destination + * queue and the calling stack, by frequency count. This is especially useful + * for understanding streams based frameworks, such as areas of the Solaris + * TCP/IP stack. + * + * $Id: putnexts.d 14 2007-09-11 08:03:35Z brendan $ + * + * USAGE: putnext.d + * + * BASED ON: /usr/demo/dtrace/putnext.d + * + * PORTIONS: Copyright (c) 2007 Brendan Gregg. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at Docs/cddl1.txt + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * CDDL HEADER END + * + * 12-Jun-2005 Brendan Gregg Created this. + */ + +fbt::putnext:entry +{ + @[stringof(args[0]->q_qinfo->qi_minfo->mi_idname), stack(5)] = count(); +} diff --git a/cddl/contrib/dtracetoolkit/Kernel/whatexec.d b/cddl/contrib/dtracetoolkit/Kernel/whatexec.d new file mode 100755 index 0000000..e70173b --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Kernel/whatexec.d @@ -0,0 +1,79 @@ +#!/usr/sbin/dtrace -s +/* + * whatexec.d - Examine the type of files exec'd. + * Written using DTrace (Solaris 10 3/05) + * + * This prints the first four chacacters of files that are executed. + * This traces the kernel function findexec_by_hdr(), which checks for + * a known magic number in the file's header. + * + * The idea came from a demo I heard about from the UK, where a + * "blue screen of death" was displayed for "MZ" files (although I + * haven't seen the script or the demo). + * + * $Id: whatexec.d 3 2007-08-01 10:50:08Z brendan $ + * + * USAGE: whatexec.d (early release, check for updates) + * + * FIELDS: + * PEXEC parent command name + * EXEC pathname to file exec'd + * OK is type runnable, Y/N + * TYPE first four characters from file + * + * COPYRIGHT: Copyright (c) 2006 Brendan Gregg. + * + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at Docs/cddl1.txt + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * CDDL HEADER END + * + * 11-Feb-2006 Brendan Gregg Created this. + * 25-Apr-2006 " " Last update. + */ + +#pragma D option quiet + +this char *buf; + +dtrace:::BEGIN +{ + printf("%-16s %-38s %2s %s\n", "PEXEC", "EXEC", "OK", "TYPE"); +} + +fbt::gexec:entry +{ + self->file = cleanpath((*(struct vnode **)arg0)->v_path); + self->ok = 1; +} + +fbt::findexec_by_hdr:entry +/self->ok/ +{ + bcopy(args[0], this->buf = alloca(5), 4); + this->buf[4] = '\0'; + self->hdr = stringof(this->buf); +} + +fbt::findexec_by_hdr:return +/self->ok/ +{ + printf("%-16s %-38s %2s %S\n", execname, self->file, + arg1 == NULL ? "N" : "Y", self->hdr); + self->hdr = 0; +} + +fbt::gexec:return +{ + self->file = 0; + self->ok = 0; +} |