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"> <sect1 xml:id="dtrace-using">
<title>Using &dtrace;</title> <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 <para>To view all probes, the administrator can execute the
following command:</para> following command:</para>
<screen>&prompt.root; <userinput>dtrace -l | more</userinput></screen> <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 &dtrace; Toolkit: the
<filename>hotkernel</filename> and <filename>hotkernel</filename> and
<filename>procsystime</filename> scripts.</para> <filename>procsystime</filename> scripts.</para>
<para>The <filename>hotkernel</filename> script is designed to identify <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> will produce output similar to the following:</para>
<screen>&prompt.root; <userinput>cd /usr/share/dtrace/toolkit</userinput> <screen>&prompt.root; <userinput>cd /usr/share/dtrace/toolkit</userinput>
&prompt.root; <userinput>./hotkernel</userinput> &prompt.root; <userinput>./hotkernel</userinput>
Sampling... Hit Ctrl-C to end.</screen> 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 action="simul"><keycap>Ctrl</keycap><keycap>C</keycap>
</keycombo> key combination to stop the process. Upon </keycombo> key combination to stop the process. Upon
termination, the script will display a list of kernel functions 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. --> how we should look that up. -->
<para>This script will also work with kernel modules. To use this <para>This script will also work with kernel modules. To use this
feature, run the script with the <option>-m</option> feature, run the script with <option>-m</option>:</para>
flag:</para>
<screen>&prompt.root; <userinput>./hotkernel -m</userinput> <screen>&prompt.root; <userinput>./hotkernel -m</userinput>
Sampling... Hit Ctrl-C to end. Sampling... Hit Ctrl-C to end.
@ -297,10 +314,10 @@ kernel 874 0.4%
seriously obvious. It is 5AM btw. --> seriously obvious. It is 5AM btw. -->
<para>The <filename>procsystime</filename> script captures and <para>The <filename>procsystime</filename> script captures and
prints the system call time usage for a given prints the system call time usage for a given process <acronym>ID</acronym>
<acronym>PID</acronym> or process name. In the following (<acronym>PID</acronym>) or process name. In the following
example, a new instance of <filename>/bin/csh</filename> was 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 remained waiting while a few commands were typed on the other
incarnation of <command>csh</command>. These are the results of incarnation of <command>csh</command>. These are the results of
this test:</para> this test:</para>
@ -331,8 +348,8 @@ Elapsed Times for processes csh,
sigsuspend 6985124 sigsuspend 6985124
read 3988049784</screen> read 3988049784</screen>
<para>As shown, the <function>read()</function> system call seems <para>As shown, the <function>read()</function> system call
to use the most time in nanoseconds with the used the most time in nanoseconds while the
<function>getpid()</function> system call used the least amount <function>getpid()</function> system call used the least amount
of time.</para> of time.</para>
</sect1> </sect1>