Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > 95299258dbdf9a86cefd89b97c0d81e5 > files > 128

systemtap-1.2-1.fc13.i686.rpm

<?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>Chapter 3. Understanding How SystemTap Works</title><link rel="stylesheet" href="./Common_Content/css/default.css" type="text/css" /><meta name="generator" content="publican 1.6" /><meta name="package" content="Systemtap-SystemTap_Beginners_Guide-1.0-en-US-2.0-2" /><link rel="home" href="index.html" title="SystemTap Beginners Guide" /><link rel="up" href="index.html" title="SystemTap Beginners Guide" /><link rel="prev" href="using-usage.html" title="2.3. Running SystemTap Scripts" /><link rel="next" href="scripts.html" title="3.2. SystemTap Scripts" /></head><body class=""><p id="title"><a class="left" href="http://www.fedoraproject.org"><img src="Common_Content/images/image_left.png" alt="Product Site" /></a><a class="right" href="http://docs.fedoraproject.org"><img src="Common_Content/images/image_right.png" alt="Documentation Site" /></a></p><ul class="docnav"><li class="previous"><a accesskey="p" href="using-usage.html"><strong>Prev</strong></a></li><li class="next"><a accesskey="n" href="scripts.html"><strong>Next</strong></a></li></ul><div xml:lang="en-US" class="chapter" title="Chapter 3. Understanding How SystemTap Works" lang="en-US"><div class="titlepage"><div><div><h2 class="title" id="understanding-how-systemtap-works">Chapter 3. Understanding How SystemTap Works</h2></div></div></div><div class="toc"><dl><dt><span class="section"><a href="understanding-how-systemtap-works.html#understanding-architecture-tools">3.1. Architecture</a></span></dt><dt><span class="section"><a href="scripts.html">3.2. SystemTap Scripts</a></span></dt><dd><dl><dt><span class="section"><a href="scripts.html#systemtapscript-events">3.2.1. Event</a></span></dt><dt><span class="section"><a href="systemtapscript-handler.html">3.2.2. Systemtap Handler/Body</a></span></dt></dl></dd><dt><span class="section"><a href="scriptconstructions.html">3.3. Basic SystemTap Handler Constructs</a></span></dt><dd><dl><dt><span class="section"><a href="scriptconstructions.html#variablesconstructs">3.3.1. Variables</a></span></dt><dt><span class="section"><a href="handlerconditionalstatements.html">3.3.2. Conditional Statements</a></span></dt><dt><span class="section"><a href="commandlineargssect.html">3.3.3. Command-Line Arguments</a></span></dt></dl></dd><dt><span class="section"><a href="associativearrays.html">3.4. Associative Arrays</a></span></dt><dt><span class="section"><a href="arrayoperators.html">3.5. Array Operations in SystemTap</a></span></dt><dd><dl><dt><span class="section"><a href="arrayoperators.html#arrayops-assignvalue">3.5.1. Assigning an Associated Value</a></span></dt><dt><span class="section"><a href="arrayops-readvalues.html">3.5.2. Reading Values From Arrays</a></span></dt><dt><span class="section"><a href="arrayops-increment.html">3.5.3. Incrementing Associated Values</a></span></dt><dt><span class="section"><a href="arrayops-foreach.html">3.5.4. Processing Multiple Elements in an Array</a></span></dt><dt><span class="section"><a href="arrayops-deleting.html">3.5.5. Clearing/Deleting Arrays and Array Elements</a></span></dt><dt><span class="section"><a href="arrayops-conditionals.html">3.5.6. Using Arrays in Conditional Statements</a></span></dt><dt><span class="section"><a href="arrayops-aggregates.html">3.5.7. Computing for Statistical Aggregates</a></span></dt></dl></dd><dt><span class="section"><a href="understanding-tapsets.html">3.6. Tapsets</a></span></dt></dl></div><a id="id3033552" class="indexterm"></a><div class="para">
		SystemTap allows users to write and reuse simple scripts to deeply examine the activities of a running Linux system. These scripts can be designed to extract data, filter it, and summarize it quickly (and safely), enabling the diagnosis of complex performance (or even functional) problems.
	</div><a id="id3033539" class="indexterm"></a><a id="id3033524" class="indexterm"></a><a id="id3033490" class="indexterm"></a><div class="para">
		The essential idea behind a SystemTap script is to name <span class="emphasis"><em>events</em></span>, and to give them <span class="emphasis"><em>handlers</em></span>. When SystemTap runs the script, SystemTap monitors for the event; once the event occurs, the Linux kernel then runs the handler as a quick sub-routine, then resumes.
	</div><a id="id3033475" class="indexterm"></a><a id="id3033466" class="indexterm"></a><div class="para">
		There are several kind of events; entering/exiting a function, timer expiration, session termination, etc. A handler is a series of script language statements that specify the work to be done whenever the event occurs. This work normally includes extracting data from the event context, storing them into internal variables, and printing results.
	</div><div class="section" title="3.1. Architecture"><div class="titlepage"><div><div><h2 class="title" id="understanding-architecture-tools">3.1. Architecture</h2></div></div></div><a id="id3033429" class="indexterm"></a><a id="id3033417" class="indexterm"></a><a id="id3033408" class="indexterm"></a><div class="para">
			A SystemTap session begins when you run a SystemTap script. This session occurs in the following fashion:
		</div><div class="procedure" id="systemtapsession"><h6>Procedure 3.1. SystemTap Session</h6><a id="id3033386" class="indexterm"></a><a id="id3033372" class="indexterm"></a><a id="id3072501" class="indexterm"></a><ol class="1"><li class="step" title="Step 1"><div class="para">
					First, SystemTap checks the script against the existing tapset library (normally in <code class="filename">/usr/share/systemtap/tapset/</code> for any tapsets used. SystemTap will then substitute any located tapsets with their corresponding definitions in the tapset library.
				</div></li><li class="step" title="Step 2"><div class="para">
					SystemTap then translates the script to C, running the system C compiler to create a kernel module from it. The tools that perform this step are contained in the <code class="filename">systemtap</code> package (refer to <a class="xref" href="using-systemtap.html#installproper" title="2.1.1. Installing SystemTap">Section 2.1.1, “Installing SystemTap”</a> for more information).
				</div></li><li class="step" title="Step 3"><div class="para">
					SystemTap loads the module, then enables all the probes (events and handlers) in the script. The <code class="command">staprun</code> in the <code class="filename">systemtap-runtime</code> package (refer to <a class="xref" href="using-systemtap.html#installproper" title="2.1.1. Installing SystemTap">Section 2.1.1, “Installing SystemTap”</a> for more information) provides this functionality.
				</div></li><li class="step" title="Step 4"><div class="para">
					As the events occur, their corresponding handlers are executed.
				</div></li><li class="step" title="Step 5"><div class="para">
					Once the SystemTap session is terminated, the probes are disabled, and the kernel module is unloaded.
				</div></li></ol></div><div class="para">
			This sequence is driven from a single command-line program: <code class="command">stap</code>. This program is SystemTap's main front-end tool. For more information about <code class="command">stap</code>, refer to <code class="command">man stap</code> (once SystemTap is properly installed on your machine).
		</div></div></div><ul class="docnav"><li class="previous"><a accesskey="p" href="using-usage.html"><strong>Prev</strong>2.3. Running SystemTap Scripts</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="scripts.html"><strong>Next</strong>3.2. SystemTap Scripts</a></li></ul></body></html>