| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21  | <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title xmlns:d="http://docbook.org/ns/docbook">5.2.6. Monitoring Changes to File Attributes</title><link rel="stylesheet" type="text/css" href="Common_Content/css/default.css" /><link rel="stylesheet" media="print" href="Common_Content/css/print.css" type="text/css" /><meta xmlns:d="http://docbook.org/ns/docbook" name="generator" content="not publican" /><meta xmlns:d="http://docbook.org/ns/docbook" name="package" content="" /><link rel="home" href="index.html" title="SystemTap Beginners Guide" /><link rel="up" href="mainsect-disk.html" title="5.2. Disk" /><link rel="prev" href="inodewatchsect.html" title="5.2.5. Monitoring Reads and Writes to a File" /><link rel="next" href="ioblktimesect.html" title="5.2.7. Periodically Print I/O Block Time" /></head><body><p id="title"></p><ul class="docnav top"><li class="previous"><a accesskey="p" href="inodewatchsect.html"><strong>Prev</strong></a></li><li class="home">SystemTap Beginners Guide</li><li class="next"><a accesskey="n" href="ioblktimesect.html"><strong>Next</strong></a></li></ul><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="inodewatch2sect"> </a>5.2.6. Monitoring Changes to File Attributes</h3></div></div></div><a id="id4987" class="indexterm"></a><a id="id4990" class="indexterm"></a><a id="id4993" class="indexterm"></a><a id="id4996" class="indexterm"></a><a id="id4999" class="indexterm"></a><div class="para">This section describes how to monitor if any processes are changing the attributes of a targeted file, in real time. </div><div class="para"><div xmlns:d="http://docbook.org/ns/docbook" class="title">inodewatch2.stp</div> <pre class="programlisting">#! /usr/bin/env stap global ATTR_MODE = 1 probe kernel.function("notify_change") { dev_nr = $dentry->d_inode->i_sb->s_dev inode_nr = $dentry->d_inode->i_ino if (dev_nr == MKDEV($1,$2) # major/minor device && inode_nr == $3 && $attr->ia_valid & ATTR_MODE) printf ("%s(%d) %s 0x%x/%u %o %d\n", execname(), pid(), ppfunc(), dev_nr, inode_nr, $attr->ia_mode, uid()) } </pre> </div><div class="para">Like <a class="xref" href="inodewatchsect.html#inodewatch">inodewatch.stp</a> from <a class="xref" href="inodewatchsect.html">Section 5.2.5, “Monitoring Reads and Writes to a File”</a>, <a class="xref" href="inodewatch2sect.html#inodewatch2">inodewatch2.stp</a> takes the targeted file's device number (in integer format) and <code class="command">inode</code> number as arguments. For more information on how to retrieve this information, refer to <a class="xref" href="inodewatchsect.html">Section 5.2.5, “Monitoring Reads and Writes to a File”</a>.</div><div class="para">The output for <a class="xref" href="inodewatch2sect.html#inodewatch2">inodewatch2.stp</a> is similar to that of <a class="xref" href="inodewatchsect.html#inodewatch">inodewatch.stp</a>, except that <a class="xref" href="inodewatch2sect.html#inodewatch2">inodewatch2.stp</a> also contains the attribute changes to the monitored file, as well as the ID of the user responsible (<code class="command">uid()</code>). <a class="xref" href="inodewatch2sect.html#inodewatch2output">Example 5.11, “inodewatch2.stp Sample Output”</a> shows the output of <a class="xref" href="inodewatch2sect.html#inodewatch2">inodewatch2.stp</a> while monitoring <code class="filename">/home/joe/bigfile</code> when user <code class="computeroutput">joe</code> executes <code class="command">chmod 777 /home/joe/bigfile</code> and <code class="command">chmod 666 /home/joe/bigfile</code>.</div><div class="example"><a id="inodewatch2output"> </a><p class="title"><strong>Example 5.11. <a class="xref" href="inodewatch2sect.html#inodewatch2">inodewatch2.stp</a> Sample Output</strong></p><div class="example-contents"><pre class="screen">chmod(17448) inode_setattr 0x800005/6011835 100777 500 chmod(17449) inode_setattr 0x800005/6011835 100666 500</pre></div></div></div><ul class="docnav"><li class="previous"><a accesskey="p" href="inodewatchsect.html"><strong>Prev</strong>5.2.5. Monitoring Reads and Writes to a File</a></li><li class="up"><a accesskey="u" href="#"><strong>Up</strong></a></li><li class="home"><a accesskey="h" href="index.html"><strong>Home</strong></a></li><li class="next"><a accesskey="n" href="ioblktimesect.html"><strong>Next</strong>5.2.7. Periodically Print I/O Block Time</a></li></ul></body></html> 
 |