From 3266a355a8d41eee4e49ce6aa841a5166e3f6fe9 Mon Sep 17 00:00:00 2001 From: William Cohen Date: Tue, 4 Nov 2008 01:43:48 -0500 Subject: Include staprep.sh script and make use of it in describing Systemtap setup. --- .../en-US/CrossInstrumenting.xml | 295 +++++++++++++------- .../en-US/Installation.xml | 308 +++++++++++---------- .../en-US/extras/stapprep.sh | 35 +++ 3 files changed, 404 insertions(+), 234 deletions(-) create mode 100644 doc/SystemTap_Beginners_Guide/en-US/extras/stapprep.sh (limited to 'doc/SystemTap_Beginners_Guide') diff --git a/doc/SystemTap_Beginners_Guide/en-US/CrossInstrumenting.xml b/doc/SystemTap_Beginners_Guide/en-US/CrossInstrumenting.xml index b0d712bd..6a91beab 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/CrossInstrumenting.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/CrossInstrumenting.xml @@ -2,35 +2,61 @@ -
- Cross-Instrumentation +
+ Generating Instrumentation for Other Computers -cross-compiling script from here: http://sources.redhat.com/ml/systemtap/2008-q3/msg00310.html + + cross-compiling script from here: + http://sources.redhat.com/ml/systemtap/2008-q3/msg00310.html + -above; add short description, significance, howto, script (test first) - - When users run a SystemTap script, SystemTap builds a kernel module out of that script. SystemTap then loads the module onto the kernel, allowing it to extract the specified data directly from the kernel (refer to in for more information). - + + above; add short description, significance, howto, script (test first) + + + + When users run a SystemTap script, SystemTap builds a kernel module out of + that script. SystemTap then loads the module onto the kernel, allowing it to + extract the specified data directly from the kernel (refer to + in + for more information). + - - Normally, however, SystemTap scripts can only be run on systems where SystemTap is deployed (as in ). This could mean that if you want to run SystemTap on ten systems, you'd need to deploy SystemTap on all those systems. - - - - In some cases, this may be neither feasible nor desired. For instance, running SystemTap on 25 systems — all of which are using a different kernel — may require fully deploying SystemTap on all 25 machines. This task may even increase in complexity if some (or all) systems are remote from the administrator. Sometimes, corporate policy may prohibit an administrator from installing a debug version of an RPM on specific machines, which will prevent the deployment of SystemTap altogether. - + + Normally, however, SystemTap scripts can only be run on systems where + SystemTap is deployed (as in ). This could + mean that if you want to run SystemTap on ten systems, you would need to + deploy SystemTap on all those systems. In some cases, + this may be neither feasible nor desired to fully deploy SystemTap on those + systems. For instance corporate policy may prohibit an administrator from + installing RPMs that proved debug information or compilers on specific + machines, which will prevent the deployment of SystemTap. + - - To work around this, you can resort to cross-instrumentation. Cross-instrumentation is the process of compiling a kernel module (out of a SystemTap script) to be used on a different machine. This process offers the following benefits: - + + To work around this, you can resort to + cross-instrumentation. Cross-instrumentation is the + process of generating SystemTap instrumentation module from a SystemTap + script on one computer to be used on another machine. This process offers + the following benefits: + - - The debug RPMs for all target machines can be installed into one system: the host machine. - - Each target machine only needs one RPM to load and use the compiled kernel module: systemtap-runtime. - - You do not need to restart any of the target machines. - + + + + The debug RPMs for various machines can be installed on a single system: + the host machine. + + + + + + Each target machine only needs one RPM to installed to use + the generated SystemTap instrumentation module: + systemtap-runtime. + + + - -Note -For the sake of simplicity, we will be using the following terms throughout this section: - - - instrumentation module — the kernel module built from a SystemTap script; i.e. the SystemTap module is built on the host system, and will be loaded on the target kernel of target system. + + Note + + + For the sake of simplicity, we will be using the following terms + throughout this section: + + + + + + instrumentation module — the + kernel module built from a SystemTap script; i.e. the + SystemTap module is built on the host + system, and will be loaded on the target + kernel of target + system. + + - host system — the system on which you compile the kernel modules (from SystemTap scripts), to be loaded on target systems. + + + host system — the system on + which you compile the instrumentation modules (from SystemTap + scripts), to be loaded on target + systems. + + - target system — the system for which you are building the instrumentation module (from SystemTap scripts). + + + target system — the system for which you + are building the instrumentation module (from + SystemTap scripts). + + - target kernel — the kernel of the target system. This is the kernel on which you wish to load/run the instrumentation module. - - + + + target kernel — the kernel of + the target system. This is the kernel on which + you wish to load/run the instrumentation + module. + + + + - - - Configuring a Host System and Target Systems - - - Configure yum on the host system to point to a repository containing the necessary debug RPMs for the target kernels. The following yum repository file (which you can add to /etc/yum.repos.d/ points to a popular debug RPM repository for i386 systems running Red Hat Enterprise Linux 5: - -[rhel-debuginfo] -name=Red Hat Enterprise Linux $releasever - $basearch - Debug - -baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Client/en/os/i386/Debuginfo/ -enabled=1 - - - - - Deploy SystemTap on the host system. It is from this machine that you will be building the instrumentation module (to be used on target systems). For instructions on how to deploy SystemTap, refer to . - - - - Install the target kernel on the host system. If multiple target systems use different target kernel, you will need to install each target kernel. - - - - - Install the corresponding debug RPMs for the target kernel of each target system on the host system. - - - - Install yum-utils on the host system. - - - - Install systemtap-runtime on each target system. - - -After performing , you can now build the instrumentation module (for any target system) on the host system. + + Configuring a Host System and Target Systems -To build the instrumentation module, run the following command on the host system (be sure to specify the appropriate values): + + + Install the systemtap-runtime RPM on each + target system. + + -stap -r kernel version script -m module name + + + Determine the kernel running on each target system + by running the by running uname -r on each + target system: + + -Here, kernel version refers to the version of target kernel (including the architecture notation), script refers to the script to be converted into an instrumentation module, and instrumentation name is the desired name of the instrumentation module. + + + Install SystemTap on the host system. It is from + this machine that you will be building the instrumentation + module (to be used on target + systems). For instructions on how to install SystemTap, refer + to . + + - - Note - To determine the architecture notation of a running kernel, run uname -m. - - + + + Using the target kernel version determined earlier, + install the target kernel and related RPMs on the + host system by the method described in . If multiple target + systems use different target kernels, + you will need to repeat this step for each different kernel used on the + target systems. + + -Once the the instrumentation module is compiled, copy it to the target system and load it using: + -staprun instrumentation + + After performing , you can now build the + instrumentation module (for any target + system) on the host system. + - - For example, to create the instrumentation module simple.ko from a SystemTap script named simple.stp for the target kernel 2.6.25.9-76.fc9 (on i686 architecture), use the following command: - - -stap -r 2.6.25.9-76.fc9.x86_64 simple.stp -m module + + To build the instrumentation module, run the following + command on the host system (be sure to specify the + appropriate values): + + + + stap -r kernel_version + script -m + module_name + + + + Here, kernel_version refers to + the version of the target kernel (the output of + uname -r on the target machine), + script refers to the script to + be converted into an instrumentation module, and + module_name is the desired + name of the instrumentation module. + + + + Note + + To determine the architecture notation of a running kernel, run + uname -m. + + + + + Once the the instrumentation module is compiled, copy + it to the target system and load it using: + + + + staprun module_name.ko + + + + For example, to create the instrumentation module + simple.ko from a SystemTap script named + simple.stp for the target kernel + 2.6.18-92.1.10.el5 (on x86_64 architecture), use the following command: + + + + stap -r 2.6.18-92.1.10.el5 -e 'probe vfs.read {exit()}' -m simple + -This will create a module named simple.ko. To use the instrumentation module simple.ko, copy it to the target system and run the following command (on the target system): + + This will create a module named simple.ko. To use the + instrumentation module simple.ko, + copy it to the target system and run the following + command (on the target system): + -staprun simple.ko + staprun simple.ko - - Important - The host system must be the same architecture as the target system in order for the instrumentation module to work. - + + Important + + The host system must be the same architecture and + running the same distribution of Linux as the target + system in order for the instrumentation + module to work. + + -
\ No newline at end of file +
diff --git a/doc/SystemTap_Beginners_Guide/en-US/Installation.xml b/doc/SystemTap_Beginners_Guide/en-US/Installation.xml index 1bde952e..2d5eb98b 100644 --- a/doc/SystemTap_Beginners_Guide/en-US/Installation.xml +++ b/doc/SystemTap_Beginners_Guide/en-US/Installation.xml @@ -4,161 +4,189 @@
- Setup and Installation - - required packages, installation thru yum, repos (?); possibly, a script to install all required packages - - - - notes in ~/Desktop/SystemTap/aug21chatlog and ~/Desktop/SystemTap/noted_wcohenmeeting - - - - To deploy SystemTap, you need to install the SystemTap packages along with the corresponding set of -devel, -debuginfo and -debuginfo-common packages for your kernel. This means that if your system has multiple kernels installed, and you wish to use SystemTap on more than one kernel kernel, you will need to install the -devel and -debuginfo packages for each of those kernel versions. - - - - These procedures will be discussed in detail in the following sections. - - - - Important - Many users confuse -debuginfo with -debug. Remember that the deployment of SystemTap requires the installation of the -debuginfo version of the kernel, not the -debug version. - - -
- Preparing For Installation - - To view what kernels and kernel versions are installed on your system, check the contents of /boot. Each installed kernel/kernel version has a corresponding vmlinuz-kernel version there. - - - - To determine what kernel your system is currently using, use: - - - -uname -r - - - - - Most -debuginfo packages for Red Hat Enterprise Linux 5 can be found at the following link (under arch/Debuginfo, where arch is the appropriate architecture for your system: - - - ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Client/en/os/ - - find any other such repository, if only for RHEL + Setup and Installation + + required packages, installation thru yum, repos (?); possibly, a script to install all required packages + + + + notes in ~/Desktop/SystemTap/aug21chatlog and ~/Desktop/SystemTap/noted_wcohenmeeting + + To deploy SystemTap, you need to install the SystemTap packages along + with the corresponding set of -devel, + -debuginfo and -debuginfo-common + packages for your kernel. If your system has multiple kernels installed, and + you wish to use SystemTap on more than one kernel kernel, you will need to + install the -devel and -debuginfo + packages for each of those kernel versions. + + These procedures will be discussed in detail in the following sections. + -
- + + Important Many users confuse + -debuginfo with -debug. Remember + that the deployment of SystemTap requires the installation of the + -debuginfo version of the kernel, not the + -debug version. + +
- Deploying SystemTap - - - Once you've decided which kernels with which you need to use SystemTap with, install the following packages: - - - systemtap - systemtap-runtime - + Installating SystemTap + + For the Systemtap Beginner's Guide the following two SystemTap RPMs + need to be installed: + + + + systemtap + systemtap-runtime + - To do so, run yum install systemtap systemtap-runtime; this will work if your yum repository is configured accordingly. To configure yum, simply add the following file to /etc/yum.repos.d: + Assuming that the computer system has been configured to use Red Hat + Network (RHN), the two rpms can be installed with yum install + systemtap systemtap-runtime. Before you use SystemTap the + additional kernel information will need to be installed as described in + the following section. + + +
+ +
+ Installing Needed Kernel Information + + SystemTap makes use of the information in additional kernel RPMs to + determine where to place instrumentation in the kernel and how to generate + code for the instrumentation. You will need to download and install the + necessary -devel and -debuginfo + packages for your kernel. The necessary -devel and + -debuginfo packages for the ordinary "vanilla" kernel + are as follows: + + + + kernel-debuginfo + kernel-debuginfo-common + kernel-devel + + + To determine what kernel your system is currently using, use: + + + uname -r + + + For example, if you wish to use SystemTap on kernel version + 2.6.18-53.el5, then you would need to download and + install the following RPMs: + + + + kernel-debuginfo-2.6.18-53.1.13.el5.i686.rpm + kernel-debuginfo-common-2.6.18-53.1.13.el5.i686.rpm + kernel-devel-2.6.18-53.1.13.el5.i686.rpm + + + The script can be used by normal users to + determine what supporting kernel RPMs need to be installed on the + machine to use SystemTap with a particular kernel. The script run + without any arguments detemines the RPMs needed for the currently + running kernel. The script can also accept one argument, the output + uname -r, to determine the related RPMs required + for a kernel that may not be currently running on the machine. + + + + stapprep.sh + + + + + + + + + If the computer has access to Red Hat Network (RHN) and the yum-utils + package is installed, the stapprep.sh script can be run + by root to download and install the needed kernel packages via + yum and rpm commands. Thus, the + system administrator should be able to install the needed RPMs with the + script on the machine: + + + + ./stapprep.sh + + + + + Important - - packages.repo - + + The version and architecture of the -devel, + -debuginfo and + -debuginfo-common packages must match the kernel + you wish to probe with SystemTap exactly. + + + + + If the yum repsitories are not accessible from the + machine, the following lines of bash script will generate the URL for + the Red Hat Enterprise Linux 5 debuginfo RPM directory: + + -[packages] -name=Packages for OS -baseurl=repository -enabled=1 -gpgcheck=0 +pkg=`grep distroverpkg /etc/yum.conf |awk -F= '{print $2}'` +releasever=`rpm -q --qf "%{version}" $pkg` +base=`uname -m` +echo "ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$base" - - - - - In , repository is the full URL of the repository containing the packages you wish to install. The name= parameter, along with the title ([packages]) and filename, can be set arbitrarily. Remember to always use the .repo filename extension. - - - - - Next, you'll need to download and install the necessary -devel and -debuginfo packages for your kernel. The necessary -devel and -debuginfo packages for the ordinary "vanilla" kernel are as follows: - - - kernel-debuginfo - kernel-debuginfo-common - kernel-devel - - -For example, if you wish to use SystemTap on kernel version 2.6.18-53.el5, then you need to download and install the following RPMs: - - - Sample List of Debugging RPMs - - kernel-debuginfo-2.6.18-53.1.13.el5.i686.rpm - kernel-debuginfo-common-2.6.18-53.1.13.el5.i686.rpm - kernel-devel-2.6.18-53.1.13.el5.i686.rpm - - - -As mentioned earlier in , kernel-debuginfo should not be confused with kernel-debug. Thus, in this example, you do not need to install the kernel-debug-2.6.18-53.1.13.el5.i686.rpm package. - - - - - Important - - The version and architecture of the -devel, -debuginfo and -debuginfo-common packages must match the kernel you wish to probe with SystemTap exactly. - - - You can download the necessary packages via your web browser. Once you have downloaded the packages, install them by running rpm -ivh package names. - - - - - Alternatively, if the packages are in a yum repository, you can configure yum again to download and install directly from that repository. Once you've configured yum correctly, run yum install full package names (as root). - + + + The package RPMs can be downloaded on another machine then copied to the + machine. Once you have downloaded the packages and copied them to the + machine, install the RPMs by running rpm -ivh + package names. + +
- - Initial Testing +
+ Initial Testing -If you are currently using the kernel you wish to probe with SystemTap, you can immediately test whether the deployment was successful. If not, you will need to reboot and load the appropriate kernel. - + If you are currently using the kernel you wish to probe with + SystemTap, you can immediately test whether the deployment was + successful. If not, you will need to reboot and load the appropriate + kernel. + -To start the test, run the command stap -v -e 'probe vfs.read {exit()}. This command simply instructs SystemTap to exit properly once a virtual file system read is detected. If the SystemTap deployment was successful, you should get the following verbose output: + To start the test, run the command stap -v -e 'probe vfs.read + {exit()}'. This command simply instructs SystemTap to exit + properly once a virtual file system read is detected. If the SystemTap + deployment was successful, you should get output very similar to the + following: + -Pass 1: parsed user script and 55 library script(s) in 340usr/10sys/380real ms. -Pass 2: analyzed script: 1 probe(s), 1 function(s), 0 embed(s), 0 global(s) in 280usr/290sys/745real ms. -Pass 3: translated to C into "/tmp/stapS1CuuS/stap_dd516743892b10a24cd36ef327265169_323.c" in 0usr/0sys/0real ms. -Pass 4: compiled C into "stap_dd516743892b10a24cd36ef327265169_323.ko" in 2050usr/220sys/2541real ms. -Pass 5: starting run. -Pass 5: run completed in 40usr/210sys/260real ms. +Pass 1: parsed user script and 55 library script(s) in 340usr/10sys/380real ms. +Pass 2: analyzed script: 1 probe(s), 1 function(s), 0 embed(s), 0 global(s) in 280usr/290sys/745real ms. +Pass 3: translated to C into "/tmp/stapS1CuuS/stap_dd516743892b10a24cd36ef327265169_323.c" in 0usr/0sys/0real ms. +Pass 4: compiled C into "stap_dd516743892b10a24cd36ef327265169_323.ko" in 2050usr/220sys/2541real ms. +Pass 5: starting run. +Pass 5: run completed in 40usr/210sys/260real ms. - - The last two lines of the output (i.e. beginning with Pass 5 indicate that SystemTap was able to successfully create the instrumentation to probe the kernel, run the instrumentation, detect the event being probed (in this case, a virtual file system read), and close it with no errors. - - - +
- \ No newline at end of file diff --git a/doc/SystemTap_Beginners_Guide/en-US/extras/stapprep.sh b/doc/SystemTap_Beginners_Guide/en-US/extras/stapprep.sh new file mode 100644 index 00000000..ba909994 --- /dev/null +++ b/doc/SystemTap_Beginners_Guide/en-US/extras/stapprep.sh @@ -0,0 +1,35 @@ +#! /bin/bash +check_error() { if test $1 != 0; then echo $2; exit $1; fi } +DEBUGINFOREPO="rhel-debuginfo" + +if [ "$#" -lt 1 ]; then + UNAME=`uname -r` # determine the kernel running on the machine +else + UNAME=$1 #user passed in uname value +fi +UNAME=`echo $UNAME | sed "s/ //"` #strip out any whitespace +KERNEL="kernel" +for VARIANT in debug kdump PAE xen; do + TMP=`echo $UNAME | sed s/$VARIANT//` + if [ "$TMP" != "$UNAME" ]; then + UNAME=$TMP; KERNEL="kernel-$VARIANT" + fi +done +KERN_ARCH=`uname -m` +KERN_REV=`echo $UNAME | sed s/.$KERN_ARCH//` # strip arch from uname +CANDIDATES="$KERNEL-$KERN_REV.$KERN_ARCH $KERNEL-devel-$KERN_REV.$KERN_ARCH \ +$KERNEL-debuginfo-$KERN_REV.$KERN_ARCH \ +kernel-debuginfo-common-$KERN_REV.$KERN_ARCH" +NEEDED=`rpm --qf "%{name}-%{version}-%{release}.%{arch}\n" -q $CANDIDATES | \ + grep "is not installed" | awk '{print $2}'` +if [ "$NEEDED" != "" ]; then + echo -e "Need to install the following packages:\n$NEEDED" + if [ `id -u` = "0" ]; then #attempt download and install + DIR=`mktemp -d` || exit 1 + yumdownloader --enablerepo=$DEBUGINFOREPO $NEEDED --destdir=$DIR + check_error $? "problem downloading rpm(s) $NEEDED" + rpm --force -ivh $DIR/*.rpm + check_error $? "problem installing rpm(s) $NEEDED" + rm -r $DIR #cleanup + fi +fi -- cgit