[Systemtap] install systemtap in cent OS 5.4 final

Source: Internet
Author: User
Tags ftp site systemtap

Installing systemtap in cent OS 5.4 final

For the latest installation steps, see

Http://blog.csdn.net/zklth/article/details/7281958

I. systemtap runtime environment requirements
(1) Linux kernel with kprobes (Mainline 2.6.11 + or backport );
(2) kernel module Build Environment (kernel-devel or kernel-smp-devel rpm );
(3) kernel debugging information (kernel-debuginfo rpm );
(4) C compiler (same as what kernel was compiled );
(5) elfutils with libdwfl for debugging informatin parsing;
(6) root privileges;
That is:
(1) The kernel supports and configures kprobe (kernel 2.6.11 and later)
(2) kernel module compiling environment (that is, the kernel header file and module configuration information required for compiling the kernel module. For Fedora Core or RedHat, it refers to the kernel-devel or kernel-smp-devel RPM package)
(3) kernel debugging information (for Fedora Core or RedHat, it refers to the kernel-debuginfo RPM package)
(4) C compiling environment
(5) elfutils that support libdwfl (only elfutils that support libwdfl can work normally. If your system's elfutils is older, you must download the elfutils source package to compile it, systemtap can be compiled with elfutils)
(6) Root permission (to run systemtap, you must have root permission)

 

Ii. Installation Steps under centos 5.4 final
Kernel version
[Root @ localhost opt] # uname-R
2.6.18-164. EL5 <if 2.6.18-164. el5xen indicates Kernel support for virtualization>
Operating system version
[Root @ localhost opt] # Cat/etc/issue
Centos release 5.4 (final) kernel/r on an/m

The cent OS 5.4 release contains most of the packages listed below,
You can run the rpm-Q command to view the details,
Or
In the graphic interface, choose "application"> "Add/delete software"> "Search"> enter a software package name to query information about the software package.
Note: The following three packages, kernel-debuginfo-common, kernel-debuginfo, and kernel-xen-debuginfo, are not included in the CD,
You need to download the package from the Internet. The following are some of the following:

(I) http://debuginfo.centos.org/5/i386/ here you can download the RPM package for cent OS 5 kernrl-debuginfo. (My machine is i386)

(Ii) http://rpm.pbone.net/select the system version number to download to the appropriate RPM installation package.

(Note)If the xen kernel is used, download the kernel-xen-debuginfo package;

In addition, the kernel-debuginfo-common and kernel-debuginfo versions must be the same, and the latter depends on the former;

I didn't install these two packages when I used systemtap in cent OS 5.4 final. systemtap still works normally and the monitoring system calls. Somehow, it is recommended to install it, finally I downloaded the installed kernel-debuginfo-2.6.18-194.11.4.el5.i686.rpm and kernel-debuginfo-common-2.6.18-194.11.4.el5.i686;

 (1) install GCC and libcap-devel
GCC is the compiler (C, C ++), and libcap-devel is the development file of libcap;
Check whether the corresponding packages are installed in the system. These packages can be found on the cent OS 5.4 final release disc;
[Root @ localhost opt] # rpm-Q gcc
Gcc-4.1.2-46.el5
[Root @ localhost opt] # rpm-Q libcap
Libcap-1.10-26

(2) install kernel-headers
Kernel-headers is the header file of the Linux Kernel used by glibc;
Check whether the corresponding package is installed in the system. This package can be found on the cent OS 5.4 final release disc;
[Root @ localhost opt] # rpm-Q kernel-headers
Kernel-headers-2.6.18-164.el5

(3) install kernel-devel
Kernel-devel is a development package used to build kernel modules that match the kernel;
For the xen kernel, you need to install the kernel-xen-devel package. If the kernel version is SMP, you need to install the kernel-[smp-] devel package;
This package can be found on the cent OS 5.4 final CD;
[Root @ localhost opt] # rpm-Q kernel-devel
Kernel-devel-2.6.18-164.el5

When the kernel-devel package is installedAdd content under the/usr/src/kernels/'uname-R' directory,This is the kernel directory. During execution, systemtap will call the corresponding modules in the kernel source code directory. If this package is not installed
"Missing x86_64 kernel/module debuginfo under '/lib/modules/'uname-R'/build'" "error, '/lib/modules/'uname-R'/build' is a link pointing to the kernel source code directory./Usr/src/kernels/'uname-R'. Note: The kernel and Kerner-devel versions must be consistent.

 

(4) install kernel-debuginfo-common
This package is not available on the cent OS 5.4 final release CD. You need to download and install the package by yourself. It is provided earlier.

[Root @ localhost opt] # rpm-Q kernel-debuginfo-common
Package kernel-deguginfo-common Is Not Installed

(5) install kernel-debuginfo
For the xen kernel, You need to download and install kernel-xen-debuginfo;
Systemtap uses kernel debugging information to locate kernel functions and variables.
This package is not available on the cent OS 5.4 final release CD. You need to download and install the package by yourself. It is provided earlier.
[Root @ localhost opt] # rpm-Q kernel-xen-debuginfo
Package kernel-xen-deguginfo Is Not Installed

 

--------------------------------------------------------------------

To install kernel-debuginfo, follow these steps:

When installing kernel-debuginfo (the xen kernel is kernel-xen-debuginfo), you must first install kernel-debuginfo-common. Otherwise, a dependency error is prompted, because kernel-debuginfo depends on Kernel-debuginfo-common, in addition, the two versions should be consistent. What I download and install is:

Kernel-debuginfo-2.6.18-194.11.4.el5.i686.rpm (kernel is xen, then kernel-xen-debuginfo-2.6.18-194.11.4.el5.i686.rpm)

Kernel-debuginfo-common-2.6.18-194.11.4.el5.i686

: Http://debuginfo.centos.org/5/i386/

Installation: rpm-IVH *. rpm
Query: rpm-Q kernel-debuginfo
Uninstall: rpm-e kernel-debuginfo

 

Installation steps:

 

[Root @ localhost kernel-debuginfo] # ls
Kernel-debuginfo-2.6.18-194.11.4.el5.i686.rpm
Kernel-debuginfo-common-2.6.18-194.11.4.el5.i686.rpm
[Root @ localhost kernel-debuginfo] # rpm-IVH kernel-debuginfo-2.6.18-194.11.4.el5.i686.rpm
Error: Failed dependencies:
Kernel-debuginfo-common-i686 = 2.6.18-194.11.4.el5 is needed by kernel-debuginfo-2.6.18-194.11.4.el5.i686
[Root @ localhost kernel-debuginfo] # rpm-IVH kernel-debuginfo-common-2.6.18-194.11.4.el5.i686.rpm
Preparing... ######################################## ### [100%]
1: kernel-debuginfo-common ################################### ####### [1, 100%]
[Root @ localhost kernel-debuginfo] # rpm-Q kernel-debuginfo-common
Kernel-debuginfo-common-2.6.18-194.11.4.el5
[Root @ localhost kernel-debuginfo] # rpm-IVH kernel-debuginfo-2.6.18-194.11.4.el5.i686.rpm
Preparing... ######################################## ### [100%]
1: kernel-debuginfo ##################################### ###### [100%]
[Root @ localhost kernel-debuginfo] # rpm-Q kernel-debuginfo
Kernel-debuginfo-2.6.18-194.11.4.el5

 

----------------------------------------------------------------------------

 

(6) install elfutils
(I) The elfutils-0.137 is installed by default in centos5.4 final
# Rpm-Q elfutils
Elfutils-0.137-3.e15
It is best to install all the elfutils * RPM packages on the centos5.4 CD;
The software package is available in centos5.4, which consists of the following seven:


By default, the following five RPM packages are installed:
Elfutils-0.137-3.el5.i386.rpm
A set of tools used to process compiled objects
Elfutils-libelf-0.137-3.el5.i386.rpm
Library for reading and writing elf files (executable and linking format. The intended format is executable and associated file formats)
Elfutils-libelf-devel-0.137-3.el5.i386.rpm
Libelf development support
Elfutils-libelf-devel-static-0.137-3.el5.i386.rpm
Static archive of libelf
Elfutils-libs-0.137-3.el5.i386.rpm
Library used to process compiled objects
The following are not installed:
Elfutils-devel-0.137-3.el5.i386.rpm
Development Library for processing compiled objects
Elfutils-devel-static-0.137-3.el5.i386.rpm
Process static archive of the compiled object

(Ii) download the elfutils source code package for Installation
Systemtap needs the library functions provided by the elfutils package to analyze debugging information.
Current systemtap requires installation of elfutils-0.123 or later versions.
We can download the RPM or source code from the systemtap site to upgrade.
Earlier elfutils versions are:
Ftp://sources.redhat.com/pub/systemtap/elfutils.old/
Other versions can also be downloaded in the https://fedorahosted.org/releases/e/l/elfutils/
Or http://kojipkgs.fedoraproject.org/packages/elfutils/
Elfutils website in https://fedorahosted.org/elfutils/

(7) install systemtap
(I) centos5.4 systemtap-0.9.7-5.e15 installed by default
# Rpm-Q systemtap
Systemtap-0.9.7-5.e15
It is best to install all the systemtap * packages on the centos5.4 CD;
Centos5.4 is installed by default with the following two:


Systemtap-0.9.7-5.e15.i386
Test System
Systemtap-runtime-0.9.7-5.e15.i386
Device testing during system operation
Uninstalled:
In the graphic interface, choose "application"> "Add/delete software"> "Search"> enter the software package name systemtap to query information about the software package.



(Ii) download the systemtap source code for Installation
Download the latest source code from the FTP site of systemtap

Ftp://sources.redhat.com/pub/SystemTap/snapshots/SystemTap-20100925.tar.bz2
Or
Ftp://sources.redhat.com/pub/systemtap/releases/

You can also download the RPM package of systemtap for installation: Search for systemtap on the http://rpm.pbone.net.

Official systemtap website

Http://sourceware.org/systemtap/documentation.html

For installation instructions, see

Install systemtap in Linux

 

I have not installed kernel-debuginfo and kernel-debuginfo-common in cent OS 5.4. The system installed systemtap works normally, but we recommend that you install the debuginfo package.
(8) run a simple systemtap test program;
 

Test script systemtap. STP:

 

--------------------------------------------------------------------

 

Global syscalllist

Global mpname = "Java"/* Attention: Java Process 'name is lower-case "Java "*/

Global DEBUG = 0/* print middle info */

Global all = 0

Probe begin {
Printf ("% s process monitoring started.../N", mpname)
}

Probe syscall. Read
{
If (all) printf ("current process: % s/n", execname ());
/* Execname () can get the current process's name */
If (execname () = mpname ){
/* Variable name is syscall's name, it is defined in kernel function */
Namex = Name
If (Debug) printf ("% s/n", namex)
/* PID () can get the current process's PID */
Pidx = PID ()
If (Debug) printf ("% d/N", pidx)

Syscalllist [pidx, namex] ++
}
}

Probe syscall. Write
{
Pname = execname ()
Syscallname = Name
Count (pname, syscallname)
}

Probe kernel. function ("sys_read "){
Pname = execname ()
Objname = "kf_sys_read"
Count (pname, objname)
}

Probe kernel. function ("sys_write "){
Pname = execname ()
Objname = "kf_sys_write"
Count (pname, objname)
}

//
// Remarks: Count process's some OBJ, such syscall, kernel. Function
//
// Parameters:
/// Pname: process' name
/// Objname: syscall name
//
// Return values:
/// Null
//
Function count (pname, objname ){
If (pname = mpname ){
If (Debug) printf ("% s", objname)
/* Current process 'id */
Pidx = PID ()
If (Debug) printf ("% d/N", pidx)
Syscalllist [pidx, objname] ++
}
}

/*
Probe timer. MS (5000 ){

}
*/

Function print_info (){
Foreach ([pidx, namex] In syscalllist ){
Printf ("% d % s = % d/N", pidx, namex, syscalllist [pidx, namex])
}
}

Probe end {
Print_info ()
Printf ("Java Process Monitoring finished/N ")
}

 

---------------------------------------------------------------------

Run the STAP-V systemtap. STP command. If the command runs normally, systemtap is successfully installed.

 

[Root @ localhost systemtap_study] # STAP-V monitorjava. STAP
Pass 1: parsed user script and 52 library script (s) in 280usr/0sys/293 real Ms.
Pass 2: analyzed Script: 6 probe (s), 4 function (s), 1 embed (s), 4 Global (s) in 310usr/350sys/654 real Ms.
Pass 3: using cached/root/. systemtap/Cache/A3/stap_a3128d43c0908f80778e75f469858507_2665.c
Pass 4: using cached/root/. systemtap/Cache/A3/stap_a3128d43c0908f80778e75f469858507_2665.ko
Pass 5: Starting run.
Java Process Monitoring started...
4151 kf_sys_read = 14
4151 READ = 14
4151 kf_sys_write = 5
4151 write = 5
4049 kf_sys_read = 43
4049 READ = 43
4049 kf_sys_write = 13
4049 write = 13
5873 kf_sys_read = 864
5873 READ = 864
5873 kf_sys_write = 2
5873 write = 2
5861 kf_sys_read = 2561
5861 READ = 2561
5861 kf_sys_write = 29
5861 write = 29
5921 kf_sys_read = 864
5921 READ = 864
5921 kf_sys_write = 2
5921 write = 2
5909 kf_sys_read = 2561
5909 READ = 2561
5909 kf_sys_write = 29
5909 write = 29
Java Process Monitoring finished
Pass 5: Run completed in 0usr/10sys/14408 real Ms.
[Root @ localhost systemtap_study] #

 

Iii. Special Features of cent OS 5.4 final and steps for installing systemtap in general Linux systems

When you select a software package to install cent OS 5.4 final, elfutils and systemtap are installed by default,
The kernel does not need to be re-compiled because it supports related options by default. These options are described below.

If the system does not install (1 )~ (5) Some RPM packages and elfutils and systemtap,
You need to download these RPM packages first (1 )~ (5) install elfutils and systemtap, re-compile the kernel, and start it with the new kernel.

During kernel compilation, you must ensure that the kernel supports the following options:
Make menuconfig; configure the kernel compilation options as follows:
General setup --->
[*] Kernel-> User Space Relay Support (formerly relayfs)
Kernel hacking --->
[*] Kernel debugging
[*] Compile the kernel with debug info
[*] Debug filesystem
Instrumentation support --->
[*] Kprobes (experimental)
Security Options --->
[*] Default Linux capabilities

When you exit, Vi. config will view the kernel compilation configuration file,
Make sure that the config_debug_info, config_kprobes, config_relay, and config_debug_fs items are selected. Run the following command:
[Root @ localhost linux-2.6.25] # grep config_debug_info. config
Config_debug_info = y
[Root @ localhost linux-2.6.25] # grep config_kprobes. config
Config_kprobes = y
[Root @ localhost linux-2.6.25] # grep config_relay. config
Config_relay = y
[Root @ localhost linux-2.6.25] # grep config_debug_fs. config
Config_debug_fs = y

Compile the kernel
Make clean
Make vmlinux modules
Make modules_install
Make bzimage
Make install

After you restart the system with the new kernel, install the elfutils * And systemtap * packages.

 

Iv. References

Linux self-check and systemtap
Http://www.ibm.com/developerworks/cn/linux/l-systemtap/index.html

A new performance measurement and tuning diagnostic tool systemtap in Linux
Http://www.ibm.com/developerworks/cn/linux/l-cn-systemtap3/#N1005B

Official systemtap website
Http://sourceware.org/systemtap/documentation.html

Elfutils Official Website
Https://fedorahosted.org/elfutils/

Use systemtap to debug the kernel
Http://linux.chinaunix.net/docs/2006-12-15/3479.shtml

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.