<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Solaris 10: tips and tricks for system administration - DTrace</title>
    <link>http://solaris.reys.net/english</link>
    <description>How to use DTrace, ZFS, Solaris Zones and other technologies in Solaris</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.1-alpha7 - http://www.s9y.org/</generator>
    
    

<item>
    <title>Announcing a new website: DTrace Scripts</title>
    <link>http://solaris.reys.net/english/2007/11/dtrace-scripts-website</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2007/11/dtrace-scripts-website#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=165</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=165</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    Thanks to &lt;a href=http://www.curthread.org&gt;CurThread.org&lt;/a&gt;, I&#039;ve recently learned about the new online project which just got started: &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=982&amp;amp;entry_id=165&quot;  onmouseover=&quot;window.status=&#039;http://www.dtracescripts.com/&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;  title=&quot;DTrace Scripts&quot;&gt;DTrace Scripts&lt;/a&gt;. It seems to be a promising project with a constantly expanding collection of DTrace scripts and tips, and it&#039;s great to see yet another project aimed at making DTrace more accessible and better known in Unix communities. 
    </content:encoded>

    <pubDate>Fri, 09 Nov 2007 14:53:56 +0300</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2007/11/dtrace-scripts-website</guid>
    <category>dtrace</category>
<category>scripts</category>
<category>website</category>
<category>dtrace</category>
<category>scripts</category>
<category>website</category>

</item>
<item>
    <title>Another good article on DTrace</title>
    <link>http://solaris.reys.net/english/2006/02/dtrace_article</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2006/02/dtrace_article#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=107</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=107</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    Thanks to &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=880&amp;amp;entry_id=107&quot; title=&quot;http://blogs.sun.com/ahl&quot;  onmouseover=&quot;window.status=&#039;http://blogs.sun.com/ahl&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Adam Leventhal&lt;/a&gt;, who is one of &lt;b&gt;DTrace&lt;/b&gt; authors, I&#039;ve learned about the recent article on &lt;b&gt;DTrace&lt;/b&gt; by &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=881&amp;amp;entry_id=107&quot; title=&quot;http://blogs.sun.com/bmc&quot;  onmouseover=&quot;window.status=&#039;http://blogs.sun.com/bmc&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Bryan Cantrill&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
I liked this article a lot, so it&#039;s been immediately added to my &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=882&amp;amp;entry_id=107&quot; title=&quot;http://solaris.reys.net/dtrace&quot;  onmouseover=&quot;window.status=&#039;http://solaris.reys.net/dtrace&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Useful DTrace resources&lt;/a&gt; index.&lt;br /&gt;
&lt;br /&gt;
You can read the article by following this link: &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=883&amp;amp;entry_id=107&quot; title=&quot;http://www.acmqueue.org/modules.php?name=Content&amp;amp;pa=showpage&amp;amp;pid=361&quot;  onmouseover=&quot;window.status=&#039;http://www.acmqueue.org/modules.php?name=Content&amp;amp;pa=showpage&amp;amp;pid=361&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Hidden in Plain Sight&lt;/a&gt; 
    </content:encoded>

    <pubDate>Wed, 08 Feb 2006 16:32:11 +0300</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2006/02/dtrace_article</guid>
    <category>article</category>
<category>dtrace</category>
<category>article</category>
<category>dtrace</category>

</item>
<item>
    <title>Useful resources on DTrace</title>
    <link>http://solaris.reys.net/english/2006/01/dtrace_useful_resources</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2006/01/dtrace_useful_resources#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=102</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=102</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    I&#039;ve finally found time to start yet another good tradition on my blog. From now on, I&#039;ll maintain an index of links to all my articles on DTrace, which will also include links to all other resources on DTrace I&#039;ve found useful.&lt;br /&gt;
&lt;br /&gt;
This link repositary can be found at the following URL: &lt;a href=&quot;http://solaris.reys.net/exit.php?url=aHR0cDovL3NvbGFyaXMucmV5cy5uZXQvZW5nbGlzaC9kdHJhY2U=&amp;amp;entry_id=102&quot; title=&quot;http://solaris.reys.net/english/dtrace&quot;  onmouseover=&quot;window.status=&#039;http://solaris.reys.net/english/dtrace&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;http://solaris.reys.net/english/dtrace&lt;/a&gt; 
    </content:encoded>

    <pubDate>Fri, 27 Jan 2006 13:06:14 +0300</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2006/01/dtrace_useful_resources</guid>
    <category>dtrace</category>
<category>opensolaris</category>
<category>solaris 10</category>
<category>dtrace</category>
<category>opensolaris</category>
<category>solaris 10</category>

</item>
<item>
    <title>DTrace: playing with mod_auth_pam and Apache 2</title>
    <link>http://solaris.reys.net/english/2005/12/dtrace_mod_auth_pam</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2005/12/dtrace_mod_auth_pam#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=99</wfw:comment>

    <slash:comments>12</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=99</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    One of our users has asked me to help with &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=609&amp;amp;entry_id=99&quot; title=&quot;http://www.sun.com/software/solaris/pam/&quot;  onmouseover=&quot;window.status=&#039;http://www.sun.com/software/solaris/pam/&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;PAM&lt;/a&gt; authentication for &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=610&amp;amp;entry_id=99&quot; title=&quot;http://httpd.apache.org/&quot;  onmouseover=&quot;window.status=&#039;http://httpd.apache.org/&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Apache 2&lt;/a&gt; on one of our remote servers.&lt;br /&gt;
&lt;br /&gt;
It did seem like a rather trivial task - download &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=611&amp;amp;entry_id=99&quot; title=&quot;http://pam.sourceforge.net/mod_auth_pam/&quot;  onmouseover=&quot;window.status=&#039;http://pam.sourceforge.net/mod_auth_pam/&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;mod_auth_pam&lt;/a&gt;, compile it for Apache 2, make sure everything works. The remote server uses NIS, I could freely log onto it.&lt;br /&gt;
&lt;br /&gt;
And you know what? It didn&#039;t work. The module compiled pretty easy, but I couldn&#039;t get it to work - error_log was reporting the same lines over and over again (I had to break the line to squeeze it into my blog format):&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#91;Tue&amp;#160;Dec&amp;#160;20&amp;#160;16&amp;#58;48&amp;#58;44&amp;#160;2005&amp;#93;&amp;#160;&amp;#91;error&amp;#93;&amp;#160;&amp;#91;client&amp;#160;xxx.xxx.xxx.xxx&amp;#93;&amp;#160;&amp;#160;\&lt;br /&gt;
PAM&amp;#58;&amp;#160;user&amp;#160;&#039;greys&#039;&amp;#160;-&amp;#160;not&amp;#160;authenticated&amp;#58;&amp;#160;No&amp;#160;account&amp;#160;present&amp;#160;for&amp;#160;user&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Up to this point, everything was done by the user himself with small help from me. At this stage is was decided I&#039;d have a look myself. To make things easier, I also wanted to:&lt;br /&gt;
&lt;br /&gt;
1) Move all the experiments onto my own Solaris 10 box&lt;br /&gt;
2) Make it all work for local users first, and only then get NIS working as well&lt;br /&gt;
&lt;br /&gt;
Seeing the same errors on my box, I&#039;ve decided to take a serious look at PAM. I&#039;ve created Apache-related lines in &lt;b&gt;/etc/pam.conf&lt;/b&gt; and added a &lt;b&gt;debug&lt;/b&gt; option:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;httpd&amp;#160;&amp;#160;auth&amp;#160;required&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;pam_authtok_get.so.1&amp;#160;debug&lt;br /&gt;
httpd&amp;#160;&amp;#160;auth&amp;#160;required&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;pam_unix_auth.so.1&amp;#160;debug&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
To make it more convenient to track all the messages, I&#039;ve updated &lt;b&gt;/etc/syslog.conf&lt;/b&gt; to include the following:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;auth.debug&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/var/log/auth_log&lt;br /&gt;
user.debug&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/var/log/user_log&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
It got easier to see what was happening, at least I knew it was the &lt;b&gt;/etc/pam.conf&lt;/b&gt; section I was thinking of. But the error was still there - my user definitely did exist in the system, only it wouldn&#039;t be recognized by Apache (and I&#039;ve broken the lines yet again here):&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;Dec&amp;#160;21&amp;#160;09&amp;#58;47&amp;#58;35&amp;#160;pele&amp;#160;httpd&amp;#91;29143&amp;#93;&amp;#58;&amp;#160;&amp;#91;ID&amp;#160;634615&amp;#160;user.debug&amp;#93;&amp;#160;\&lt;br /&gt;
pam_authtok_get&amp;#58;pam_sm_authenticate&amp;#58;&amp;#160;flags&amp;#160;=&amp;#160;1&lt;br /&gt;
Dec&amp;#160;21&amp;#160;09&amp;#58;47&amp;#58;35&amp;#160;pele&amp;#160;httpd&amp;#91;29143&amp;#93;&amp;#58;&amp;#160;&amp;#91;ID&amp;#160;378613&amp;#160;user.debug&amp;#93;&amp;#160;\&lt;br /&gt;
pam_dhkeys&amp;#58;&amp;#160;user&amp;#160;greys&amp;#160;not&amp;#160;found&lt;br /&gt;
Dec&amp;#160;21&amp;#160;09&amp;#58;47&amp;#58;35&amp;#160;pele&amp;#160;httpd&amp;#91;29143&amp;#93;&amp;#58;&amp;#160;&amp;#91;ID&amp;#160;896952&amp;#160;user.debug&amp;#93;&amp;#160;\&lt;br /&gt;
pam_unix_auth&amp;#58;&amp;#160;entering&amp;#160;pam_sm_authenticate&amp;#40;&amp;#41;&lt;br /&gt;
Dec&amp;#160;21&amp;#160;09&amp;#58;47&amp;#58;35&amp;#160;pele&amp;#160;httpd&amp;#91;29143&amp;#93;&amp;#58;&amp;#160;&amp;#91;ID&amp;#160;219349&amp;#160;user.debug&amp;#93;&amp;#160;\&lt;br /&gt;
pam_unix_auth&amp;#58;&amp;#160;user&amp;#160;greys&amp;#160;not&amp;#160;found&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
It was the right time to look at how exactly PAM and Apache 2 interacted when I was giving the username and password trying to access my page. I immediately thought of Brendan Gregg&#039;s &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=612&amp;amp;entry_id=99&quot; title=&quot;http://users.tpg.com.au/adsln4yb/DTrace/opensnoop&quot;  onmouseover=&quot;window.status=&#039;http://users.tpg.com.au/adsln4yb/DTrace/opensnoop&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;opensnoop&lt;/a&gt; script for DTrace. And it was this script indeed which helped me see the problem:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;-1&amp;#160;&amp;#160;&amp;#160;2&amp;#160;/etc/pam_debug&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/etc/pam.conf&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/usr/lib/security/pam_authtok_get.so.1&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/usr/lib/passwdutil.so.1&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/usr/lib/libsldap.so.1&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/usr/lib/security/pam_dhkeys.so.1&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/usr/lib/security/pam_unix_cred.so.1&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/lib/libbsm.so.1&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/lib/libsecdb.so.1&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/usr/lib/libproject.so.1&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/lib/libproc.so.1&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/lib/librtld_db.so.1&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/lib/libelf.so.1&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/lib/libctf.so.1&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/usr/lib/security/pam_unix_auth.so.1&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;-1&amp;#160;&amp;#160;&amp;#160;2&amp;#160;/var/run/syslog_door&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;-1&amp;#160;&amp;#160;13&amp;#160;/etc/shadow&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/var/run/name_service_door&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;11&amp;#160;&amp;#160;&amp;#160;0&amp;#160;/etc/passwd&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;-1&amp;#160;&amp;#160;13&amp;#160;/etc/shadow&lt;br /&gt;
60001&amp;#160;24744&amp;#160;httpd&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;-1&amp;#160;&amp;#160;&amp;#160;2&amp;#160;/var/run/syslog_door&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Apparently, &lt;b&gt;httpd&lt;/b&gt; could not open &lt;b&gt;/etc/shadow&lt;/b&gt; (-1 means error), obviously becase of permissions for the file. But just to make sure, I&#039;ve looked for the error code (it&#039;s 13 as you can see):&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;bash-3.00#&amp;#160;grep&amp;#160;13&amp;#160;/usr/include/sys/errno.h&lt;br /&gt;
#define&amp;#160;EACCES&amp;#160;&amp;#160;13&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;/&amp;#42;&amp;#160;Permission&amp;#160;denied&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#42;/&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
So it all was suddenly clear, and I&#039;ve proceeded like this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#groupadd&amp;#160;shadows&lt;br /&gt;
#&amp;#160;chown&amp;#160;root&amp;#58;shadows&amp;#160;/etc/shadow&lt;br /&gt;
#&amp;#160;chmod&amp;#160;440&amp;#160;/etc/shadow&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
All that&#039;s left to be done now was to make sure &lt;b&gt;httpd.conf&lt;/b&gt; has a &lt;b&gt;Group&lt;/b&gt; parameter set to this &lt;b&gt;shadows&lt;/b&gt; group, and not nobody.&lt;br /&gt;
&lt;br /&gt;
pS: you might ask why didn&#039;t it work for NIS on the remote server in first place. This is because &lt;b&gt;/etc/nsswitch.conf&lt;/b&gt; had not this: &lt;b&gt;passwd: files nis&lt;/b&gt;, but this: &lt;b&gt;passwd: compat&lt;/b&gt;, so NIS maps were consulted, but only based on + and - specifications in &lt;b&gt;/etc/passwd&lt;/b&gt; and &lt;b&gt;/etc/shadow&lt;/b&gt; files. This means we still needed to be able to read &lt;b&gt;/etc/shadow&lt;/b&gt;, even though later PAM would consult NIS. 
    </content:encoded>

    <pubDate>Wed, 21 Dec 2005 13:29:25 +0300</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2005/12/dtrace_mod_auth_pam</guid>
    <category>apache2</category>
<category>dtrace</category>
<category>solaris</category>
<category>apache2</category>
<category>dtrace</category>
<category>solaris</category>

</item>
<item>
    <title>DTrace: observing PHP, part 2</title>
    <link>http://solaris.reys.net/english/2005/12/dtrace_php_scripts_timer</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2005/12/dtrace_php_scripts_timer#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=98</wfw:comment>

    <slash:comments>2</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=98</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    Your next step in observing PHP with DTrace could easily be the following script. It times how much time (in nanoseconds) each Apache process has spent running a particular PHP function.&lt;br /&gt;
&lt;br /&gt;
This script generates a table of Apache PIDs and PHP scripts started within, and later you&#039;ll get a table of all the functions with PIDs which ran them and the time spent.&lt;br /&gt;
&lt;br /&gt;
You can download this script here: &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=580&amp;amp;entry_id=98&quot; title=&quot;http://solaris.reys.net/scripts/php-scripts-timer.d&quot;  onmouseover=&quot;window.status=&#039;http://solaris.reys.net/scripts/php-scripts-timer.d&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;php-scripts-timer.d&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
#pragma&amp;#160;D&amp;#160;option&amp;#160;quiet&lt;br /&gt;
&lt;br /&gt;
BEGIN&lt;br /&gt;
{&lt;br /&gt;
printf&amp;#40;&quot;php&amp;#160;scripts&amp;#160;timer&amp;#160;started\n&quot;&amp;#41;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;#58;dtrace.so&amp;#58;&amp;#58;function-entry&lt;br /&gt;
/&amp;#160;copyinstr&amp;#40;arg0&amp;#41;&amp;#160;==&amp;#160;&quot;&quot;&amp;#160;&amp;amp;&amp;amp;&amp;#160;name&amp;#91;pid,copyinstr&amp;#40;arg1&amp;#41;&amp;#93;&amp;#160;!=&amp;#160;1&amp;#160;/&lt;br /&gt;
{&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;printf&amp;#40;&quot;%d&amp;#160;-&amp;#62;&amp;#160;%-30s\n&quot;,&amp;#160;pid,&amp;#160;copyinstr&amp;#40;arg1&amp;#41;&amp;#41;;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;name&amp;#91;pid,copyinstr&amp;#40;arg1&amp;#41;&amp;#93;&amp;#160;=&amp;#160;1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;#58;dtrace.so&amp;#58;&amp;#58;function-entry&lt;br /&gt;
/&amp;#160;copyinstr&amp;#40;arg0&amp;#41;&amp;#160;!=&amp;#160;&quot;&quot;&amp;#160;/&lt;br /&gt;
{&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;self-&amp;#62;ts&amp;#160;=&amp;#160;timestamp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;#58;dtrace.so&amp;#58;&amp;#58;function-return&lt;br /&gt;
/&amp;#160;copyinstr&amp;#40;arg0&amp;#41;&amp;#160;!=&amp;#160;&quot;&quot;&amp;#160;/&lt;br /&gt;
{&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;self-&amp;#62;elapsed&amp;#160;=&amp;#160;timestamp&amp;#160;-&amp;#160;self-&amp;#62;ts;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;@time&amp;#91;pid,&amp;#160;copyinstr&amp;#40;arg0&amp;#41;&amp;#93;&amp;#160;=&amp;#160;sum&amp;#40;self-&amp;#62;elapsed&amp;#41;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
END&lt;br /&gt;
{&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;printf&amp;#40;&quot;&amp;#60;------&amp;#160;php&amp;#160;scripts&amp;#160;timer&amp;#160;finished&quot;&amp;#41;;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;printf&amp;#40;&quot;\n%10s&amp;#160;%40s&amp;#160;%14s\n&quot;,&amp;#160;&quot;PID&quot;,&amp;#160;&quot;PHP&amp;#160;function&quot;,&amp;#160;&quot;Time&amp;#160;elapsed&quot;&amp;#41;;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;printa&amp;#40;&quot;%10d&amp;#160;%40s&amp;#160;%14@u\n&quot;,&amp;#160;@time&amp;#41;;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
A typical result of running this script while opening some PHP pages served by your Apache will look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;php&amp;#160;scripts&amp;#160;timer&amp;#160;started&lt;br /&gt;
223074&amp;#160;-&amp;#62;&amp;#160;/export/www/nightly/pma/left.php&lt;br /&gt;
223071&amp;#160;-&amp;#62;&amp;#160;/export/www/nightly/pma/main.php&lt;br /&gt;
223074&amp;#160;-&amp;#62;&amp;#160;/export/www/nightly/pma/css/phpmyadmin.css.php&lt;br /&gt;
223071&amp;#160;-&amp;#62;&amp;#160;/export/www/nightly/pma/css/phpmyadmin.css.php&lt;br /&gt;
&lt;br /&gt;
&amp;#60;------&amp;#160;php&amp;#160;scripts&amp;#160;timer&amp;#160;finished&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;PID&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;PHP&amp;#160;function&amp;#160;&amp;#160;&amp;#160;Time&amp;#160;elapsed&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223074&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;ob_get_level&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;22280&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223074&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;get_cfg_var&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;32678&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223074&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;mysql_get_client_info&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;32705&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223074&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;strrpos&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;39160&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223074&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;PMA_auth_set_user&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;39178&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223071&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;get_magic_quotes_gpc&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;39478&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223071&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;ob_get_level&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;43673&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223071&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;addslashes&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;54847&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223074&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;strpos&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;56869&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223071&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;basename&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;61874&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223071&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;PMA_reloadNavigation&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;63588&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223071&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;mysql_get_client_info&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;64570&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223071&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;get_cfg_var&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;64592&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223071&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;ereg_replace&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;65993&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;223074&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;get_magic_quotes_gpc&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;67738&lt;br /&gt;
...&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;234950&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;main&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;84254684&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;238255&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;main&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;105016748&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;238255&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;substr&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;153752861&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;238255&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;mysql_query&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;192585647&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;238255&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;PMA_DBI_try_query&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;195113800&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;234950&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;PMA_DBI_query&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;220108343&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;234950&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;mysql_query&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;276732073&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;234950&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;PMA_DBI_try_query&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;280801228&lt;/div&gt; 
    </content:encoded>

    <pubDate>Tue, 13 Dec 2005 02:16:13 +0300</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2005/12/dtrace_php_scripts_timer</guid>
    <category>dtrace</category>
<category>php</category>
<category>dtrace</category>
<category>php</category>

</item>
<item>
    <title>DTrace: observing PHP</title>
    <link>http://solaris.reys.net/english/2005/12/dtrace_php_scripts_snoop</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2005/12/dtrace_php_scripts_snoop#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=95</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=95</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    I&#039;ve finally got some spare time to download a PEAR module for &lt;a href=http://netevil.org/node.php?nid=413&gt;DTrace&lt;/a&gt;. What a great module! I&#039;ve found a little problem with it, wrote a letter to &lt;a href=http://netevil.org/wiki.php?WezFurlong&gt;Wez Furlong&lt;/a&gt;, and he immediately changed the source code to make it work even better. Thanks a lot, Wez! :)&lt;br /&gt;
&lt;br /&gt;
So, here it is - my first PHP Dtrace script: &lt;a href=http://solaris.reys.net/scripts/php-scripts-snoop.d&gt;php-scripts-snoop.d&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
#pragma&amp;#160;D&amp;#160;option&amp;#160;quiet&lt;br /&gt;
&lt;br /&gt;
&amp;#58;dtrace.so&amp;#58;&amp;#58;function-entry&lt;br /&gt;
/&amp;#160;copyinstr&amp;#40;arg0&amp;#41;&amp;#160;==&amp;#160;&quot;&quot;&amp;#160;/&lt;br /&gt;
{&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;printf&amp;#40;&quot;%d&amp;#160;-&amp;#62;&amp;#160;%-30s\n&quot;,&amp;#160;pid,&amp;#160;copyinstr&amp;#40;arg1&amp;#41;&amp;#41;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;#58;dtrace.so&amp;#58;&amp;#58;function-return&lt;br /&gt;
/&amp;#160;copyinstr&amp;#40;arg0&amp;#41;&amp;#160;==&amp;#160;&quot;&quot;&amp;#160;/&lt;br /&gt;
{&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;printf&amp;#40;&quot;%d&amp;#160;&amp;#60;-&amp;#160;%-30s\n&quot;,&amp;#160;pid,&amp;#160;copyinstr&amp;#40;arg1&amp;#41;&amp;#41;;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
So go ahead, download the script, do &lt;b&gt;chmod a+x&lt;/b&gt; for it, and after you start it in a terminal of your web-server, you can run PHP scripts from this server, and our DTrace script will be reporting us whenever each PHP script stars or finishes, specifying which Apache process is responsible for this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;bash-3.00#&amp;#160;./php-scripts-snoop.d&lt;br /&gt;
204934&amp;#160;-&amp;#62;&amp;#160;/export/www/pma/index.php&lt;br /&gt;
204934&amp;#160;&amp;#60;-&amp;#160;/export/www/pma/index.php&lt;br /&gt;
204934&amp;#160;-&amp;#62;&amp;#160;/export/www/pma/css/phpmyadmin.css.php&lt;br /&gt;
204934&amp;#160;&amp;#60;-&amp;#160;/export/www/pma/css/phpmyadmin.css.php&lt;br /&gt;
204936&amp;#160;-&amp;#62;&amp;#160;/export/www/pma/left.php&lt;br /&gt;
204934&amp;#160;-&amp;#62;&amp;#160;/export/www/pma/queryframe.php&lt;br /&gt;
204936&amp;#160;&amp;#60;-&amp;#160;/export/www/pma/left.php&lt;br /&gt;
204936&amp;#160;-&amp;#62;&amp;#160;/export/www/pma/main.php&lt;br /&gt;
204934&amp;#160;&amp;#60;-&amp;#160;/export/www/pma/queryframe.php&lt;br /&gt;
204934&amp;#160;-&amp;#62;&amp;#160;/export/www/pma/css/phpmyadmin.css.php&lt;br /&gt;
204934&amp;#160;&amp;#60;-&amp;#160;/export/www/pma/css/phpmyadmin.css.php&lt;br /&gt;
204934&amp;#160;-&amp;#62;&amp;#160;/export/www/pma/css/phpmyadmin.css.php&lt;br /&gt;
204936&amp;#160;-&amp;#62;&amp;#160;/export/www/pma/css/phpmyadmin.css.php&lt;br /&gt;
204934&amp;#160;&amp;#60;-&amp;#160;/export/www/pma/css/phpmyadmin.css.php&lt;br /&gt;
204934&amp;#160;-&amp;#62;&amp;#160;/export/www/1.php&lt;br /&gt;
204934&amp;#160;&amp;#60;-&amp;#160;/export/www/1.php&lt;br /&gt;
204936&amp;#160;&amp;#60;-&amp;#160;/export/www/pma/css/phpmyadmin.css.php&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
pS: yes, starting of today I&#039;ve decided to provide download links for each of my scripts - should be more convenient for you now. This means that sooner or later I&#039;ll update all the archive blog entries to have download links for respective scripts. 
    </content:encoded>

    <pubDate>Tue, 06 Dec 2005 20:16:23 +0300</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2005/12/dtrace_php_scripts_snoop</guid>
    <category>dtrace</category>
<category>php</category>
<category>dtrace</category>
<category>php</category>

</item>
<item>
    <title>DTrace: command line parameters in scripting</title>
    <link>http://solaris.reys.net/english/2005/05/dtrace_command_line_parameters</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2005/05/dtrace_command_line_parameters#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=62</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=62</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    When you&#039;re writing a DTrace script, often you&#039;d like to pass some parameter in command line. Such an easy task might be really hard unless you read a &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=546&amp;amp;entry_id=62&quot; title=&quot;http://docs.sun.com&quot;  onmouseover=&quot;window.status=&#039;http://docs.sun.com&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;docs.sun.com&lt;/a&gt; section &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=547&amp;amp;entry_id=62&quot; title=&quot;http://docs.sfbay/app/docs/doc/817-6223/6mlkidlim?a=view&quot;  onmouseover=&quot;window.status=&#039;http://docs.sfbay/app/docs/doc/817-6223/6mlkidlim?a=view&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;about DTrace scripting&lt;/a&gt;, particularly a section about &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=548&amp;amp;entry_id=62&quot; title=&quot;http://docs.sfbay/app/docs/doc/817-6223/6mlkidliq?a=view&quot;  onmouseover=&quot;window.status=&#039;http://docs.sfbay/app/docs/doc/817-6223/6mlkidliq?a=view&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;comman line parameters macros&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
As with &lt;b&gt;sh&lt;/b&gt; or &lt;b&gt;bash&lt;/b&gt;, you can access command line parameters via &lt;b&gt;$0&lt;/b&gt;..&lt;b&gt;$9&lt;/b&gt; macroses. But there&#039;s a catch. Values of these macroses should match a certain definition - a number, an identifier or a string. If there isn&#039;t a match here, you&#039;ll get an error.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start with a simple script.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
&lt;br /&gt;
#pragma&amp;#160;D&amp;#160;option&amp;#160;quiet&lt;br /&gt;
&lt;br /&gt;
BEGIN&amp;#160;{&lt;br /&gt;
printf&amp;#40;&quot;Your&amp;#160;parameter&amp;#58;&amp;#160;%d\n&quot;,&amp;#160;$1&amp;#41;;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
If you pass a number as a command line parameter, there will be no error, and you&#039;ll get this message:&lt;br /&gt;
&lt;b&gt;Your parameter: 123&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
But if you pass a string instead of number, here&#039;s the error you&#039;ll get:&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
bash-3.00# ./args.d a1b2c3&lt;br /&gt;
dtrace: failed to compile script ./args.d: line 9: failed to resolve a1b2c3: Unknown variable name&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
This happens because DTrace tries to find an identifier &quot;a1b2c3&quot;. Why does this happen? Because of the way DTrace tries to recognize the type of a command line parameter. The parameter doesn&#039;t look like a number, but to make DTrace accept the value as a string, you have to specify it in quotes. Without them, DTrace accepts we&#039;ve passed an identifier name. And since there isn&#039;t one with such a name, we get an error.&lt;br /&gt;
&lt;br /&gt;
To prove this theory, you simply have to create a variable with the same name in your script:&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
&lt;br /&gt;
#pragma&amp;#160;D&amp;#160;option&amp;#160;quiet&lt;br /&gt;
&lt;br /&gt;
BEGIN&amp;#160;{&lt;br /&gt;
a1b2c3=1979;&lt;br /&gt;
printf&amp;#40;&quot;Your&amp;#160;parameter&amp;#58;&amp;#160;%d\n&quot;,&amp;#160;$1&amp;#41;;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
There you go - it works just like I said:&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
Your parameter: 1979&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
And if your parameter is definitely a string, you have to change your script (the line with printf, so that it has %s for a string, and not %d for an integer, otherwise you&#039;ll get another error)...&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
&lt;br /&gt;
#pragma&amp;#160;D&amp;#160;option&amp;#160;quiet&lt;br /&gt;
&lt;br /&gt;
BEGIN&amp;#160;{&lt;br /&gt;
a1b2c3=1979;&lt;br /&gt;
printf&amp;#40;&quot;Your&amp;#160;parameter&amp;#58;&amp;#160;%s\n&quot;,&amp;#160;$1&amp;#41;;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
... and also put your parameter in quotes, like this:&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
bash-3.00# ./args.d &#039;&quot;a1b2c3&quot;&#039;&lt;br /&gt;
Your parameter: a1b2c3&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
As you can see, we&#039;re getting a string we passed, and not the variable with the same name, which was left in the script intentionally to demonstrate it&#039;s not used anymore.&lt;br /&gt;
&lt;br /&gt;
And finally, one more thing. If you want all your command line parameters to be treated as strings by default and even leave the quotes around parameters out, all you have to do is to access the macroses for your parameters with a double &lt;b&gt;$&lt;/b&gt; sign, and then the parameter type definition will be skipped:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
&lt;br /&gt;
#pragma&amp;#160;D&amp;#160;option&amp;#160;quiet&lt;br /&gt;
&lt;br /&gt;
BEGIN&amp;#160;{&lt;br /&gt;
a1b2c3=1979;&lt;br /&gt;
printf&amp;#40;&quot;Your&amp;#160;parameter&amp;#58;&amp;#160;%s\n&quot;,&amp;#160;$$1&amp;#41;;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
And here&#039;s how you&#039;d access such a script with the same parameter we&#039;ve used before:&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
bash-3.00# ./args.d a1b2c3&lt;br /&gt;
Your parameter: a1b2c3&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
That&#039;s it for today! Good luck with your DTrace scripts! 
    </content:encoded>

    <pubDate>Wed, 18 May 2005 20:05:49 +0400</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2005/05/dtrace_command_line_parameters</guid>
    <category>dtrace</category>
<category>dtrace</category>

</item>
<item>
    <title>Tips and tricks from DTrace authors</title>
    <link>http://solaris.reys.net/english/2005/03/tips_and_tricks_from_dtrace_authors</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2005/03/tips_and_tricks_from_dtrace_authors#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=56</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=56</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    Yesterday &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=690&amp;amp;entry_id=56&quot; title=&quot;http://blogs.sun.com/bmc&quot;  onmouseover=&quot;window.status=&#039;http://blogs.sun.com/bmc&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Bryan Cantrill&lt;/a&gt; (one of DTrace authors) &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=691&amp;amp;entry_id=56&quot; title=&quot;http://blogs.sun.com/roller/page/bmc/20050228&quot;  onmouseover=&quot;window.status=&#039;http://blogs.sun.com/roller/page/bmc/20050228&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;provided a link&lt;/a&gt; to the presentation he along with two other DTrace authors gave recently on advanced DTrace scripting. There are lots of useful tips, tricks and gotchas explained, which might be useful for both newbies and some seasoned DTrace users.&lt;br /&gt;
&lt;br /&gt;
As it&#039;s states one the very first slides of the presentation, some of the things presented are quite simple - most of the tips you&#039;d know if you read the documentation carefully, but the tips given are very useful. I&#039;ve learned lots of new things, so I strongly recommend anyone interested in DTrace to find some time and read it as well. Here is the &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=692&amp;amp;entry_id=56&quot; title=&quot;http://blogs.sun.com/roller/resources/bmc/dtrace_tips.pdf&quot;  onmouseover=&quot;window.status=&#039;http://blogs.sun.com/roller/resources/bmc/dtrace_tips.pdf&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;presentation in a PDF file&lt;/a&gt;. 
    </content:encoded>

    <pubDate>Tue, 01 Mar 2005 13:38:04 +0300</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2005/03/tips_and_tricks_from_dtrace_authors</guid>
    
</item>
<item>
    <title>DTrace: pid provider</title>
    <link>http://solaris.reys.net/english/2005/02/dtrace_pid_provider</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2005/02/dtrace_pid_provider#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=55</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=55</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    Quite ofter we&#039;d like to know what happens to a particular process on a system, and if we&#039;re using DTrace for our investigation, we&#039;d probably use the &lt;b&gt;$target&lt;/b&gt; variable (I&#039;ve already &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=693&amp;amp;entry_id=55&quot; title=&quot;http://solaris.reys.net/archives/43-DTrace-target.html&quot;  onmouseover=&quot;window.status=&#039;http://solaris.reys.net/archives/43-DTrace-target.html&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;spoked about it&lt;/a&gt; in the past) or simply specify the process identifier (pid) in some predicates of our probes, thus pointing to DTrace that we&#039;re after only a certain process. &lt;b&gt;$target&lt;/b&gt; variable still can and should be used when creating our probes with pid provider.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For DTrace beginners it&#039;s quite a common and good practice. But there is a better way: using the &lt;b&gt;pid&lt;/b&gt; provider.&lt;br /&gt;
&lt;br /&gt;
As it&#039;s explained in the official DTrace guide, &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=694&amp;amp;entry_id=55&quot; title=&quot;http://docs.sun.com/app/docs/doc/817-6223/6mlkidlls?q=dtrace+pid&amp;amp;a=view&quot;  onmouseover=&quot;window.status=&#039;http://docs.sun.com/app/docs/doc/817-6223/6mlkidlls?q=dtrace+pid&amp;amp;a=view&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;pid provider&lt;/a&gt; isn&#039;t just a provider, but in fact is a whole class of providers. And, as the name suggests, it provides us with probes related to a certain process.&lt;br /&gt;
&lt;br /&gt;
For instance, pid737 provider allows us to trace everything happening within a process with pid of 737. What&#039;s really cool about this provide - it&#039;s not only easier to scope our interest, but it also gets much easier to see how where certain probes originate from (what libraries provide certain functions used by our process, read on - I&#039;ll explain it a bit later).&lt;br /&gt;
&lt;br /&gt;
Such a way of looking at a certain process, in contrast to using predicates like &lt;b&gt;/pid == $target/&lt;/b&gt;, is more correct. Instead of enabling all the specified probes by default, and then using predicates for each probe firing for each process on the system only to see whether we&#039;re interested in a given process, DTrace won&#039;t even look at other processes - and pid737 will make sure that all the probes specified will be enabled and possibly fired only for the specified process.&lt;br /&gt;
&lt;br /&gt;
We already know how to get the list of all the probes known to DTrace. I&#039;ve &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=695&amp;amp;entry_id=55&quot; title=&quot;http://solaris.reys.net/archives/17-DTrace.html&quot;  onmouseover=&quot;window.status=&#039;http://solaris.reys.net/archives/17-DTrace.html&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;explained&lt;/a&gt; it a while ago. The thing you need to remember about the pid provider is this: after you&#039;ve used pid provider in some probes for a process, &lt;b&gt;dtrace -l&lt;/b&gt; will start reporting you these probes at the end of all the available probes. They&#039;ve been dynamically allocated just for you. If the process in question dies or finishes, all the dynamically allocated probes for its pid provider will disappear.&lt;br /&gt;
&lt;br /&gt;
One more thing I really like about pid provider - modules used in probes are in fact libraries used for the execution of the process you&#039;re looking at. This gives you a wonderful opportunity of observing only what&#039;s been done in your process by functions of a particular library. Very useful.&lt;br /&gt;
&lt;br /&gt;
Right, enough of theory - here&#039;s an example. First, we create a simple bit of &quot;Hello, world!&quot; code in C:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;void&amp;#160;main&amp;#40;&amp;#41;&amp;#160;{&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;printf&amp;#40;&quot;Hello,&amp;#160;world!\n&quot;&amp;#41;;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
After you compile it, let&#039;s get going with out DTrace script:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
#pragma&amp;#160;D&amp;#160;option&amp;#160;quiet&lt;br /&gt;
&lt;br /&gt;
BEGIN&amp;#160;{&lt;br /&gt;
	printf&amp;#40;&quot;Target&amp;#160;pid&amp;#58;&amp;#160;%d\n&quot;,&amp;#160;$target&amp;#41;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
pid$target&amp;#58;&amp;#58;&amp;#58;entry&amp;#160;{&lt;br /&gt;
	printf&amp;#40;&quot;%s&amp;#58;%s&amp;#58;%s&amp;#58;%s\n&quot;,&amp;#160;probeprov,&amp;#160;probemod,&amp;#160;probefunc,&amp;#160;probename&amp;#41;;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Save the script, make it executable, and start it, specifying our hello as a command to start:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;$&amp;#160;./pid-global.d&amp;#160;-c&amp;#160;./hello&amp;#160;|&amp;#160;more&lt;br /&gt;
Target&amp;#160;pid&amp;#58;&amp;#160;1059&lt;br /&gt;
Hello,&amp;#160;world!&lt;br /&gt;
pid1059&amp;#58;LM1`ld.so.1&amp;#58;call_array&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;LM1`ld.so.1&amp;#58;call_init&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;LM1`ld.so.1&amp;#58;leave&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;LM1`ld.so.1&amp;#58;fmap_setup&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;LM1`ld.so.1&amp;#58;munmap&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;LM1`ld.so.1&amp;#58;rt_bind_clear&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;LM1`ld.so.1&amp;#58;_rt_bind_clear&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;LM1`ld.so.1&amp;#58;rt_mutex_unlock&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;LM1`ld.so.1&amp;#58;_rt_null&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;LM1`ld.so.1&amp;#58;rt_bind_clear&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;LM1`ld.so.1&amp;#58;_rt_bind_clear&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;libc.so.1&amp;#58;libc_init&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;libc.so.1&amp;#58;__amd64id&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;libc.so.1&amp;#58;atexit&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;libc.so.1&amp;#58;lmalloc&amp;#58;entry&lt;br /&gt;
pid1059&amp;#58;libc.so.1&amp;#58;getbucketnum&amp;#58;entry&lt;br /&gt;
...&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
You see this list of probes? I won&#039;t give you the full list - it&#039;s going to be almost a 1000 lines, but I hope you get the idea. It&#039;s also a perfect opportunity to see how easy it&#039;s going to be for you to track probes of a particular library.&lt;br /&gt;
&lt;br /&gt;
Back to our example, it&#039;s obvious what I&#039;m going to do now: I&#039;d like to get our printf caught with a probe. &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
#pragma&amp;#160;D&amp;#160;option&amp;#160;quiet&lt;br /&gt;
&lt;br /&gt;
BEGIN&amp;#160;{&lt;br /&gt;
	printf&amp;#40;&quot;Target&amp;#160;pid&amp;#58;&amp;#160;%d\n&quot;,&amp;#160;$target&amp;#41;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
pid$target&amp;#58;&amp;#58;printf&amp;#58;entry&amp;#160;{&lt;br /&gt;
	printf&amp;#40;&quot;%s&amp;#58;%s&amp;#58;%s&amp;#58;%s\n&quot;,&amp;#160;probeprov,&amp;#160;probemod,&amp;#160;probefunc,&amp;#160;probename&amp;#41;;&lt;br /&gt;
	printf&amp;#40;&quot;Argument&amp;#58;&amp;#160;%s\n&quot;,&amp;#160;copyinstr&amp;#40;arg0&amp;#41;&amp;#41;;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
If we start tihs script, here&#039;s what you&#039;ll get:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;$&amp;#160;./pid-printf.d&amp;#160;-c&amp;#160;./hello&lt;br /&gt;
Target&amp;#160;pid&amp;#58;&amp;#160;1201&lt;br /&gt;
Hello,&amp;#160;world!&lt;br /&gt;
pid1201&amp;#58;libc.so.1&amp;#58;printf&amp;#58;entry&lt;br /&gt;
Argument&amp;#58;&amp;#160;Hello,&amp;#160;world!&lt;/div&gt; 
    </content:encoded>

    <pubDate>Sat, 26 Feb 2005 23:52:58 +0300</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2005/02/dtrace_pid_provider</guid>
    <category>dtrace</category>
<category>dtrace</category>

</item>
<item>
    <title>DTrace open sourced</title>
    <link>http://solaris.reys.net/english/2005/01/dtrace_open_sourced</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2005/01/dtrace_open_sourced#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=48</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=48</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    At last, OpenSolaris.Org is up!&lt;br /&gt;
&lt;br /&gt;
As it was expected, it&#039;s not possible to download OS sources just yet. Instead, to prove that the whole OpenSolaris idea is serious, Sun revealed DTrace sources.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=698&amp;amp;entry_id=48&quot; title=&quot;http://blogs.sun.com/bmc&quot;  onmouseover=&quot;window.status=&#039;http://blogs.sun.com/bmc&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Bryan Cantrill&lt;/a&gt; has posted a very interesting entry in his blog today, I strongly recommend you read it: &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=699&amp;amp;entry_id=48&quot; title=&quot;http://blogs.sun.com/roller/page/bmc/20050125&quot;  onmouseover=&quot;window.status=&#039;http://blogs.sun.com/roller/page/bmc/20050125&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Solaris 10 Revealed&lt;/a&gt;. 
    </content:encoded>

    <pubDate>Tue, 25 Jan 2005 19:49:17 +0300</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2005/01/dtrace_open_sourced</guid>
    <category>dtrace</category>
<category>opensolaris</category>
<category>dtrace</category>
<category>opensolaris</category>

</item>
<item>
    <title>DTrace: aggregation functions (aggregations)</title>
    <link>http://solaris.reys.net/english/2005/01/dtrace_aggregates</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2005/01/dtrace_aggregates#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=45</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=45</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    Quite often it is more important for you to see the whole picture, rather than to know each case when a particular probe fires. For instance, observing a process which consumes a lot of CPU time according to &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=707&amp;amp;entry_id=45&quot; title=&quot;http://docs.sun.com/app/docs/doc/816-5166/6mbb1kqc9?q=prstat&amp;amp;a=view&quot;  onmouseover=&quot;window.status=&#039;http://docs.sun.com/app/docs/doc/816-5166/6mbb1kqc9?q=prstat&amp;amp;a=view&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;prstat&lt;/a&gt;, we ask ourselves: what is this process doing? And often we think about the overall number of system calls executed by this process, and not every particular one of these system calls.&lt;br /&gt;
&lt;br /&gt;
DTrace aggregations are created specifically for answering such questions. Working with sets of numerical data, aggregation functions help us to easily determing average, min and max values of data sets, count numbers and sums of elements in these data sets, and even build frequency distributions.&lt;br /&gt;
&lt;br /&gt;
More information can be found &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=708&amp;amp;entry_id=45&quot; title=&quot;http://docs.sun.com/app/docs/doc/817-6223/6mlkidlh7?q=target&amp;amp;a=view&quot;  onmouseover=&quot;window.status=&#039;http://docs.sun.com/app/docs/doc/817-6223/6mlkidlh7?q=target&amp;amp;a=view&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;here&lt;/a&gt;, but today I&#039;ll show only few examples of using aggregations.&lt;br /&gt;
&lt;br /&gt;
DTrace stores the results of aggregation functions in objects called &lt;b&gt;aggregations&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
The syntax is:&lt;br /&gt;
&lt;b&gt;@name[ keys ] = aggfunc ( args );&lt;/b&gt;&lt;br /&gt;
here:&lt;br /&gt;
&lt;b&gt;name&lt;/b&gt; - name of our aggregation&lt;br /&gt;
&lt;b&gt;keys&lt;/b&gt; - index keys, very similar to those of associative arrays.&lt;br /&gt;
&lt;b&gt;aggfunc&lt;/b&gt; - aggregation function&lt;br /&gt;
&lt;b&gt;args&lt;/b&gt; - function arguments, usually it&#039;s a set of numerical data&lt;br /&gt;
&lt;br /&gt;
Today I&#039;ll use &lt;b&gt;sum&lt;/b&gt; aggregation function, which as it&#039;s obvious from the name, helps us calculate the sum of a numerical data set,&lt;br /&gt;
&lt;br /&gt;
Only the current value of the aggregation function is stored in the memory, it&#039;s calculated off the previous function argument values. Then the function is calculated for the current value of the argument, and this result is applied to the current aggregation value.&lt;br /&gt;
&lt;br /&gt;
For basic analysis you can use as few aggregations keys as you can - for instance, use only PID, without specifying thread ID as another index key.You can even use execname - but keep in mind that there might be more than one process running on your system with the same name. Still, execname-based aggregation will be quite useful to track what&#039;s getting most of our system&#039;s attention:&lt;br /&gt;
&lt;br /&gt;
Here&#039;s our script:&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
#pragma&amp;#160;D&amp;#160;option&amp;#160;quiet&lt;br /&gt;
&lt;br /&gt;
syscall&amp;#58;&amp;#58;&amp;#58;entry&lt;br /&gt;
{&lt;br /&gt;
	self-&amp;#62;ts=timestamp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
syscall&amp;#58;&amp;#58;&amp;#58;return&lt;br /&gt;
{&lt;br /&gt;
	self-&amp;#62;elapsed&amp;#160;=&amp;#160;timestamp&amp;#160;-&amp;#160;self-&amp;#62;ts;&lt;br /&gt;
	@time&amp;#91;execname&amp;#93;=sum&amp;#40;self-&amp;#62;elapsed&amp;#41;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
END&lt;br /&gt;
{&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;printf&amp;#40;&quot;\n%20s&amp;#160;%20s\n&quot;,&amp;#160;&lt;br /&gt;
		&quot;Execname&quot;,&amp;#160;&quot;Time&amp;#160;elapsed&quot;&amp;#41;;&lt;br /&gt;
&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;printa&amp;#40;&quot;%20s&amp;#160;%20@u\n&quot;,&amp;#160;@time&amp;#41;;&lt;br /&gt;
}&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Save it into a file, do &lt;b&gt;chmod a+x&lt;/b&gt; on this file and start it. You&#039;ll get an output similar to this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Execname&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Time&amp;#160;elapsed&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;xscreensaver&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;5710&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;gnome-smproxy&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;6886&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;wnck-applet&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;7735&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;gnome-panel&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;52032&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;metacity&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;54430&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;gnome-settings-d&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;60419&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;vim&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;66452&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;mixer_applet2&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;670078802&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;gnome-netstatus-&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;819836799&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;nautilus&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;900025830&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Xorg&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1074783431&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;gnome-terminal&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1074816530&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;firefox-bin&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;2000076871&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;dtrace&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;9843796821648&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
The time in the last column is given in nanoseconds, so don&#039;t be scared with such huge numbers :) For timing some actions in your script &lt;b&gt;timestamp&lt;/b&gt; proves to be VERY useful. It&#039;s a nanoseconds counter which increments from an arbitrary point, so it can be used for relative computations only.&lt;br /&gt;
&lt;br /&gt;
Now you can look at the output and notice how much of unnecessary actions is happening on my laptop with started Gnome ;)&lt;br /&gt;
&lt;br /&gt;
If you want a deeper analysis, you can make our script a bit more complex, and you&#039;ll get a powerful tool for determining what process was doing what on our system, and for how long.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
#pragma&amp;#160;D&amp;#160;option&amp;#160;quiet&lt;br /&gt;
&lt;br /&gt;
syscall&amp;#58;&amp;#58;&amp;#58;entry&lt;br /&gt;
{&lt;br /&gt;
	self-&amp;#62;ts=timestamp;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
syscall&amp;#58;&amp;#58;&amp;#58;return&lt;br /&gt;
{&lt;br /&gt;
	self-&amp;#62;elapsed&amp;#160;=&amp;#160;timestamp&amp;#160;-&amp;#160;self-&amp;#62;ts;&lt;br /&gt;
	@time&amp;#91;execname,probefunc,pid,tid&amp;#93;=sum&amp;#40;self-&amp;#62;elapsed&amp;#41;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
END&lt;br /&gt;
{&lt;br /&gt;
	printf&amp;#40;&quot;\n%20s&amp;#160;%20s&amp;#160;%8s&amp;#160;%7s&amp;#160;%20s\n&quot;,&amp;#160;&lt;br /&gt;
		&quot;Execname&quot;,&amp;#160;&quot;Syscall&quot;,&amp;#160;&quot;Process&quot;,&amp;#160;&quot;Thread&quot;,&amp;#160;&quot;Time&amp;#160;elapsed&quot;&amp;#41;;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;printa&amp;#40;&quot;%20s&amp;#160;%20s&amp;#160;%8d&amp;#160;%7d&amp;#160;%20@u\n&quot;,&amp;#160;@time&amp;#41;;&lt;br /&gt;
}&amp;#160;&amp;#160;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
If you save this code into syscalls.d and start the script, you&#039;ll probably get something similar (I&#039;ve deleted lots of lines to save up some space):&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;&amp;#160;&amp;#160;Execname&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Syscall&amp;#160;&amp;#160;Process&amp;#160;&amp;#160;Thread&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Time&amp;#160;elapsed&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;gnome-terminal&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;read&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;7199&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;12867&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Xorg&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;read&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;6953&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;13769&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;dtrace&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;brk&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;7331&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;33647&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;dtrace&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;schedctl&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;7331&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;39320&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;gnome-terminal&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;write&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;7199&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;48052&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Xorg&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;writev&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;6953&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;57112&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;gnome-terminal&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;pollsys&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;7199&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;646816&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;dtrace&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;lwp_park&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;7331&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;44817217&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Xorg&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;pollsys&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;6953&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;46936244&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;dtrace&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;ioctl&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;7331&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;9269224066655&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
If you leave such a script running for a couple of minutes, you&#039;ll get a very long output with the list of every process running on your system all the system calls it&#039;s been executing, with the time spent by each thread of each process. 
    </content:encoded>

    <pubDate>Wed, 12 Jan 2005 19:26:30 +0300</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2005/01/dtrace_aggregates</guid>
    <category>dtrace</category>
<category>dtrace</category>

</item>
<item>
    <title>DTrace: $target macro variable</title>
    <link>http://solaris.reys.net/english/2005/01/dtrace_target_macro_variable</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2005/01/dtrace_target_macro_variable#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=43</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=43</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    Macro variables are meant to make your life MUCH easier when scripting with DTrace. Names of such variables must begin with a &lt;b&gt;$&lt;/b&gt; sign,  and DTrace will automatically replace all the macro variables with the appropriate values when parsing your script.&lt;br /&gt;
&lt;br /&gt;
Full list of macro variables can be found &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=710&amp;amp;entry_id=43&quot; title=&quot;http://docs.sun.com/app/docs/doc/817-6223/6mlkidlim?q=target&amp;amp;a=view#chp-script-2&quot;  onmouseover=&quot;window.status=&#039;http://docs.sun.com/app/docs/doc/817-6223/6mlkidlim?q=target&amp;amp;a=view#chp-script-2&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;here&lt;/a&gt;, I will only talk about &lt;b&gt;$target&lt;/b&gt; variable this time.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;$target&lt;/b&gt; specifies the PID of the process you associate with your DTrace script.&lt;br /&gt;
&lt;br /&gt;
DTrace has two useful command line options which can be used not only when running a &lt;a href=&quot;http://solaris.reys.net/exit.php?url=aHR0cDovL2RvY3Muc3VuLmNvbS9hcHAvZG9jcy9kb2MvODE2LTUxNjYvNm1iYjFrcTEyP3E9ZHRyYWNlJmE9dmlldw==&amp;amp;entry_id=43&quot; title=&quot;http://docs.sun.com/app/docs/doc/816-5166/6mbb1kq12?q=dtrace&amp;amp;a=view&quot;  onmouseover=&quot;window.status=&#039;http://docs.sun.com/app/docs/doc/816-5166/6mbb1kq12?q=dtrace&amp;amp;a=view&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;dtrace&lt;/a&gt; command, but also when running DTrace-scripts:&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;./script.d -c xterm&lt;/b&gt;&lt;br /&gt;
This command asks DTrace to run a command which follows the -c option, and process the actual script.d only after this.  Our macro variable, &lt;b&gt;$target&lt;/b&gt;, will containt a PID of the started command we specified - xterm  in this example.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;./script.d -p 654&lt;/b&gt;&lt;br /&gt;
This is a similar way of running a DTrace script, only we notify DTrace that we&#039;d like to work with the process with PID of 654. This way of using DTrace is especially useful as you don&#039;t have to start or restart an already running process. &lt;b&gt;$target&lt;/b&gt; will contain the PID specified in the command line - 654 in this example.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;$target&lt;/b&gt; may be used like this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
#pragma&amp;#160;D&amp;#160;option&amp;#160;quiet&lt;br /&gt;
&lt;br /&gt;
syscall&amp;#58;&amp;#58;&amp;#58;entry,&amp;#160;syscall&amp;#58;&amp;#58;&amp;#58;return&lt;br /&gt;
/pid&amp;#160;==&amp;#160;$target/&lt;br /&gt;
{&lt;br /&gt;
printf&amp;#40;&quot;%d/%d&amp;#58;&amp;#160;%s&amp;#58;%s\n&quot;,&amp;#160;pid,&amp;#160;tid,&amp;#160;probefunc,&amp;#160;probename&amp;#41;;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
If you execute this script, you&#039;ll probably get an output like this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;./script.d&amp;#160;-c&amp;#160;xterm&lt;br /&gt;
26525/1&amp;#58;&amp;#160;munmap&amp;#58;entry&lt;br /&gt;
26525/1&amp;#58;&amp;#160;munmap&amp;#58;return&lt;br /&gt;
26525/1&amp;#58;&amp;#160;mmap&amp;#58;entry&lt;br /&gt;
26525/1&amp;#58;&amp;#160;mmap&amp;#58;return&lt;br /&gt;
26525/1&amp;#58;&amp;#160;setcontext&amp;#58;entry&lt;br /&gt;
26525/1&amp;#58;&amp;#160;setcontext&amp;#58;return&lt;br /&gt;
26525/1&amp;#58;&amp;#160;getrlimit&amp;#58;entry&lt;br /&gt;
26525/1&amp;#58;&amp;#160;getrlimit&amp;#58;return&lt;br /&gt;
26525/1&amp;#58;&amp;#160;getpid&amp;#58;entry&lt;br /&gt;
26525/1&amp;#58;&amp;#160;getpid&amp;#58;return&lt;br /&gt;
...&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Just a little bit later I&#039;ll talk about aggregations - yet another one of the wonderful DTrace features, and then I&#039;ll be able to give you more interesting and useful examples of DTrace scripting. 
    </content:encoded>

    <pubDate>Fri, 07 Jan 2005 18:34:22 +0300</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2005/01/dtrace_target_macro_variable</guid>
    <category>dtrace</category>
<category>dtrace</category>

</item>
<item>
    <title>More on how DTrace works</title>
    <link>http://solaris.reys.net/english/2005/01/how_dtrace_works</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2005/01/how_dtrace_works#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=39</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=39</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    Just went to &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=715&amp;amp;entry_id=39&quot; title=&quot;http://www.sun.com/bigadmin/content/dtrace/&quot;  onmouseover=&quot;window.status=&#039;http://www.sun.com/bigadmin/content/dtrace/&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;BigAdmin: DTrace&lt;/a&gt; once again, and bumped into &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=721&amp;amp;entry_id=39&quot; title=&quot;http://www.sun.com/bigadmin/content/dtrace/dtrace_usenix.pdf&quot;  onmouseover=&quot;window.status=&#039;http://www.sun.com/bigadmin/content/dtrace/dtrace_usenix.pdf&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;this useful link&lt;/a&gt; - and decided to highlight it yet again.&lt;br /&gt;
&lt;br /&gt;
This link leads to a pdf-file with the technical paper of the three guys who created &lt;b&gt;DTrace&lt;/b&gt; - &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=717&amp;amp;entry_id=39&quot; title=&quot;http://blogs.sun.com/bmc&quot;  onmouseover=&quot;window.status=&#039;http://blogs.sun.com/bmc&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Bryan M. Cantrill&lt;/a&gt;, &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=718&amp;amp;entry_id=39&quot; title=&quot;http://www.sun.com/bigadmin/cgi/xpertApp.cgi?xpert=dtraceteam&amp;amp;action=bio&quot;  onmouseover=&quot;window.status=&#039;http://www.sun.com/bigadmin/cgi/xpertApp.cgi?xpert=dtraceteam&amp;amp;action=bio&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Michael W. Shapiro&lt;/a&gt; and &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=719&amp;amp;entry_id=39&quot; title=&quot;http://blogs.sun.com/ahl&quot;  onmouseover=&quot;window.status=&#039;http://blogs.sun.com/ahl&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Adam H. Leventhal&lt;/a&gt;, for the last &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=720&amp;amp;entry_id=39&quot; title=&quot;http://www.usenix.org/events/usenix04/index.html&quot;  onmouseover=&quot;window.status=&#039;http://www.usenix.org/events/usenix04/index.html&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;USENIX&lt;/a&gt; conference. The title is: &lt;a href=&quot;http://solaris.reys.net/exit.php?url_id=721&amp;amp;entry_id=39&quot; title=&quot;http://www.sun.com/bigadmin/content/dtrace/dtrace_usenix.pdf&quot;  onmouseover=&quot;window.status=&#039;http://www.sun.com/bigadmin/content/dtrace/dtrace_usenix.pdf&#039;;return true;&quot; onmouseout=&quot;window.status=&#039;&#039;;return true;&quot;&gt;Dynamic Instrumentation of Production Systems.&lt;/a&gt;&lt;br /&gt;
Apart from listing all the advantages of &lt;b&gt;DTrace&lt;/b&gt;,  the paper also gives a thorough conceptual description of DTrace dynamic tracing mechanisms &lt;b&gt;DTrace&lt;/b&gt; - I highly recommend you read it. 
    </content:encoded>

    <pubDate>Thu, 06 Jan 2005 01:12:57 +0300</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2005/01/how_dtrace_works</guid>
    <category>dtrace</category>
<category>dtrace</category>

</item>
<item>
    <title>DTrace options: flowindent</title>
    <link>http://solaris.reys.net/english/2004/12/dtrace_flowindent</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2004/12/dtrace_flowindent#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=35</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=35</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    One of the most useful (for me) options in DTrace is &lt;b&gt;flowindent&lt;/b&gt;. All it does is indent the entry to each function with &quot;-&gt;&quot;, and mark the return from this function with &quot;&lt;-&quot;. Doesn&#039;t seem like much, does it? But just look at the results!&lt;br /&gt;
&lt;br /&gt;
The following example catches all the probes of the &lt;b&gt;fbt&lt;/b&gt; provided. By default (that&#039;s our case since we&#039;re not changing any other options but flowindent), DTrace registers and prints to the standard output all the probes matched in the tracing process.&lt;br /&gt;
&lt;br /&gt;
Here is our script:&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
&lt;br /&gt;
fbt&amp;#58;&amp;#58;&amp;#58;&lt;br /&gt;
/execname&amp;#160;==&amp;#160;&quot;dtrace&quot;/&lt;br /&gt;
{&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
And this is the output we&#039;ll get by running this script:&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;dtrace&amp;#58;&amp;#160;script&amp;#160;&#039;./try5.d&#039;&amp;#160;matched&amp;#160;32659&amp;#160;probes&lt;br /&gt;
CPU&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;ID&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;FUNCTION&amp;#58;NAME&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;2027&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;xc_sync&amp;#58;entry&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;819&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;xc_do_call&amp;#58;entry&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;1210&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;mutex_vector_enter&amp;#58;entry&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;1238&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;lock_set_spl&amp;#58;entry&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;2353&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;splx&amp;#58;entry&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;15484&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;apic_setspl&amp;#58;entry&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;15485&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;apic_setspl&amp;#58;return&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;2354&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;splx&amp;#58;return&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;1239&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;lock_set_spl&amp;#58;return&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;1211&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;mutex_vector_enter&amp;#58;return&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;821&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;xc_common&amp;#58;entry&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;15510&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;apic_send_ipi&amp;#58;entry&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;15511&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;apic_send_ipi&amp;#58;return&amp;#160;&lt;br /&gt;
...&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
But if we only add the &lt;b&gt;flowindent&lt;/b&gt; option to our script (you can also achieve the same result by using -F dtrace command line option), the output is going to appear much more readable and easy to follow:&lt;br /&gt;
&lt;br /&gt;
Our new script:&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
#pragma&amp;#160;D&amp;#160;option&amp;#160;flowindent&lt;br /&gt;
&lt;br /&gt;
fbt&amp;#58;&amp;#58;&amp;#58;&lt;br /&gt;
/execname&amp;#160;==&amp;#160;&quot;dtrace&quot;/&lt;br /&gt;
{&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
And this is the output we&#039;ll get:&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;dtrace&amp;#58;&amp;#160;script&amp;#160;&#039;./try5.d&#039;&amp;#160;matched&amp;#160;32659&amp;#160;probes&lt;br /&gt;
CPU&amp;#160;FUNCTION&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;-&amp;#62;&amp;#160;xc_sync&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;-&amp;#62;&amp;#160;xc_do_call&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;-&amp;#62;&amp;#160;mutex_vector_enter&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;-&amp;#62;&amp;#160;lock_set_spl&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;-&amp;#62;&amp;#160;splx&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;-&amp;#62;&amp;#160;apic_setspl&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;-&amp;#160;apic_setspl&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;-&amp;#160;splx&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;-&amp;#160;lock_set_spl&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;-&amp;#160;mutex_vector_enter&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;-&amp;#62;&amp;#160;xc_common&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;-&amp;#62;&amp;#160;apic_send_ipi&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;
&amp;#160;&amp;#160;1&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#60;-&amp;#160;apic_send_ipi&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&lt;br /&gt;
...&lt;/div&gt; 
    </content:encoded>

    <pubDate>Tue, 14 Dec 2004 19:26:42 +0300</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2004/12/dtrace_flowindent</guid>
    <category>dtrace</category>
<category>dtrace</category>

</item>
<item>
    <title>DTrace: predicates</title>
    <link>http://solaris.reys.net/english/2004/10/dtrace_predicates</link>
            <category>DTrace</category>
    
    <comments>http://solaris.reys.net/english/2004/10/dtrace_predicates#comments</comments>
    <wfw:comment>http://solaris.reys.net/wfwcomment.php?cid=32</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://solaris.reys.net/rss.php?version=2.0&amp;type=comments&amp;cid=32</wfw:commentRss>
    

    <author>nospam@example.com (Gleb Reys)</author>
    <content:encoded>
    You don&#039;t have conditional statements like &lt;b&gt;if..then..else&lt;/b&gt; in DTrace, instead of them &lt;u&gt;predicates&lt;/u&gt; are used. &lt;br /&gt;
&lt;b&gt;Predicates&lt;/b&gt; are slash (&lt;b&gt;/&lt;/b&gt;) wrapped conditions which are put right after the lines of probe definitions, defining whether DTrace should or should not executre the code of such probes.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an example. The following script will print the list of all system calls, excluding &lt;b&gt;write&lt;/b&gt;, for all the processes currently running on our system. Since DTrace tracks events on a thread-level, you can see in this example that some PIDs are the same. This is because these lines were printed by probes fired for different threads of the same process:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
#pragma&amp;#160;D&amp;#160;option&amp;#160;quiet&lt;br /&gt;
&lt;br /&gt;
syscall&amp;#58;&amp;#58;&amp;#58;&lt;br /&gt;
/probefunc&amp;#160;!=&amp;#160;&quot;write&quot;/&lt;br /&gt;
{&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;printf&amp;#40;&quot;probefunc&amp;#58;&amp;#160;%s,&amp;#160;pid&amp;#58;&amp;#160;%d,&amp;#160;execname&amp;#58;&amp;#160;%s\n&quot;,&amp;#160;probefunc,&amp;#160;pid,&amp;#160;execname&amp;#41;;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
When you execute this script, you&#039;ll get something similar to this:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;probefunc&amp;#58;&amp;#160;ioctl,&amp;#160;pid&amp;#58;&amp;#160;28603,&amp;#160;execname&amp;#58;&amp;#160;dtrace&lt;br /&gt;
probefunc&amp;#58;&amp;#160;ioctl,&amp;#160;pid&amp;#58;&amp;#160;28603,&amp;#160;execname&amp;#58;&amp;#160;dtrace&lt;br /&gt;
probefunc&amp;#58;&amp;#160;ioctl,&amp;#160;pid&amp;#58;&amp;#160;28603,&amp;#160;execname&amp;#58;&amp;#160;dtrace&lt;br /&gt;
probefunc&amp;#58;&amp;#160;ioctl,&amp;#160;pid&amp;#58;&amp;#160;28603,&amp;#160;execname&amp;#58;&amp;#160;dtrace&lt;br /&gt;
probefunc&amp;#58;&amp;#160;ioctl,&amp;#160;pid&amp;#58;&amp;#160;28603,&amp;#160;execname&amp;#58;&amp;#160;dtrace&lt;br /&gt;
probefunc&amp;#58;&amp;#160;sysconfig,&amp;#160;pid&amp;#58;&amp;#160;28603,&amp;#160;execname&amp;#58;&amp;#160;dtrace&lt;br /&gt;
probefunc&amp;#58;&amp;#160;sysconfig,&amp;#160;pid&amp;#58;&amp;#160;28603,&amp;#160;execname&amp;#58;&amp;#160;dtrace&lt;br /&gt;
probefunc&amp;#58;&amp;#160;sysconfig,&amp;#160;pid&amp;#58;&amp;#160;28603,&amp;#160;execname&amp;#58;&amp;#160;dtrace&lt;br /&gt;
probefunc&amp;#58;&amp;#160;sysconfig,&amp;#160;pid&amp;#58;&amp;#160;28603,&amp;#160;execname&amp;#58;&amp;#160;dtrace&lt;br /&gt;
probefunc&amp;#58;&amp;#160;sigaction,&amp;#160;pid&amp;#58;&amp;#160;28603,&amp;#160;execname&amp;#58;&amp;#160;dtrace&lt;br /&gt;
probefunc&amp;#58;&amp;#160;sigaction,&amp;#160;pid&amp;#58;&amp;#160;28603,&amp;#160;execname&amp;#58;&amp;#160;dtrace&lt;br /&gt;
probefunc&amp;#58;&amp;#160;sigaction,&amp;#160;pid&amp;#58;&amp;#160;28603,&amp;#160;execname&amp;#58;&amp;#160;dtrace&lt;br /&gt;
probefunc&amp;#58;&amp;#160;sigaction,&amp;#160;pid&amp;#58;&amp;#160;28603,&amp;#160;execname&amp;#58;&amp;#160;dtrace&lt;br /&gt;
...&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, our script even took a note of all the &lt;b&gt;dtrace&lt;/b&gt; syscalls which was used to run the script. To exclude &lt;b&gt;dtrace&lt;/b&gt; from our data, we should alter the predicate to include one more condition:&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;/probefunc&amp;#160;!=&amp;#160;&quot;write&quot;&amp;#160;&amp;amp;&amp;amp;&amp;#160;execname&amp;#160;!=&amp;#160;&quot;dtrace&quot;/&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
this will result in our output including all the processes but &lt;b&gt;dtrace&lt;/b&gt;. In this example, we can see a couple of my rxvt terminals and java:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;probefunc&amp;#58;&amp;#160;pollsys,&amp;#160;pid&amp;#58;&amp;#160;28411,&amp;#160;execname&amp;#58;&amp;#160;rxvt&lt;br /&gt;
probefunc&amp;#58;&amp;#160;ioctl,&amp;#160;pid&amp;#58;&amp;#160;28411,&amp;#160;execname&amp;#58;&amp;#160;rxvt&lt;br /&gt;
probefunc&amp;#58;&amp;#160;ioctl,&amp;#160;pid&amp;#58;&amp;#160;28411,&amp;#160;execname&amp;#58;&amp;#160;rxvt&lt;br /&gt;
probefunc&amp;#58;&amp;#160;pollsys,&amp;#160;pid&amp;#58;&amp;#160;28411,&amp;#160;execname&amp;#58;&amp;#160;rxvt&lt;br /&gt;
probefunc&amp;#58;&amp;#160;pollsys,&amp;#160;pid&amp;#58;&amp;#160;28406,&amp;#160;execname&amp;#58;&amp;#160;rxvt&lt;br /&gt;
probefunc&amp;#58;&amp;#160;ioctl,&amp;#160;pid&amp;#58;&amp;#160;28406,&amp;#160;execname&amp;#58;&amp;#160;rxvt&lt;br /&gt;
probefunc&amp;#58;&amp;#160;ioctl,&amp;#160;pid&amp;#58;&amp;#160;28406,&amp;#160;execname&amp;#58;&amp;#160;rxvt&lt;br /&gt;
probefunc&amp;#58;&amp;#160;pollsys,&amp;#160;pid&amp;#58;&amp;#160;28406,&amp;#160;execname&amp;#58;&amp;#160;rxvt&lt;br /&gt;
probefunc&amp;#58;&amp;#160;lwp_cond_wait,&amp;#160;pid&amp;#58;&amp;#160;27870,&amp;#160;execname&amp;#58;&amp;#160;java_vm&lt;br /&gt;
probefunc&amp;#58;&amp;#160;lwp_cond_signal,&amp;#160;pid&amp;#58;&amp;#160;27870,&amp;#160;execname&amp;#58;&amp;#160;java_vm&lt;br /&gt;
probefunc&amp;#58;&amp;#160;lwp_cond_signal,&amp;#160;pid&amp;#58;&amp;#160;27870,&amp;#160;execname&amp;#58;&amp;#160;java_vm&lt;br /&gt;
probefunc&amp;#58;&amp;#160;lwp_cond_wait,&amp;#160;pid&amp;#58;&amp;#160;27870,&amp;#160;execname&amp;#58;&amp;#160;java_vm&lt;br /&gt;
...&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Predicates allow you to use any constants and variables defined earlier in the code, or standard ones, just like the ones shows in my examples. And if you keep in mind, that local variables are unique on thread-level, you can build up pretty complex constructions.&lt;br /&gt;
&lt;br /&gt;
Thread-specific local variables are defined with the help of &lt;b&gt;self&lt;/b&gt; indicator and a special &lt;b&gt;-&gt;&lt;/b&gt; operator, for instance: &lt;b&gt;self-&gt;flag = 1;&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
My next example will print only one message for each &lt;b&gt;write&lt;/b&gt; syscall of every thread. As you can see in the code, every time we note a thread returning from &lt;b&gt;write&lt;/b&gt; syscall, we mark this thread with a local variable, so that we know the thread has been processedt: &lt;b&gt;self-&gt;processed = 1;&lt;/b&gt;. Next time a &lt;b&gt;write&lt;/b&gt; probe fires for this thread, the predicate will take care of it and skip the probe code execution if needed:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;#!/usr/sbin/dtrace&amp;#160;-s&lt;br /&gt;
#pragma&amp;#160;D&amp;#160;option&amp;#160;quiet&lt;br /&gt;
&lt;br /&gt;
syscall&amp;#58;&amp;#58;write&amp;#58;return&lt;br /&gt;
/&amp;#160;self-&amp;#62;processed&amp;#160;==&amp;#160;0/&lt;br /&gt;
{&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;printf&amp;#40;&quot;tid&amp;#58;&amp;#160;%d,&amp;#160;pid&amp;#58;&amp;#160;%d,&amp;#160;execname&amp;#58;&amp;#160;%s\n&quot;,&amp;#160;tid,&amp;#160;pid,&amp;#160;execname&amp;#41;;&lt;br /&gt;
&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;self-&amp;#62;processed&amp;#160;=&amp;#160;1;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
As it&#039;s clearly seen, every thread has been registered only once:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;bb-code-title&quot;&gt;CODE:&lt;/div&gt;&lt;div class=&quot;bb-code&quot;&gt;tid&amp;#58;&amp;#160;1,&amp;#160;pid&amp;#58;&amp;#160;21583,&amp;#160;execname&amp;#58;&amp;#160;soffice.bin&lt;br /&gt;
tid&amp;#58;&amp;#160;4,&amp;#160;pid&amp;#58;&amp;#160;21750,&amp;#160;execname&amp;#58;&amp;#160;thunderbird-bin&lt;br /&gt;
tid&amp;#58;&amp;#160;4,&amp;#160;pid&amp;#58;&amp;#160;27406,&amp;#160;execname&amp;#58;&amp;#160;mozilla-bin&lt;br /&gt;
tid&amp;#58;&amp;#160;1,&amp;#160;pid&amp;#58;&amp;#160;27406,&amp;#160;execname&amp;#58;&amp;#160;mozilla-bin&lt;br /&gt;
tid&amp;#58;&amp;#160;1,&amp;#160;pid&amp;#58;&amp;#160;21450,&amp;#160;execname&amp;#58;&amp;#160;icewm&lt;br /&gt;
tid&amp;#58;&amp;#160;4,&amp;#160;pid&amp;#58;&amp;#160;21583,&amp;#160;execname&amp;#58;&amp;#160;soffice.bin&lt;br /&gt;
tid&amp;#58;&amp;#160;1,&amp;#160;pid&amp;#58;&amp;#160;21750,&amp;#160;execname&amp;#58;&amp;#160;thunderbird-bin&lt;br /&gt;
tid&amp;#58;&amp;#160;1,&amp;#160;pid&amp;#58;&amp;#160;28636,&amp;#160;execname&amp;#58;&amp;#160;dtrace&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
It&#039;s impossibly to even try to cover all different ways of using DTrace predicates in only one entry, so I think I&#039;ll call it a day. Next time I&#039;ll show a few more ways of making your life easier. 
    </content:encoded>

    <pubDate>Fri, 10 Dec 2004 19:52:52 +0300</pubDate>
    <guid isPermaLink="false">http:/solaris.reys.net/english/2004/10/dtrace_predicates</guid>
    <category>dtrace</category>
<category>dtrace</category>

</item>

</channel>
</rss>