summaryrefslogtreecommitdiffstats
path: root/cddl/contrib/dtracetoolkit/System
diff options
context:
space:
mode:
Diffstat (limited to 'cddl/contrib/dtracetoolkit/System')
-rw-r--r--cddl/contrib/dtracetoolkit/System/Readme3
-rwxr-xr-xcddl/contrib/dtracetoolkit/System/sar-c.d101
-rwxr-xr-xcddl/contrib/dtracetoolkit/System/syscallbysysc.d10
-rwxr-xr-xcddl/contrib/dtracetoolkit/System/topsyscall184
-rwxr-xr-xcddl/contrib/dtracetoolkit/System/uname-a.d53
5 files changed, 351 insertions, 0 deletions
diff --git a/cddl/contrib/dtracetoolkit/System/Readme b/cddl/contrib/dtracetoolkit/System/Readme
new file mode 100644
index 0000000..3d739da
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/System/Readme
@@ -0,0 +1,3 @@
+System - System based analysis
+
+ This would include measuring system wide activity.
diff --git a/cddl/contrib/dtracetoolkit/System/sar-c.d b/cddl/contrib/dtracetoolkit/System/sar-c.d
new file mode 100755
index 0000000..ef63198
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/System/sar-c.d
@@ -0,0 +1,101 @@
+#!/usr/sbin/dtrace -s
+/*
+ * sar-c.d - sar -c demo in DTrace.
+ * Written using DTrace (Solaris 10 3/05).
+ *
+ * This has been written to demonstrate fetching similar data as sar -c
+ * from DTrace. This program is intended as a starting point for other
+ * DTrace scripts, by beginning with familiar statistics.
+ *
+ * $Id: sar-c.d 3 2007-08-01 10:50:08Z brendan $
+ *
+ * USAGE: sar-c.d
+ *
+ * FIELDS:
+ * scall/s System calls
+ * sread/s reads
+ * swrit/s writes
+ * fork/s forks
+ * exec/s execs
+ * rchar/s read characters
+ * wchar/s write characters
+ *
+ * IDEA: David Rubio, who also wrote the original.
+ *
+ * NOTES:
+ * As this program does not use Kstat, there is no summary since boot line.
+ *
+ * SEE ALSO: sar(1)
+ *
+ * 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
+ *
+ * 12-Jun-2005 Brendan Gregg Created this.
+ * 12-Jun-2005 " " Last update.
+ */
+
+#pragma D option quiet
+
+inline int SCREEN = 21;
+
+/*
+ * Initialise variables
+ */
+dtrace:::BEGIN
+{
+ scall = 0; sread = 0; swrit = 0; fork = 0; exec = 0;
+ rchar = 0; wchar = 0;
+ lines = SCREEN + 1;
+}
+
+/*
+ * Print header
+ */
+dtrace:::BEGIN,
+tick-1sec
+/lines++ > SCREEN/
+{
+ printf("%-20s %7s %7s %7s %7s %7s %8s %8s\n",
+ "Time", "scall/s", "sread/s", "swrit/s", "fork/s",
+ "exec/s", "rchar/s", "wchar/s");
+ lines = 0;
+}
+
+/*
+ * Probe events
+ */
+syscall:::entry { scall++; }
+sysinfo:::sysread { sread++; }
+sysinfo:::syswrite { swrit++; }
+sysinfo:::sysfork { fork++; }
+sysinfo:::sysvfork { fork++; }
+sysinfo:::sysexec { exec++; }
+sysinfo:::readch { rchar += arg0; }
+sysinfo:::writech { wchar += arg0; }
+
+/*
+ * Print output line
+ */
+profile:::tick-1sec
+{
+ /* print line */
+ printf("%20Y %7d %7d %7d %4d.00 %4d.00 %8d %8d\n",
+ walltimestamp, scall, sread, swrit, fork, exec, rchar, wchar);
+
+ /* clear counters */
+ scall = 0; sread = 0; swrit = 0; fork = 0; exec = 0;
+ rchar = 0; wchar = 0;
+}
diff --git a/cddl/contrib/dtracetoolkit/System/syscallbysysc.d b/cddl/contrib/dtracetoolkit/System/syscallbysysc.d
new file mode 100755
index 0000000..86b8ac3
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/System/syscallbysysc.d
@@ -0,0 +1,10 @@
+#!/usr/sbin/dtrace -s
+/*
+ * syscallbysysc.d - report on syscalls by syscall. DTrace OneLiner.
+ *
+ * This is a DTrace OneLiner from the DTraceToolkit.
+ *
+ * $Id: syscallbysysc.d 3 2007-08-01 10:50:08Z brendan $
+ */
+
+syscall:::entry { @num[probefunc] = count(); }
diff --git a/cddl/contrib/dtracetoolkit/System/topsyscall b/cddl/contrib/dtracetoolkit/System/topsyscall
new file mode 100755
index 0000000..63ef8c6
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/System/topsyscall
@@ -0,0 +1,184 @@
+#!/usr/bin/ksh
+#
+# topsyscall - display top syscalls by syscall name.
+# Written using DTrace (Solaris 10 3/05).
+#
+# This program continually prints a report of the top system calls,
+# and refreshes the display every 1 second or as specified at the
+# command line.
+#
+# $Id: topsyscall 3 2007-08-01 10:50:08Z brendan $
+#
+# USAGE: topsyscall [-Cs] [interval [count]]
+#
+# -C # don't clear the screen
+# -s # print per second values
+#
+# FIELDS:
+# load avg load averages, see uptime(1)
+# syscalls total syscalls in this interval
+# syscalls/s syscalls per second
+# SYSCALL system call name
+# COUNT total syscalls in this interval
+# COUNT/s syscalls per second
+#
+# INSPIRATION: top(1) by William LeFebvre
+#
+# 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
+#
+# 13-Jun-2005 Brendan Gregg Created this.
+# 20-Apr-2006 " " Last update.
+#
+
+##############################
+# --- Process Arguments ---
+#
+
+### Default variables
+count=-1; interval=1; opt_persec=0; opt_clear=1
+
+### Process options
+while getopts Chs name
+do
+ case $name in
+ C) opt_clear=0 ;;
+ s) opt_persec=1 ;;
+ h|?) cat <<-END >&2
+ USAGE: topsyscall [-s] [interval [count]]
+ -C # don't clear the screen
+ -s # print per second values
+ eg,
+ topsyscall # default, 1 second updates
+ topsyscall 5 # 5 second updates
+ END
+ exit 1
+ esac
+done
+shift $(( $OPTIND - 1 ))
+
+### option logic
+if [[ "$1" > 0 ]]; then
+ interval=$1; shift
+fi
+if [[ "$1" > 0 ]]; then
+ count=$1; shift
+fi
+if (( opt_clear )); then
+ clearstr=`clear`
+else
+ clearstr=.
+fi
+
+
+
+#################################
+# --- Main Program, DTrace ---
+#
+/usr/sbin/dtrace -n '
+ #pragma D option quiet
+ #pragma D option destructive
+
+ /* constants */
+ inline int OPT_clear = '$opt_clear';
+ inline int OPT_persec = '$opt_persec';
+ inline int INTERVAL = '$interval';
+ inline int COUNTER = '$count';
+ inline int SCREEN = 20;
+ inline string CLEAR = "'$clearstr'";
+
+ /* variables */
+ dtrace:::BEGIN
+ {
+ secs = INTERVAL;
+ counts = COUNTER;
+ printf("Tracing... Please wait.\n");
+ }
+
+ /* record syscall event */
+ syscall:::entry
+ {
+ @Name[probefunc] = count();
+ @Total = count();
+ }
+
+ /* timer */
+ profile:::tick-1sec
+ {
+ secs--;
+ }
+
+ /* update screen */
+ profile:::tick-1sec
+ /secs == 0/
+ {
+ /* 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;
+
+ /* clear screen */
+ OPT_clear ? printf("%s", CLEAR) : 1;
+
+ /* print load average */
+ printf("%Y, load average: %d.%02d, %d.%02d, %d.%02d",
+ walltimestamp, this->load1a, this->load1b, this->load5a,
+ this->load5b, this->load15a, this->load15b);
+
+ /* calculate per second values if needed */
+ OPT_persec ? normalize(@Total, INTERVAL) : 1;
+ OPT_persec ? normalize(@Name, INTERVAL) : 1;
+
+ /* print syscall count */
+ printf(" %s: ", OPT_persec ? "syscalls/s" : "syscalls");
+ printa("%@d\n",@Total);
+
+ /* print report */
+ trunc(@Name, SCREEN);
+ printf("\n %-25s %12s\n", "SYSCALL",
+ OPT_persec ? "COUNT/s" : "COUNT");
+ printa(" %-25s %@12d\n", @Name);
+ printf("\n");
+
+ /* reset variables */
+ trunc(@Name);
+ clear(@Total);
+ secs = INTERVAL;
+ counts--;
+ }
+
+ /*
+ * End of program
+ */
+ profile:::tick-1sec
+ /counts == 0/
+ {
+ exit(0);
+ }
+
+ /*
+ * Cleanup for Ctrl-C
+ */
+ dtrace:::END
+ {
+ trunc(@Name);
+ trunc(@Total);
+ }
+'
+
diff --git a/cddl/contrib/dtracetoolkit/System/uname-a.d b/cddl/contrib/dtracetoolkit/System/uname-a.d
new file mode 100755
index 0000000..7775021
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/System/uname-a.d
@@ -0,0 +1,53 @@
+#!/usr/sbin/dtrace -s
+/*
+ * uname-a.d - "uname -a" demo in DTrace.
+ * Written using DTrace (Solaris 10 3/05).
+ *
+ * This has been written to demonstrate fetching the "uname -a" info
+ * from a DTrace script, which turns out to be all kernel variables.
+ * This is intended as a starting point for other DTrace scripts, by
+ * beginning with familiar statistics.
+ *
+ * $Id: uname-a.d 3 2007-08-01 10:50:08Z brendan $
+ *
+ * USAGE: uname-a.d
+ *
+ * FIELDS: See uname(1) manpage for documentation.
+ *
+ * SEE ALSO: uname
+ *
+ * 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.
+ *
+ * 24-Jul-2005 Brendan Gregg Created this.
+ * 24-Jul-2005 " " Last update.
+ */
+
+#pragma D option quiet
+#pragma D option bufsize=8k
+
+/* print system info */
+dtrace:::BEGIN
+{
+ printf("%s %s %s %s %s %s %s",
+ `utsname.sysname,
+ `utsname.nodename,
+ `utsname.release,
+ `utsname.version,
+ `utsname.machine,
+ `architecture,
+ `platform);
+
+ exit(0);
+}
OpenPOWER on IntegriCloud