summaryrefslogtreecommitdiffstats
path: root/SystemTap_Beginners_Guide/inodewatchsect.html
diff options
Diffstat (limited to 'SystemTap_Beginners_Guide/inodewatchsect.html')
-rw-r--r--SystemTap_Beginners_Guide/inodewatchsect.html20
1 files changed, 11 insertions, 9 deletions
diff --git a/SystemTap_Beginners_Guide/inodewatchsect.html b/SystemTap_Beginners_Guide/inodewatchsect.html
index 83f2c8de..4b06943b 100644
--- a/SystemTap_Beginners_Guide/inodewatchsect.html
+++ b/SystemTap_Beginners_Guide/inodewatchsect.html
@@ -1,7 +1,8 @@
1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!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.5. Monitoring Reads and Writes to a File</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="publican v4.0.0" /><meta xmlns:d="http://docbook.org/ns/docbook" name="package" content="SystemTap-SystemTap_Beginners_Guide-2.6-en-US-2.0-1" /><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="traceio2sect.html" title="5.2.4. I/O Monitoring (By Device)" /><link rel="next" href="inodewatch2sect.html" title="5.2.6. Monitoring Changes to File Attributes" /></head><body><p id="title"><a class="left" href="https://fedorahosted.org/publican"><img alt="Product Site" src="Common_Content/images//image_left.png" /></a><a class="right" href="https://fedorahosted.org/publican"><img alt="Documentation Site" src="Common_Content/images//image_right.png" /></a></p><ul class="docnav top"><li class="previous"><a accesskey="p" href="traceio2sect.html"><strong>Prev</strong></a></li><li class="home">SystemTap Beginners Guide</li><li class="next"><a accesskey="n" href="inodewatch2sect.html"><strong>Next</strong></a></li></ul><div xml:lang="en-US" class="section" lang="en-US"><div class="titlepage"><div><div><h3 class="title"><a id="inodewatchsect"></a>5.2.5. Monitoring Reads and Writes to a File</h3></div></div></div><a id="idm47951462922528" class="indexterm"></a><a id="idm47951454720960" class="indexterm"></a><a id="idm47951416392928" class="indexterm"></a><a id="idm47951455814784" class="indexterm"></a><a id="idm47951459861888" class="indexterm"></a><a id="idm47951469034048" class="indexterm"></a><div class="para"> 2<!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.5. Monitoring Reads and Writes to a File</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="publican v4.1.3" /><meta xmlns:d="http://docbook.org/ns/docbook" name="package" content="SystemTap-SystemTap_Beginners_Guide-2.6-en-US-2.0-1" /><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="traceio2sect.html" title="5.2.4. I/O Monitoring (By Device)" /><link rel="next" href="inodewatch2sect.html" title="5.2.6. Monitoring Changes to File Attributes" /></head><body><p id="title"><a class="left" href="https://fedorahosted.org/publican"><img alt="Product Site" src="Common_Content/images//image_left.png" /></a><a class="right" href="https://fedorahosted.org/publican"><img alt="Documentation Site" src="Common_Content/images//image_right.png" /></a></p><ul class="docnav top"><li class="previous"><a accesskey="p" href="traceio2sect.html"><strong>Prev</strong></a></li><li class="home">SystemTap Beginners Guide</li><li class="next"><a accesskey="n" href="inodewatch2sect.html"><strong>Next</strong></a></li></ul><div xml:lang="en-US" class="section" lang="en-US"><div class="titlepage"><div><div><h3 class="title"><a id="inodewatchsect">
3 ⁠</a>5.2.5. Monitoring Reads and Writes to a File</h3></div></div></div><a id="idm214013453232" class="indexterm"></a><a id="idm213974358944" class="indexterm"></a><a id="idm213971871008" class="indexterm"></a><a id="idm213974755760" class="indexterm"></a><a id="idm214026640048" class="indexterm"></a><a id="idm214012314320" class="indexterm"></a><div class="para">
3 This section describes how to monitor reads from and writes to a file in real time. 4 This section describes how to monitor reads from and writes to a file in real time.
4 </div><div class="formalpara"><div xmlns:d="http://docbook.org/ns/docbook" class="title">inodewatch.stp</div> 5 </div><div class="para"><div xmlns:d="http://docbook.org/ns/docbook" class="title">inodewatch.stp</div>
5 6
6<pre class="programlisting">#! /usr/bin/env stap 7<pre class="programlisting">#! /usr/bin/env stap
7 8
@@ -11,24 +12,25 @@ probe vfs.write, vfs.read
11 if (dev == MKDEV($1,$2) # major/minor device 12 if (dev == MKDEV($1,$2) # major/minor device
12 &amp;&amp; ino == $3) 13 &amp;&amp; ino == $3)
13 printf ("%s(%d) %s 0x%x/%u\n", 14 printf ("%s(%d) %s 0x%x/%u\n",
14 execname(), pid(), probefunc(), dev, ino) 15 execname(), pid(), ppfunc(), dev, ino)
15} 16}
16</pre> 17</pre>
17 </div><div class="para"> 18 </div><div class="para">
18 <a class="xref" href="inodewatchsect.html#inodewatch">inodewatch.stp</a> takes the following information about the file as arguments on the command line: 19 <a class="xref" href="inodewatchsect.html#inodewatch">inodewatch.stp</a> takes the following information about the file as arguments on the command line:
19 </div><a id="idm47951460633088" class="indexterm"></a><a id="idm47951476100368" class="indexterm"></a><a id="idm47951475850208" class="indexterm"></a><a id="idm47951474957296" class="indexterm"></a><div xmlns:d="http://docbook.org/ns/docbook" class="itemizedlist"><ul><li class="listitem"><div class="para"> 20 </div><a id="idm213972707568" class="indexterm"></a><a id="idm214018744944" class="indexterm"></a><a id="idm213967959744" class="indexterm"></a><a id="idm214026294656" class="indexterm"></a><div xmlns:d="http://docbook.org/ns/docbook" class="itemizedlist"><ul><li class="listitem"><div class="para">
20 The file's major device number. 21 The file's major device number.
21 </div></li><li class="listitem"><div class="para"> 22 </div></li><li class="listitem"><div class="para">
22 The file's minor device number. 23 The file's minor device number.
23 </div></li><li class="listitem"><div class="para"> 24 </div></li><li class="listitem"><div class="para">
24 The file's <code class="command">inode</code> number. 25 The file's <code class="command">inode</code> number.
25 </div></li></ul></div><a id="idm47951471156640" class="indexterm"></a><a id="idm47951475123024" class="indexterm"></a><a id="idm47951462796400" class="indexterm"></a><div class="para"> 26 </div></li></ul></div><a id="idm214015608816" class="indexterm"></a><a id="idm214008596400" class="indexterm"></a><a id="idm214026189984" class="indexterm"></a><div class="para">
26 To get this information, use <code class="command">stat -c '%D %i' <em class="replaceable"><code>filename</code></em></code>, where <code class="command"><em class="replaceable"><code>filename</code></em></code> is an absolute path. 27 To get this information, use <code class="command">stat -c '%D %i' <em class="replaceable">filename</em></code>, where <code class="command"><em class="replaceable">filename</em></code> is an absolute path.
27 </div><div class="para"> 28 </div><div class="para">
28 For instance: to monitor <code class="filename">/etc/crontab</code>, run <code class="command">stat -c '%D %i' /etc/crontab</code> first. This gives the following output: 29 For instance: to monitor <code class="filename">/etc/crontab</code>, run <code class="command">stat -c '%D %i' /etc/crontab</code> first. This gives the following output:
29 </div><pre class="screen">805 1078319</pre><a id="idm47951469525008" class="indexterm"></a><a id="idm47951416212576" class="indexterm"></a><a id="idm47951457058176" class="indexterm"></a><div class="para"> 30 </div><pre class="screen">805 1078319</pre><a id="idm213968983872" class="indexterm"></a><a id="idm213968985008" class="indexterm"></a><a id="idm214018697696" class="indexterm"></a><div class="para">
30 <code class="computeroutput">805</code> is the base-16 (hexadecimal) device number. The lower two digits are the minor device number and the upper digits are the major number. <code class="computeroutput">1078319</code> is the <code class="command">inode</code> number. To start monitoring <code class="filename">/etc/crontab</code>, run <code class="command">stap inodewatch.stp 0x8 0x05 1078319</code> (The <code class="command">0x</code> prefixes indicate base-16 values. 31 <code class="computeroutput">805</code> is the base-16 (hexadecimal) device number. The lower two digits are the minor device number and the upper digits are the major number. <code class="computeroutput">1078319</code> is the <code class="command">inode</code> number. To start monitoring <code class="filename">/etc/crontab</code>, run <code class="command">stap inodewatch.stp 0x8 0x05 1078319</code> (The <code class="command">0x</code> prefixes indicate base-16 values.
31 </div><div class="para"> 32 </div><div class="para">
32 The output of this command contains the name and ID of any process performing a read/write, the function it is performing (that is, <code class="command">vfs_read</code> or <code class="command">vfs_write</code>), the device number (in hex format), and the <code class="command">inode</code> number. <a class="xref" href="inodewatchsect.html#inodewatchoutput">Example 5.10, “inodewatch.stp Sample Output”</a> contains the output of <code class="command">stap inodewatch.stp 0x8 0x05 1078319</code> (when <code class="command">cat /etc/crontab</code> is executed while the script is running) : 33 The output of this command contains the name and ID of any process performing a read/write, the function it is performing (that is, <code class="command">vfs_read</code> or <code class="command">vfs_write</code>), the device number (in hex format), and the <code class="command">inode</code> number. <a class="xref" href="inodewatchsect.html#inodewatchoutput">Example 5.10, “inodewatch.stp Sample Output”</a> contains the output of <code class="command">stap inodewatch.stp 0x8 0x05 1078319</code> (when <code class="command">cat /etc/crontab</code> is executed while the script is running) :
33 </div><div class="example"><a id="inodewatchoutput"></a><p class="title"><strong>Example 5.10. <a class="xref" href="inodewatchsect.html#inodewatch">inodewatch.stp</a> Sample Output</strong></p><div class="example-contents"><pre class="screen">cat(16437) vfs_read 0x800005/1078319 34 </div><div class="example"><a id="inodewatchoutput">
34cat(16437) vfs_read 0x800005/1078319</pre></div></div><br class="example-break" /></div><ul class="docnav"><li class="previous"><a accesskey="p" href="traceio2sect.html"><strong>Prev</strong>5.2.4. I/O Monitoring (By Device)</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="inodewatch2sect.html"><strong>Next</strong>5.2.6. Monitoring Changes to File Attributes</a></li></ul></body></html> \ No newline at end of file 35 ⁠</a><p class="title"><strong>Example 5.10. <a class="xref" href="inodewatchsect.html#inodewatch">inodewatch.stp</a> Sample Output</strong></p><div class="example-contents"><pre class="screen">cat(16437) vfs_read 0x800005/1078319
36cat(16437) vfs_read 0x800005/1078319</pre></div></div></div><ul class="docnav"><li class="previous"><a accesskey="p" href="traceio2sect.html"><strong>Prev</strong>5.2.4. I/O Monitoring (By Device)</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="inodewatch2sect.html"><strong>Next</strong>5.2.6. Monitoring Changes to File Attributes</a></li></ul></body></html> \ No newline at end of file