From 63265337e2b74c4a34fb9b4d67d0a695c88e7d5e Mon Sep 17 00:00:00 2001 From: ddomingo Date: Wed, 10 Sep 2008 16:25:23 +1000 Subject: added new content for Understanding, events --- doc/SystemTap_Beginners_Guide/en-US/Book_Info.xml | 3 +- .../en-US/Introduction.xml | 11 ++- doc/SystemTap_Beginners_Guide/en-US/Scripts.xml | 106 +++++++++++++++++++-- 3 files changed, 106 insertions(+), 14 deletions(-) (limited to 'doc/SystemTap_Beginners_Guide') diff --git a/doc/SystemTap_Beginners_Guide/en-US/Book_Info.xml b/doc/SystemTap_Beginners_Guide/en-US/Book_Info.xml index 0058f768..09530ccc 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Book_Info.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Book_Info.xml @@ -5,10 +5,9 @@ SystemTap Beginners Guide For use with Red Hat Enterprise Linux 5 - 0.1 1.0 Red Hat Enterprise Linux - 5 + 5.3 1 This guide provides basic instructions on how to use SystemTap to monitor different subsystems of &PRODUCT; in finer detail. The SystemTap Beginners Guide is recommended for users who have taken RHCT or have a similar level of expertise in &PRODUCT;. diff --git a/doc/SystemTap_Beginners_Guide/en-US/Introduction.xml b/doc/SystemTap_Beginners_Guide/en-US/Introduction.xml index f60ab2f3..6f1b2a0a 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Introduction.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Introduction.xml @@ -19,13 +19,13 @@ -->
Goals - The goal of SystemTap is to provide infrastructure to monitor the running Linux kernel for detailed analysis. This can assist in identifying the underlying cause of a performance or functional problem. + SystemTap provides the infrastructure to monitor the running Linux kernel for detailed analysis. This can assist in identifying the underlying cause of a performance or functional problem. - Without SystemTap, monitoring the activity of a running kernel would require a tedious instrument, recompile, install, and reboot sequence. SystemTap is designed to eliminate this, allowing you to gather the same information by simply running its suite of tools against specific tapsets or SystemTap scripts. + Without SystemTap, monitoring the activity of a running kernel would require a tedious instrument, recompile, install, and reboot sequence. SystemTap is designed to eliminate this, allowing users to gather the same information by simply running its suite of tools against specific tapsets or SystemTap scripts. However, SystemTap was initially designed for users with intermediate to advanced knowledge of the kernel. This could present a steep learning curve for administrators or developers whose knowledge of the Linux kernel is little to none. - In line with that, the main goal of the SystemTap Beginner's Guide is two-fold: + In line with that, the main goals of the SystemTap Beginner's Guide are as follows: To introduce users to SystemTap, familiarize them with its architecture, and provide setup instructions for all kernel types. @@ -34,15 +34,16 @@ above, Short description on the underlying goals of SystemTap_Beginners_Guide, what we want to teach users. -
+ +
SystemTap Versus Other Monitoring Tools diff --git a/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml b/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml index abb087bc..24ab8a83 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Scripts.xml @@ -6,7 +6,7 @@ SystemTap Scripts - For the most part, SystemTap scripts are the foundation of each SystemTap session. The SystemTap scripts you use or write yourself instruct SystemTap on what type of information to trap, and what to do once that information is trapped. + For the most part, SystemTap scripts are the foundation of each SystemTap session. SystemTap scripts instruct SystemTap on what type of information to trap, and what to do once that information is trapped. @@ -15,7 +15,7 @@ Note - An event and its corresponding handler is collectively called a probe. A SystemTap script can have multiple probes, in the same manner that each event can have multiple corresponding handlers. + An event and its corresponding handler is collectively called a probe. A SystemTap script can have multiple probes. @@ -26,13 +26,105 @@ SystemTap scripts go one step further by allowing you more flexibility with regard to handlers. Events serve as the triggers for handlers to run; handlers can be specified to trap specified data and print it in a certain manner. + + Format + + SystemTap scripts use the file extension .stp, and are written in the following format: + + + +probe [event], +[another event] + +{ + [handler] + + exit() +} + + The exit() condition is optional, but it is recommended since it safely terminates the session once the script successfully traps the required information. + + Important + + is designed to introduce readers to the basics of SystemTap scripts. To understand SystemTap scripts better, it is advisable that you refer to ; each section therein provides a detailed explanation of the script, its events, handlers, and expected output. + + +
+ Events + + + SystemTap supports multiple events per probe; as shown in , multiple events are delimited by a comma (,). Sample [event]s include: + + + + + begin + + The startup of a SystemTap session; i.e. as soon as the SystemTap script is run. + + + + + end + + The end of a SystemTap session. + + + + + kernel.function("[function]") + + The entry to the kernel function function. For example, kernel.function("sys_open") refers to the "event" that the kernel function sys_open is used. To specify the return of the kernel function sys_open, append the return string to the event statement; i.e. kernel.function("sys_open").return. + + When defining functions, you can use asterisk (*) for wildcards. You can also trace the entry/exit of a function in a kernel source file. Consider the following example: +Wildcards and Kernel Source Files in an Event + +probe kernel.function("*@net/socket.c") { } +probe kernel.function("*@net/socket.c").return { } + + + +In the previous example, the first probe's event specifies the entry of ALL functions in the kernel source file net/socket.c. The second probe specifies the exit of all those functions. Note that in this example, no handler was specified; as such, no information will be displayed. + + + + + syscall.[system_call] + + The entry to the system call [system_call]. Similar to kerne.function, appending a return to the statement specifies the exit of the system call. For example, to specify the entry of the system call close, use syscall.close.return. + + To identify what system calls are made by a specific program/command, use strace command. + + + + + + + +
+ +
+ Handlers + + + SystemTap supports a wide variety of functions that can trap data when triggered by events. One way to display these functions is to use the print() + + + + -
- Format - - SystemTap scripts use the following format: -