summaryrefslogtreecommitdiffstats
path: root/SystemTap_Beginners_Guide/mainsect-disk.html
diff options
Diffstat (limited to 'SystemTap_Beginners_Guide/mainsect-disk.html')
-rw-r--r--SystemTap_Beginners_Guide/mainsect-disk.html16
1 files changed, 8 insertions, 8 deletions
diff --git a/SystemTap_Beginners_Guide/mainsect-disk.html b/SystemTap_Beginners_Guide/mainsect-disk.html
index 68002ea4..ebc4a2a1 100644
--- a/SystemTap_Beginners_Guide/mainsect-disk.html
+++ b/SystemTap_Beginners_Guide/mainsect-disk.html
@@ -1,7 +1,7 @@
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. Disk</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="useful-systemtap-scripts.html" title="Chapter 5. Useful SystemTap Scripts" /><link rel="prev" href="useful-systemtap-scripts.html" title="Chapter 5. Useful SystemTap Scripts" /><link rel="next" href="iotimesect.html" title="5.2.2. Tracking I/O Time For Each File Read or Write" /></head><body><p id="title"></p><ul class="docnav top"><li class="previous"><a accesskey="p" href="useful-systemtap-scripts.html"><strong>Prev</strong></a></li><li class="home">SystemTap Beginners Guide</li><li class="next"><a accesskey="n" href="iotimesect.html"><strong>Next</strong></a></li></ul><div class="section"><div class="titlepage"><div><div><h2 class="title"><a id="mainsect-disk"> 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. Disk</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="useful-systemtap-scripts.html" title="Chapter 5. Useful SystemTap Scripts" /><link rel="prev" href="useful-systemtap-scripts.html" title="Chapter 5. Useful SystemTap Scripts" /><link rel="next" href="iotimesect.html" title="5.2.2. Tracking I/O Time For Each File Read or Write" /></head><body><p id="title"></p><ul class="docnav top"><li class="previous"><a accesskey="p" href="useful-systemtap-scripts.html"><strong>Prev</strong></a></li><li class="home">SystemTap Beginners Guide</li><li class="next"><a accesskey="n" href="iotimesect.html"><strong>Next</strong></a></li></ul><div class="section"><div class="titlepage"><div><div><h2 class="title"><a id="mainsect-disk">
3 ⁠</a>5.2. Disk</h2></div></div></div><div class="para">The following sections showcase scripts that monitor disk and I/O activity.</div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="disktop"> 3 ⁠</a>5.2. Disk</h2></div></div></div><div class="para">The following sections showcase scripts that monitor disk and I/O activity.</div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="disktop">
4 ⁠</a>5.2.1. Summarizing Disk Read/Write Traffic</h3></div></div></div><a id="idm47006124420832" class="indexterm"></a><a id="idm47006129033056" class="indexterm"></a><a id="idm47006118735008" class="indexterm"></a><a id="idm47006118855440" class="indexterm"></a><a id="idm47006123068944" class="indexterm"></a><a id="idm47006119655616" class="indexterm"></a><a id="idm47006129871744" class="indexterm"></a><a id="idm47006122836928" class="indexterm"></a><div class="para">This section describes how to identify which processes are performing the heaviest disk reads/writes to the system.</div><div class="para"><div xmlns:d="http://docbook.org/ns/docbook" class="title">disktop.stp</div> 4 ⁠</a>5.2.1. Summarizing Disk Read/Write Traffic</h3></div></div></div><a id="idp71890967491216" class="indexterm"></a><a id="idp71890973802240" class="indexterm"></a><a id="idp71890960102896" class="indexterm"></a><a id="idp71890962328208" class="indexterm"></a><a id="idp71890964622528" class="indexterm"></a><a id="idp71890967353104" class="indexterm"></a><a id="idp71890971651248" class="indexterm"></a><a id="idp71890969295520" class="indexterm"></a><div class="para">This section describes how to identify which processes are performing the heaviest disk reads/writes to the system.</div><div class="para"><div xmlns:d="http://docbook.org/ns/docbook" class="title">disktop.stp</div>
5<pre class="programlisting">#!/usr/bin/env stap 5<pre class="programlisting">#!/usr/bin/env stap
6# 6#
7# Copyright (C) 2007 Oracle Corp. 7# Copyright (C) 2007 Oracle Corp.
@@ -20,21 +20,21 @@ global io_stat,device
20global read_bytes,write_bytes 20global read_bytes,write_bytes
21 21
22probe vfs.read.return { 22probe vfs.read.return {
23 if ($return&gt;0) { 23 if (returnval()&gt;0) {
24 if (devname!="N/A") {/*skip read from cache*/ 24 if (devname!="N/A") {/*skip read from cache*/
25 io_stat[pid(),execname(),uid(),ppid(),"R"] += $return 25 io_stat[pid(),execname(),uid(),ppid(),"R"] += returnval()
26 device[pid(),execname(),uid(),ppid(),"R"] = devname 26 device[pid(),execname(),uid(),ppid(),"R"] = devname
27 read_bytes += $return 27 read_bytes += returnval()
28 } 28 }
29 } 29 }
30} 30}
31 31
32probe vfs.write.return { 32probe vfs.write.return {
33 if ($return&gt;0) { 33 if (returnval()&gt;0) {
34 if (devname!="N/A") { /*skip update cache*/ 34 if (devname!="N/A") { /*skip update cache*/
35 io_stat[pid(),execname(),uid(),ppid(),"W"] += $return 35 io_stat[pid(),execname(),uid(),ppid(),"W"] += returnval()
36 device[pid(),execname(),uid(),ppid(),"W"] = devname 36 device[pid(),execname(),uid(),ppid(),"W"] = devname
37 write_bytes += $return 37 write_bytes += returnval()
38 } 38 }
39 } 39 }
40} 40}
@@ -74,7 +74,7 @@ probe end{
74 delete write_bytes 74 delete write_bytes
75} 75}
76</pre> 76</pre>
77</div><div class="para"><a class="xref" href="mainsect-disk.html#scriptdisktop">disktop.stp</a> outputs the top ten processes responsible for the heaviest reads/writes to disk. <a class="xref" href="mainsect-disk.html#disktopoutput">Example 5.6, “disktop.stp Sample Output”</a> displays a sample output for this script, and includes the following data per listed process:</div><div xmlns:d="http://docbook.org/ns/docbook" class="itemizedlist"><ul><li class="listitem"><div class="para"><code class="computeroutput">UID</code> — user ID. A user ID of <code class="computeroutput">0</code> refers to the root user.</div></li><li class="listitem"><div class="para"><code class="computeroutput">PID</code> — the ID of the listed process.</div></li><li class="listitem"><div class="para"><code class="computeroutput">PPID</code> — the process ID of the listed process's <span class="emphasis"><em>parent process</em></span>.</div></li><li class="listitem"><div class="para"><code class="computeroutput">CMD</code> — the name of the listed process.</div></li><li class="listitem"><div class="para"><code class="computeroutput">DEVICE</code> — which storage device the listed process is reading from or writing to.</div></li><li class="listitem"><div class="para"><code class="computeroutput">T</code> — the type of action performed by the listed process; <code class="computeroutput">W</code> refers to write, while <code class="computeroutput">R</code> refers to read.</div></li><li class="listitem"><div class="para"><code class="computeroutput">BYTES</code> — the amount of data read to or written from disk.</div></li></ul></div><a id="idm47006128207904" class="indexterm"></a><a id="idm47006125942384" class="indexterm"></a><a id="idm47006118410368" class="indexterm"></a><div class="para">The time and date in the output of <a class="xref" href="mainsect-disk.html#scriptdisktop">disktop.stp</a> is returned by the functions <code class="command">ctime()</code> and <code class="command">gettimeofday_s()</code>. <code class="command">ctime()</code> derives calendar time in terms of seconds passed since the Unix epoch (January 1, 1970). <code class="command">gettimeofday_s()</code> counts the <span class="emphasis"><em>actual</em></span> number of seconds since Unix epoch, which gives a fairly accurate human-readable timestamp for the output.</div><a id="idm47006127590304" class="indexterm"></a><a id="idm47006121644320" class="indexterm"></a><a id="idm47006123284912" class="indexterm"></a><div class="para"> 77</div><div class="para"><a class="xref" href="mainsect-disk.html#scriptdisktop">disktop.stp</a> outputs the top ten processes responsible for the heaviest reads/writes to disk. <a class="xref" href="mainsect-disk.html#disktopoutput">Example 5.6, “disktop.stp Sample Output”</a> displays a sample output for this script, and includes the following data per listed process:</div><div xmlns:d="http://docbook.org/ns/docbook" class="itemizedlist"><ul><li class="listitem"><div class="para"><code class="computeroutput">UID</code> — user ID. A user ID of <code class="computeroutput">0</code> refers to the root user.</div></li><li class="listitem"><div class="para"><code class="computeroutput">PID</code> — the ID of the listed process.</div></li><li class="listitem"><div class="para"><code class="computeroutput">PPID</code> — the process ID of the listed process's <span class="emphasis"><em>parent process</em></span>.</div></li><li class="listitem"><div class="para"><code class="computeroutput">CMD</code> — the name of the listed process.</div></li><li class="listitem"><div class="para"><code class="computeroutput">DEVICE</code> — which storage device the listed process is reading from or writing to.</div></li><li class="listitem"><div class="para"><code class="computeroutput">T</code> — the type of action performed by the listed process; <code class="computeroutput">W</code> refers to write, while <code class="computeroutput">R</code> refers to read.</div></li><li class="listitem"><div class="para"><code class="computeroutput">BYTES</code> — the amount of data read to or written from disk.</div></li></ul></div><a id="idp71890973828960" class="indexterm"></a><a id="idp71890965953680" class="indexterm"></a><a id="idp71890961269136" class="indexterm"></a><div class="para">The time and date in the output of <a class="xref" href="mainsect-disk.html#scriptdisktop">disktop.stp</a> is returned by the functions <code class="command">ctime()</code> and <code class="command">gettimeofday_s()</code>. <code class="command">ctime()</code> derives calendar time in terms of seconds passed since the Unix epoch (January 1, 1970). <code class="command">gettimeofday_s()</code> counts the <span class="emphasis"><em>actual</em></span> number of seconds since Unix epoch, which gives a fairly accurate human-readable timestamp for the output.</div><a id="idp71890960130112" class="indexterm"></a><a id="idp71890971853472" class="indexterm"></a><a id="idp71890974112448" class="indexterm"></a><div class="para">
78 In this script, the <code class="command">$return</code> is a local variable that stores the 78 In this script, the <code class="command">$return</code> is a local variable that stores the
79 actual number of bytes each process reads or writes from the virtual file system. 79 actual number of bytes each process reads or writes from the virtual file system.
80 <code class="command">$return</code> can only be used in return probes (for example, 80 <code class="command">$return</code> can only be used in return probes (for example,