Finish editorial review of DTrace chapter.

Add an explanatory paragraph for probes.
This chapter still needs a section on userland DTrace.

Sponsored by:	iXsystems
This commit is contained in:
Dru Lavigne 2014-04-16 14:01:55 +00:00
parent b10bacfc10
commit 928e8d3ee1
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=44576

View file

@ -215,25 +215,43 @@ options DEBUG=-g</programlisting>
<sect1 xml:id="dtrace-using">
<title>Using &dtrace;</title>
<para>&dtrace; scripts consist of a list of one or more
<firstterm>probes</firstterm>, or instrumentation points, where
each probe is associated with an action. Whenever the condition
for a probe is met, the associated action is executed. For
example, an action may occur when a file is opened, a process is
started, or a line of code is executed. The action might be to
log some information or to modify context variables. The
reading and writing of context variables allows probes to share
information and to cooperatively analyze the correlation of
different events.</para>
<para>To view all probes, the administrator can execute the
following command:</para>
<screen>&prompt.root; <userinput>dtrace -l | more</userinput></screen>
<para>This section demonstrates how to use two of the fully supported scripts from the
<para>Each probe has an <literal>ID</literal>, a
<literal>PROVIDER</literal> (dtrace or fbt), a
<literal>MODULE</literal>, and a
<literal>FUNCTION NAME</literal>. Refer to &man.dtrace.1; for
more information about this command.</para>
<para>The examples in this section provide an overview of how to
use two of the fully supported scripts from the
&dtrace; Toolkit: the
<filename>hotkernel</filename> and
<filename>procsystime</filename> scripts.</para>
<para>The <filename>hotkernel</filename> script is designed to identify
which function is using the most kernel time. Run normally, it
which function is using the most kernel time. It
will produce output similar to the following:</para>
<screen>&prompt.root; <userinput>cd /usr/share/dtrace/toolkit</userinput>
&prompt.root; <userinput>./hotkernel</userinput>
Sampling... Hit Ctrl-C to end.</screen>
<para>The system administrator must use the
<para>As instructed, use the
<keycombo action="simul"><keycap>Ctrl</keycap><keycap>C</keycap>
</keycombo> key combination to stop the process. Upon
termination, the script will display a list of kernel functions
@ -272,8 +290,7 @@ kernel`sched_idletd 137 0.3%
how we should look that up. -->
<para>This script will also work with kernel modules. To use this
feature, run the script with the <option>-m</option>
flag:</para>
feature, run the script with <option>-m</option>:</para>
<screen>&prompt.root; <userinput>./hotkernel -m</userinput>
Sampling... Hit Ctrl-C to end.
@ -297,10 +314,10 @@ kernel 874 0.4%
seriously obvious. It is 5AM btw. -->
<para>The <filename>procsystime</filename> script captures and
prints the system call time usage for a given
<acronym>PID</acronym> or process name. In the following
prints the system call time usage for a given process <acronym>ID</acronym>
(<acronym>PID</acronym>) or process name. In the following
example, a new instance of <filename>/bin/csh</filename> was
spawned. The <filename>procsystime</filename> was executed and
spawned. Then, <filename>procsystime</filename> was executed and
remained waiting while a few commands were typed on the other
incarnation of <command>csh</command>. These are the results of
this test:</para>
@ -331,8 +348,8 @@ Elapsed Times for processes csh,
sigsuspend 6985124
read 3988049784</screen>
<para>As shown, the <function>read()</function> system call seems
to use the most time in nanoseconds with the
<para>As shown, the <function>read()</function> system call
used the most time in nanoseconds while the
<function>getpid()</function> system call used the least amount
of time.</para>
</sect1>