summaryrefslogtreecommitdiffstats
path: root/cddl/contrib/dtracetoolkit/Cpu
diff options
context:
space:
mode:
Diffstat (limited to 'cddl/contrib/dtracetoolkit/Cpu')
-rw-r--r--cddl/contrib/dtracetoolkit/Cpu/Readme3
-rwxr-xr-xcddl/contrib/dtracetoolkit/Cpu/cputypes.d66
-rwxr-xr-xcddl/contrib/dtracetoolkit/Cpu/cpuwalk.d72
-rwxr-xr-xcddl/contrib/dtracetoolkit/Cpu/dispqlen.d52
-rwxr-xr-xcddl/contrib/dtracetoolkit/Cpu/intbycpu.d49
-rwxr-xr-xcddl/contrib/dtracetoolkit/Cpu/intoncpu.d66
-rwxr-xr-xcddl/contrib/dtracetoolkit/Cpu/inttimes.d73
-rwxr-xr-xcddl/contrib/dtracetoolkit/Cpu/loads.d58
-rwxr-xr-xcddl/contrib/dtracetoolkit/Cpu/runocc.d56
-rwxr-xr-xcddl/contrib/dtracetoolkit/Cpu/xcallsbypid.d51
10 files changed, 546 insertions, 0 deletions
diff --git a/cddl/contrib/dtracetoolkit/Cpu/Readme b/cddl/contrib/dtracetoolkit/Cpu/Readme
new file mode 100644
index 0000000..e0f8698
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Cpu/Readme
@@ -0,0 +1,3 @@
+Cpu - CPU based analysis
+
+ This would include activity by CPU.
diff --git a/cddl/contrib/dtracetoolkit/Cpu/cputypes.d b/cddl/contrib/dtracetoolkit/Cpu/cputypes.d
new file mode 100755
index 0000000..213af9e
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Cpu/cputypes.d
@@ -0,0 +1,66 @@
+#!/usr/sbin/dtrace -s
+/*
+ * cputypes.d - list CPU type info.
+ * Written using DTrace (Solaris 10 3/05).
+ *
+ * $Id: cputypes.d 3 2007-08-01 10:50:08Z brendan $
+ *
+ * USAGE: cputypes.d
+ *
+ * FIELDS:
+ * CPU CPU ID
+ * CHIP chip ID
+ * PSET processor set ID
+ * LGRP latency group ID
+ * CLOCK clock speed, MHz
+ * TYPE CPU type
+ * FPU floating point identifier types
+ *
+ * SEE ALSO: psrinfo(1M)
+ * /usr/include/sys/processor.h
+ *
+ * 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-Jun-2005 Brendan Gregg Created this.
+ * 27-Jun-2005 " " Last update.
+ */
+
+#pragma D option quiet
+#pragma D option bufsize=64k
+
+dtrace:::BEGIN
+{
+ printf("%4s %4s %4s %4s %6s %-16s %s\n",
+ "CPU", "CHIP", "PSET", "LGRP", "CLOCK", "TYPE", "FPU");
+ done[0] = 0;
+}
+
+profile:::profile-10ms
+/done[cpu] == 0/
+{
+ printf("%4d %4d %4d %4d %6d %-16s %s\n",
+ cpu, curcpu->cpu_chip, curcpu->cpu_pset,
+ curcpu->cpu_lgrp, curcpu->cpu_info.pi_clock,
+ stringof(curcpu->cpu_info.pi_processor_type),
+ stringof(curcpu->cpu_info.pi_fputypes));
+ done[cpu]++;
+}
+
+profile:::tick-100ms
+{
+ exit(0);
+}
diff --git a/cddl/contrib/dtracetoolkit/Cpu/cpuwalk.d b/cddl/contrib/dtracetoolkit/Cpu/cpuwalk.d
new file mode 100755
index 0000000..495f64b
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Cpu/cpuwalk.d
@@ -0,0 +1,72 @@
+#!/usr/sbin/dtrace -s
+/*
+ * cpuwalk.d - Measure which CPUs a process runs on.
+ * Written using DTrace (Solaris 10 3/05)
+ *
+ * This program is for multi-CPU servers, and can help identify if a process
+ * is running on multiple CPUs concurrently or not.
+ *
+ * $Id: cpuwalk.d 3 2007-08-01 10:50:08Z brendan $
+ *
+ * USAGE: cpuwalk.d [duration]
+ * eg,
+ * cpuwalk.d 10 # sample for 10 seconds
+ * cpuwalk.d # sample until Ctrl-C is hit
+ *
+ * FIELDS:
+ * value CPU id
+ * count Number of 1000 hz samples on this 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
+ *
+ * 22-Sep-2005 Brendan Gregg Created this.
+ * 14-Feb-2006 " " Last update.
+ */
+
+#pragma D option quiet
+#pragma D option defaultargs
+
+inline int MAXCPUID = 1024;
+
+dtrace:::BEGIN
+{
+ $1 ? printf("Sampling...\n") :
+ printf("Sampling... Hit Ctrl-C to end.\n");
+ seconds = 0;
+}
+
+profile:::profile-1000hz
+/pid/
+{
+ @sample[pid, execname] = lquantize(cpu, 0, MAXCPUID, 1);
+}
+
+profile:::tick-1sec
+{
+ seconds++;
+}
+
+profile:::tick-1sec
+/seconds == $1/
+{
+ exit(0);
+}
+
+dtrace:::END
+{
+ printa("\n PID: %-8d CMD: %s\n%@d", @sample);
+}
diff --git a/cddl/contrib/dtracetoolkit/Cpu/dispqlen.d b/cddl/contrib/dtracetoolkit/Cpu/dispqlen.d
new file mode 100755
index 0000000..46742c5
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Cpu/dispqlen.d
@@ -0,0 +1,52 @@
+#!/usr/sbin/dtrace -s
+/*
+ * dispqlen.d - dispatcher queue length by CPU.
+ * Written using DTrace (Solaris 10 3/05).
+ *
+ * $Id: dispqlen.d 3 2007-08-01 10:50:08Z brendan $
+ *
+ * USAGE: dispqlen.d # hit Ctrl-C to end sample
+ *
+ * NOTES: The dispatcher queue length is an indication of CPU saturation.
+ * It is not an indicatior of utilisation - the CPUs may or may not be
+ * utilised when the dispatcher queue reports a length of zero.
+ *
+ * SEE ALSO: uptime(1M)
+ *
+ * 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-Jun-2005 Brendan Gregg Created this.
+ * 14-Feb-2006 " " Last update.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Sampling... Hit Ctrl-C to end.\n");
+}
+
+profile:::profile-1000hz
+{
+ @queue[cpu] =
+ lquantize(curthread->t_cpu->cpu_disp->disp_nrunnable, 0, 64, 1);
+}
+
+dtrace:::END
+{
+ printa(" CPU %d%@d\n", @queue);
+}
diff --git a/cddl/contrib/dtracetoolkit/Cpu/intbycpu.d b/cddl/contrib/dtracetoolkit/Cpu/intbycpu.d
new file mode 100755
index 0000000..606f402
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Cpu/intbycpu.d
@@ -0,0 +1,49 @@
+#!/usr/sbin/dtrace -s
+/*
+ * intbycpu.d - interrupts by CPU.
+ * Written using DTrace (Solaris 10 3/05).
+ *
+ * $Id: intbycpu.d 3 2007-08-01 10:50:08Z brendan $
+ *
+ * USAGE: intbycpu.d # hit Ctrl-C to end sample
+ *
+ * FIELDS:
+ * CPU CPU number
+ * INTERRUPTS number of interrupts in sample
+ *
+ * This is based on a DTrace OneLiner from the DTraceToolkit.
+ *
+ * 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
+ *
+ * 15-May-2005 Brendan Gregg Created this.
+ * 20-Apr-2006 " " Last update.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Tracing... Hit Ctrl-C to end.\n");
+}
+
+sdt:::interrupt-start { @num[cpu] = count(); }
+
+dtrace:::END
+{
+ printf("%-16s %16s\n", "CPU", "INTERRUPTS");
+ printa("%-16d %@16d\n", @num);
+}
diff --git a/cddl/contrib/dtracetoolkit/Cpu/intoncpu.d b/cddl/contrib/dtracetoolkit/Cpu/intoncpu.d
new file mode 100755
index 0000000..b32685a
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Cpu/intoncpu.d
@@ -0,0 +1,66 @@
+#!/usr/sbin/dtrace -s
+/*
+ * intoncpu.d - print interrupt on-cpu usage.
+ * Written using DTrace (Solaris 10 3/05)
+ *
+ * $Id: intoncpu.d 3 2007-08-01 10:50:08Z brendan $
+ *
+ * USAGE: intoncpu.d # wait several seconds, then hit Ctrl-C
+ *
+ * FIELDS:
+ * value Time interrupt thread was on-cpu, ns
+ * count Number of occurrences of at least this time
+ *
+ * BASED ON: /usr/demo/dtrace/intr.d
+ *
+ * SEE ALSO: DTrace Guide "sdt Provider" chapter (docs.sun.com)
+ * intrstat(1M)
+ *
+ * PORTIONS: 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
+ *
+ * 09-May-2005 Brendan Gregg Created this.
+ * 20-Apr-2006 " " Last update.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Tracing... Hit Ctrl-C to end.\n");
+}
+
+sdt:::interrupt-start
+{
+ self->ts = vtimestamp;
+}
+
+sdt:::interrupt-complete
+/self->ts && arg0 != 0/
+{
+ this->devi = (struct dev_info *)arg0;
+ /* this checks the pointer is valid, */
+ self->name = this->devi != 0 ?
+ stringof(`devnamesp[this->devi->devi_major].dn_name) : "?";
+ this->inst = this->devi != 0 ? this->devi->devi_instance : 0;
+ @Time[self->name, this->inst] = quantize(vtimestamp - self->ts);
+ self->name = 0;
+}
+
+dtrace:::END
+{
+ printa("%s%d\n%@d", @Time);
+}
diff --git a/cddl/contrib/dtracetoolkit/Cpu/inttimes.d b/cddl/contrib/dtracetoolkit/Cpu/inttimes.d
new file mode 100755
index 0000000..926a566
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Cpu/inttimes.d
@@ -0,0 +1,73 @@
+#!/usr/sbin/dtrace -s
+/*
+ * inttimes.d - print interrupt on-cpu time.
+ * Written using DTrace (Solaris 10 3/05)
+ *
+ * $Id: inttimes.d 3 2007-08-01 10:50:08Z brendan $
+ *
+ * USAGE: inttimes.d # wait several seconds, then hit Ctrl-C
+ *
+ * FIELDS:
+ * DEVICE instance name of device driver
+ * TIME (ns) sum of time spent servicing interrupt (ns)
+ *
+ * BASED ON: /usr/demo/dtrace/intr.d
+ *
+ * SEE ALSO:
+ * DTrace Guide "sdt Provider" chapter (docs.sun.com)
+ * intrstat(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
+ *
+ * 28-Jun-2005 Brendan Gregg Created this.
+ * 20-Apr-2006 " " Last update.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Tracing... Hit Ctrl-C to end.\n");
+}
+
+sdt:::interrupt-start
+{
+ self->ts = vtimestamp;
+}
+
+sdt:::interrupt-complete
+/self->ts && arg0 != 0/
+{
+ this->devi = (struct dev_info *)arg0;
+ /* this checks the pointer is valid, */
+ self->name = this->devi != 0 ?
+ stringof(`devnamesp[this->devi->devi_major].dn_name) : "?";
+ this->inst = this->devi != 0 ? this->devi->devi_instance : 0;
+ @num[self->name, this->inst] = sum(vtimestamp - self->ts);
+ self->name = 0;
+}
+
+sdt:::interrupt-complete
+{
+ self->ts = 0;
+}
+
+dtrace:::END
+{
+ printf("%11s %16s\n", "DEVICE", "TIME (ns)");
+ printa("%10s%-3d %@16d\n", @num);
+}
diff --git a/cddl/contrib/dtracetoolkit/Cpu/loads.d b/cddl/contrib/dtracetoolkit/Cpu/loads.d
new file mode 100755
index 0000000..681e8f6
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Cpu/loads.d
@@ -0,0 +1,58 @@
+#!/usr/sbin/dtrace -s
+/*
+ * loads.d - print load averages. Written using DTrace (Solaris 10 3/05).
+ *
+ * These are the same load averages that the "uptime" command prints.
+ * The purpose of this script is to demonstrate fetching these values
+ * from the DTrace language.
+ *
+ * $Id: loads.d 3 2007-08-01 10:50:08Z brendan $
+ *
+ * USAGE: loads.d
+ *
+ * SEE ALSO: uptime(1)
+ *
+ * The first field is the 1 minute average, the second is the 5 minute,
+ * and the third is the 15 minute average. The value represents the average
+ * number of runnable threads in the system, a value higher than your
+ * CPU (core/hwthread) count may be a sign of CPU saturation.
+ *
+ * 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
+ *
+ * 10-Jun-2005 Brendan Gregg Created this.
+ * 10-Jun-2005 " " Last update.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ /* fetch load averages */
+ this->load1a = `hp_avenrun[0] / 65536;
+ this->load5a = `hp_avenrun[1] / 65536;
+ this->load15a = `hp_avenrun[2] / 65536;
+ this->load1b = ((`hp_avenrun[0] % 65536) * 100) / 65536;
+ this->load5b = ((`hp_avenrun[1] % 65536) * 100) / 65536;
+ this->load15b = ((`hp_avenrun[2] % 65536) * 100) / 65536;
+
+ /* print load average */
+ printf("%Y, load average: %d.%02d, %d.%02d, %d.%02d\n",
+ walltimestamp, this->load1a, this->load1b, this->load5a,
+ this->load5b, this->load15a, this->load15b);
+
+ exit(0);
+}
diff --git a/cddl/contrib/dtracetoolkit/Cpu/runocc.d b/cddl/contrib/dtracetoolkit/Cpu/runocc.d
new file mode 100755
index 0000000..a2b0469
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Cpu/runocc.d
@@ -0,0 +1,56 @@
+#!/usr/sbin/dtrace -s
+/*
+ * runocc.d - run queue occupancy by CPU.
+ * Written using DTrace (Solaris 10 3/05).
+ *
+ * This prints the dispatcher run queue occupancy by CPU each second.
+ * A consistant run queue occupancy is a sign of CPU saturation.
+ *
+ * The value is similar to that seen in "sar -q", however this is
+ * calculated in a more accurate manner - sampling at 1000 Hertz.
+ *
+ * $Id: runocc.d 3 2007-08-01 10:50:08Z brendan $
+ *
+ * USAGE: runocc.d
+ *
+ * FIELDS:
+ * CPU cpu ID
+ * %runocc % run queue occupancy, sampled at 1000 Hertz
+ *
+ * SEE ALSO: Solaris Internals 2nd Ed, vol 2, CPU chapter.
+ *
+ * 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
+ *
+ * 02-Mar-2006 Brendan Gregg Created this.
+ * 24-Apr-2006 " " Last update.
+ */
+
+#pragma D option quiet
+
+profile-1000hz
+/curthread->t_cpu->cpu_disp->disp_nrunnable/
+{
+ @qocc[cpu] = count();
+}
+
+profile:::tick-1sec
+{
+ normalize(@qocc, 10);
+ printf("\n%8s %8s\n", "CPU", "%runocc");
+ printa("%8d %@8d\n", @qocc);
+ clear(@qocc);
+}
diff --git a/cddl/contrib/dtracetoolkit/Cpu/xcallsbypid.d b/cddl/contrib/dtracetoolkit/Cpu/xcallsbypid.d
new file mode 100755
index 0000000..b08027c
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Cpu/xcallsbypid.d
@@ -0,0 +1,51 @@
+#!/usr/sbin/dtrace -s
+/*
+ * xcallsbypid.d - CPU cross calls by PID.
+ * Writen using DTrace (Solaris 10 3/05).
+ *
+ * $Id: xcallsbypid.d 3 2007-08-01 10:50:08Z brendan $
+ *
+ * USAGE: xcallsbypid.d # hit Ctrl-C to end sample
+ *
+ * FIELDS:
+ * PID process ID
+ * CMD process name
+ * XCALLS number of cross calls
+ *
+ * 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
+ *
+ * 17-Sep-2005 Brendan Gregg Created this.
+ * 20-Apr-2006 " " Last update.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Tracing... Hit Ctrl-C to end.\n");
+}
+
+sysinfo:::xcalls
+{
+ @num[pid, execname] = count();
+}
+
+dtrace:::END
+{
+ printf("%6s %-16s %16s\n", "PID", "CMD", "XCALLS");
+ printa("%6d %-16s %@16d\n", @num);
+}
OpenPOWER on IntegriCloud