| Solaris |
|
|
Author: Sowmini Varadhan
Dtrace is a handy tool for debugging some types of networking problems esp. in the kernel, and this cookbook will attempt to provide a quick tour of dtrace, what it can/can't do, and a collection of handy networking specific scripts of varying complexity. The objective is to provide a repository of scripts that can be borrowed from, or built upon, by someone in the middle of a nasty network bug, who's thinking "Gee, I wish I could find out what's happening here but I don't have the time to take a Dtrace class!"
Note that the scripts included here are mostly intended to be used as sources for cut/paste templates for solving other problems, rather than as complete "cure-all" examples of their own.
Contributions of all shapes, sizes and complexity to the repository are welcome! Please send mail to Sowmini with any input!
Here are some useful links to other documentation:
How do I use DTrace? You will probably either use DTrace scripts or write DTrace scripts:
Use DTrace scripts
Write DTrace Scripts
Some people will write their own customised DTrace scripts to troubleshoot faults or solve performance issues.
To get started writing your own scripts:
Note: Many of the DTrace scripts on this site have been wrapped in the Bourne shell or Perl to provide command line options. In the future, DTrace may may be directly capable of optional arguments. In the meantime this code has been written in such a way that future conversion to pure DTrace is easy.
Several dtrace one-liners are available at usres.tpg.com.au
In addition a tarball of Dscripts of varying complexity (detailed descriptions follow) may be found here
bge_send.d - count packets sent in bge_send, and the fails. Can easily be modified to count packets of a particular type (like ip proto etc.)
arp_lookup.d - print out ipv4 address that we are trying to lookup in arp.
arp_snoop.d prints stack trace and packet layout (in snoop-like format) of packets intercepted in ar_rput().
break_in_kmdb.html - demonstrates how to get dscripts to stop in kmdb.
ctx.d - watch for context switching during sendto() calls using pswitch probe.
udp.d - use UDP MIB provider to show udp stats once per second.
ip_reass.d - track fragmented ip packets; has a user-friendly output of 32 bit ip addresses..
unknown_proto.d is a dtrace script to print out the identity of "unknown IP protocol" packets -- the things bumping up the ipInUnknownProtos MIB/netstat counter.
e1000g.d - count e1000g driver calls, time the expensive CleanTxInterrupts() function; Demonstrates use of Aggregations ("@").
ce.d.html - measure the service time in the arp module with ce driver.
jitter.d - Measure time spent in sendto, recvfrom, looking for "jitter", or long pauses; jitter2.d refines jitter.d by using speculate()
trace_nce_res_mp.d is a simple template that can be customized to help pick out a particular packet at critical functions (dblk_free, in this example) in the stack.
prof.d - Profile the kernel looking for high system time; demonstrates how to use the profile provider with aggregations. prof2.d and prof3.d are refinements of prof.d..
The Sun Studio Compiler also supports the er_kernel tool for profiling the Solaris kernel. er_kernel can collect data using either of two drivers: DTrace, for Solaris 10, which will be externally available, and an no-ship loadable driver, kpcsdrv, available for Solaris 8, 9, or 10. The DTrace driver is the default; the kpcsdrv driver is accessed when the first argument to er_kernel is -X.
A wealth of information about this tool is available at the following locations:
There are some examples of scripts to watch connections at the dtrace discussions (http://www.open solaris.org/os/community/dtrace/scripts/) site.
zerocopy.d (http://npt.eng/dtrace/zerocopy.d.html//)** - monitors
zerocopy.d - monitors TCP's ZeroCopy feature, shows what happens at different components, e.g. STREAM head, TCP, IP(ill), mblk, etc.
Richard McDougall's Dtrace Scripts
Dtrace is not a good tool for post-mortem analysis. For example, one problem frequently encountered in Networking is the "where did my packet get queued up?" problem posed in this customer's question. Another class of problems encountered is the analysis of the sequence of events that led to a memory leak or reference-count leak after the leak has occurred.
Jim Carlson, Jim Fiori, Darrin Johnson, Alex Peng, Sowmini Varadhan
Retrieved from "http://ctg.central.sun.com/wiki/index.php/Dtrace_Networking_Cookbook"
php/Main_Page
Terms of Use
|
Privacy
|
Trademarks
|
Copyright Policy
|
Site Guidelines
|
Site Map
|
Help
Your use of this web site or any of its content or software indicates your agreement to be bound by these Terms of Use.
© 2012, Oracle Corporation and/or its affiliates.