White space fix only. Translators can ignore.

Sponsored by:	iXsystems
This commit is contained in:
Dru Lavigne 2014-04-15 17:45:54 +00:00
parent a1c9a8f7d4
commit 4ea28ab6bf
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=44565

View file

@ -41,18 +41,18 @@ that might make this chapter too large.
kernel and in userland programs.</para> kernel and in userland programs.</para>
<para>&dtrace; is a remarkable profiling tool, with an impressive <para>&dtrace; is a remarkable profiling tool, with an impressive
array of features for diagnosing system issues. It may also array of features for diagnosing system issues. It may also be
be used to run pre-written scripts to take advantage of its used to run pre-written scripts to take advantage of its
capabilities. Users can author their own utilities using capabilities. Users can author their own utilities using the
the &dtrace; D Language, allowing them to customize their &dtrace; D Language, allowing them to customize their profiling
profiling based on specific needs.</para> based on specific needs.</para>
<para>The &os; implementation in provides full support for kernel <para>The &os; implementation in provides full support for kernel
&dtrace; and experimental &dtrace; and experimental support for userland &dtrace;.
support for userland &dtrace;. Userland &dtrace; allows users to Userland &dtrace; allows users to perform function boundary
perform function boundary tracing for userland programs using tracing for userland programs using the <literal>pid</literal>
the <literal>pid</literal> provider, and to insert static probes provider, and to insert static probes into userland programs for
into userland programs for later tracing. Some ports, such as later tracing. Some ports, such as
<package>databases/postgres-server</package> and <package>databases/postgres-server</package> and
<package>lang/php5</package> have a &dtrace; option to enable <package>lang/php5</package> have a &dtrace; option to enable
static probes. &os; 10.0-RELEASE has reasonably good userland static probes. &os; 10.0-RELEASE has reasonably good userland
@ -85,8 +85,8 @@ that might make this chapter too large.
</listitem> </listitem>
<listitem> <listitem>
<para>Have some familiarity with security and how it <para>Have some familiarity with security and how it pertains
pertains to &os; (<xref linkend="security"/>).</para> to &os; (<xref linkend="security"/>).</para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
</sect1> </sect1>
@ -106,12 +106,12 @@ that might make this chapter too large.
automatically loaded when <command>dtrace</command> is automatically loaded when <command>dtrace</command> is
run.</para> run.</para>
<para>&os; uses the <literal>DDB_CTF</literal> kernel option <para>&os; uses the <literal>DDB_CTF</literal> kernel option to
to enable support for loading <acronym>CTF</acronym> enable support for loading <acronym>CTF</acronym> data from
data from kernel modules and the kernel itself. kernel modules and the kernel itself. <acronym>CTF</acronym> is
<acronym>CTF</acronym> is the &solaris; Compact C Type Format the &solaris; Compact C Type Format which encapsulates a reduced
which encapsulates a reduced form of debugging information form of debugging information similar to
similar to <acronym>DWARF</acronym> and the venerable stabs. <acronym>DWARF</acronym> and the venerable stabs.
<acronym>CTF</acronym> data is added to binaries by the <acronym>CTF</acronym> data is added to binaries by the
<command>ctfconvert</command> and <command>ctfmerge</command> <command>ctfconvert</command> and <command>ctfmerge</command>
build tools. The <command>ctfconvert</command> utility parses build tools. The <command>ctfconvert</command> utility parses
@ -122,8 +122,8 @@ that might make this chapter too large.
<para>Some different providers exist for &os; than for &solaris;. <para>Some different providers exist for &os; than for &solaris;.
Most notable is the <literal>dtmalloc</literal> provider, which Most notable is the <literal>dtmalloc</literal> provider, which
allows tracing <function>malloc()</function> by type in the allows tracing <function>malloc()</function> by type in the &os;
&os; kernel. Some of the providers found in &solaris;, such as kernel. Some of the providers found in &solaris;, such as
<literal>cpc</literal> and <literal>mib</literal>, are not <literal>cpc</literal> and <literal>mib</literal>, are not
present in &os;. These may appear in future versions of &os;. present in &os;. These may appear in future versions of &os;.
Moreover, some of the providers available in both operating Moreover, some of the providers available in both operating
@ -139,9 +139,9 @@ that might make this chapter too large.
<filename>/dev/dtrace/dtrace</filename> is strictly limited to <filename>/dev/dtrace/dtrace</filename> is strictly limited to
<systemitem class="username">root</systemitem>.</para> <systemitem class="username">root</systemitem>.</para>
<para>&dtrace; falls under the Common Development and <para>&dtrace; falls under the Common Development and Distribution
Distribution License (<acronym>CDDL</acronym>) license. To view License (<acronym>CDDL</acronym>) license. To view this license
this license on &os;, see on &os;, see
<filename>/usr/src/cddl/contrib/opensolaris/OPENSOLARIS.LICENSE</filename> <filename>/usr/src/cddl/contrib/opensolaris/OPENSOLARIS.LICENSE</filename>
or view it online at <uri or view it online at <uri
xlink:href="http://www.opensolaris.org/os/licensing">http://www.opensolaris.org/os/licensing</uri>. xlink:href="http://www.opensolaris.org/os/licensing">http://www.opensolaris.org/os/licensing</uri>.
@ -164,78 +164,73 @@ that might make this chapter too large.
<programlisting>options KDTRACE_HOOKS <programlisting>options KDTRACE_HOOKS
options DDB_CTF</programlisting> options DDB_CTF</programlisting>
<para>Users of the AMD64 architecture should also add this <para>Users of the AMD64 architecture should also add this
line:</para> line:</para>
<programlisting>options KDTRACE_FRAME</programlisting> <programlisting>options KDTRACE_FRAME</programlisting>
<para>This option provides support for <para>This option provides support for <acronym>FBT</acronym>.
<acronym>FBT</acronym>. While &dtrace; will work without While &dtrace; will work without this option, there will be
this option, there will be limited support for limited support for function boundary tracing.</para>
function boundary tracing.</para>
<para>Once the &os; system has rebooted into the new kernel, or <para>Once the &os; system has rebooted into the new kernel, or
the &dtrace; kernel modules have been loaded using the &dtrace; kernel modules have been loaded using
<command>kldload dtraceall</command>, the system will <command>kldload dtraceall</command>, the system will have
have support for the Korn shell. This support for the Korn shell. This is needed as the &dtrace;
is needed as the &dtrace; Toolkit has several utilities written Toolkit has several utilities written in <command>ksh</command>.
in <command>ksh</command>. Make sure that the Make sure that the <package>shells/ksh93</package> package or
<package>shells/ksh93</package> package or port is installed. port is installed. It is also possible to run these tools under
It is also
possible to run these tools under
<package>shells/pdksh</package> or <package>shells/pdksh</package> or
<package>shells/mksh</package>.</para> <package>shells/mksh</package>.</para>
<para>Finally, obtain the current &dtrace; Toolkit. <para>Finally, obtain the current &dtrace; Toolkit. FreeBSD 10
FreeBSD 10 includes the &dtrace; Toolkit includes the &dtrace; Toolkit in
in <filename>/usr/share/dtrace</filename>. <filename>/usr/share/dtrace</filename>. Otherwise, install the
Otherwise, install the &dtrace; Toolkit using the &dtrace; Toolkit using the
<package>sysutils/DTraceToolkit</package> package or <package>sysutils/DTraceToolkit</package> package or
port.</para> port.</para>
<para>The &dtrace; Toolkit includes many scripts in the special <para>The &dtrace; Toolkit includes many scripts in the special
language of &dtrace;. This language is called the D language of &dtrace;. This language is called the D language
language and it is very similar and it is very similar to C++. An in depth discussion of the
to C++. An in depth discussion of the language is beyond the language is beyond the scope of this document. It is
scope of this document. It is extensively discussed at <uri extensively discussed at <uri
xlink:href="http://wikis.oracle.com/display/DTrace/Documentation">http://wikis.oracle.com/display/DTrace/Documentation</uri>.</para> xlink:href="http://wikis.oracle.com/display/DTrace/Documentation">http://wikis.oracle.com/display/DTrace/Documentation</uri>.</para>
</sect1> </sect1>
<sect1 xml:id="dtrace-using"> <sect1 xml:id="dtrace-using">
<title>Using &dtrace;</title> <title>Using &dtrace;</title>
<para>To view all <para>To view all probes, the administrator can execute the
probes, the administrator can execute the following following command:</para>
command:</para>
<screen>&prompt.root; <userinput>dtrace -l | more</userinput></screen> <screen>&prompt.root; <userinput>dtrace -l | more</userinput></screen>
<para>The &dtrace; Toolkit is a collection of ready-made scripts <para>The &dtrace; Toolkit is a collection of ready-made scripts
for collecting system information. There are scripts for collecting system information. There are scripts to check
to check open files, memory, <acronym>CPU</acronym> usage, and open files, memory, <acronym>CPU</acronym> usage, and a lot
a lot more. Extract the scripts with the following more. Extract the scripts with the following command:</para>
command:</para>
<screen>&prompt.root; <userinput>gunzip -c DTraceToolkit* | tar xvf -</userinput></screen> <screen>&prompt.root; <userinput>gunzip -c DTraceToolkit* | tar xvf -</userinput></screen>
<para>Change into that directory with the <command>cd</command> <para>Change into that directory with the <command>cd</command>
and change the execution permissions on all files, designated and change the execution permissions on all files, designated as
as those files with lower case names, to those files with lower case names, to
<literal>755</literal>.</para> <literal>755</literal>.</para>
<para>All of these scripts will need modifications to their <para>All of these scripts will need modifications to their
contents. The ones which refer to contents. The ones which refer to
<filename>/usr/bin/ksh</filename> need that changed to <filename>/usr/bin/ksh</filename> need that changed to
<filename>/usr/local/bin/ksh</filename>, the others which <filename>/usr/local/bin/ksh</filename>, the others which use
use <filename>/usr/bin/sh</filename> need to be altered to use <filename>/usr/bin/sh</filename> need to be altered to use
<filename>/bin/sh</filename>, and finally the ones which <filename>/bin/sh</filename>, and finally the ones which use
use <filename>/usr/bin/perl</filename> will need altered to <filename>/usr/bin/perl</filename> will need altered to use
use <filename>/usr/local/bin/perl</filename>.</para> <filename>/usr/local/bin/perl</filename>.</para>
<para>At the time of this writing only two of the scripts of the <para>At the time of this writing only two of the scripts of the
&dtrace; Toolkit are fully supported in &os;: &dtrace; Toolkit are fully supported in &os;: the
the <filename>hotkernel</filename> <filename>hotkernel</filename> and
and <filename>procsystime</filename> scripts. These are the two <filename>procsystime</filename> scripts. These are the two
we will explore in the following parts of this section.</para> we will explore in the following parts of this section.</para>
<para>The <filename>hotkernel</filename> is designed to identify <para>The <filename>hotkernel</filename> is designed to identify
@ -312,11 +307,11 @@ kernel 874 0.4%
<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
<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> example, a new instance of <filename>/bin/csh</filename> was
was spawned. The <filename>procsystime</filename> was executed spawned. The <filename>procsystime</filename> was executed and
and remained waiting while a few commands were typed on the remained waiting while a few commands were typed on the other
other incarnation of <command>csh</command>. These are the incarnation of <command>csh</command>. These are the results of
results of this test:</para> this test:</para>
<screen>&prompt.root; <userinput>./procsystime -n csh</userinput> <screen>&prompt.root; <userinput>./procsystime -n csh</userinput>
Tracing... Hit Ctrl-C to end... Tracing... Hit Ctrl-C to end...
@ -344,8 +339,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 <para>As shown, the <function>read()</function> system call seems
seems to use the most time in nanoseconds with the to use the most time in nanoseconds with 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>