Red Hat Enterprise Linux 7 SystemTap Beginners Guide Introduction to SystemTap Last Updated: 2020-09-29 Red Hat Enterprise Linux 7 SystemTap Beginners Guide Introduction to SystemTap William Cohen Red Hat Software Engineering [email protected] Don Domingo Red Hat Customer Content Services Vladimír Slávik Red Hat Customer Content Services [email protected] Robert Kratky Red Hat Customer Content Services Jacquelynn East Red Hat Customer Content Services Legal Notice Copyright © 2019 Red Hat, Inc. This document is licensed by Red Hat under the Creative Commons Attribution-ShareAlike 3.0 Unported License. If you distribute this document, or a modified version of it, you must provide attribution to Red Hat, Inc. and provide a link to the original. If the document is modified, all Red Hat trademarks must be removed. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries. Linux ® is the registered trademark of Linus Torvalds in the United States and other countries. Java ® is a registered trademark of Oracle and/or its affiliates. XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries. MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and other countries. Node.js ® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project. The OpenStack ® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community. All other trademarks are the property of their respective owners. Abstract This guide provides basic instructions on how to use SystemTap to monitor different subsystems of Red Hat Enterprise Linux 7 in detail. The SystemTap Beginners Guide is recommended for users who have taken the RHCSA exam or have a similar level of expertise in Red Hat Enterprise Linux 7. Table of Contents Table of Contents .C . H. .A . P. .T .E . R. 1.. .I .N . T. .R .O . .D . U. .C . T. .I O. N. 3. 1.1. DOCUMENTATION GOALS 3 1.2. SYSTEMTAP CAPABILITIES 3 .C . H. .A . P. .T .E . R. 2. U. .S . I.N . .G . .S . Y. .S .T . E. .M . .T .A . P. 5. 2.1. INSTALLATION AND SETUP 5 2.2. GENERATING INSTRUMENTATION FOR OTHER COMPUTERS 6 2.3. RUNNING SYSTEMTAP SCRIPTS 8 .C . H. .A . P. .T .E . R. 3. U. N. .D . E. .R . S. T. .A . N. .D . I. N. .G . .H . O. W. .S .Y . S. .T . E. .M . T. .A . P. W. O. .R . K. .S . 1. 2. 3.1. ARCHITECTURE 12 3.2. SYSTEMTAP SCRIPTS 12 3.3. BASIC SYSTEMTAP HANDLER CONSTRUCTS 19 3.4. ASSOCIATIVE ARRAYS 22 3.5. ARRAY OPERATIONS IN SYSTEMTAP 23 3.6. TAPSETS 29 .C . H. .A . P. .T .E . R. 4. .U . S. .E .F . U. .L . .S .Y . S. .T . E. M. T. .A . P. S. .C . R. I. P. .T .S . .3 .0 . 4.1. NETWORK 30 4.2. DISK 35 4.3. PROFILING 44 4.4. IDENTIFYING CONTENDED USER-SPACE LOCKS 54 .C . H. .A . P. .T .E . R. 5. U. .N . .D . E. .R . S. T. .A . N. .D . I.N . .G . .S . Y. .S .T . E. .M . .T .A . P. E. .R . R. .O . R. .S . .5 . 7. 5.1. PARSE AND SEMANTIC ERRORS 57 5.2. RUN TIME ERRORS AND WARNINGS 59 .C . H. .A . P. .T .E . R. 6. .R .E . F. .E . R. .E .N . C. E. S. .6 .0 . .A .P . P. .E . N. .D . I. X. A . .R .E . V. .I S. .I O. N. H. .I S. .T . O. .R . Y. 6. .1 . .I N. .D . E. .X . .6 . 2. 1 SystemTap Beginners Guide 2 CHAPTER 1. INTRODUCTION CHAPTER 1. INTRODUCTION SystemTap is a tracing and probing tool that allows users to study and monitor the activities of the operating system (particularly, the kernel) in fine detail. It provides information similar to the output of tools like netstat, ps, top, and iostat; however, SystemTap is designed to provide more filtering and analysis options for collected information. SystemTap can be used by system administrators as a performance monitoring tool for Red Hat Enterprise Linux 5 or later. It is most useful when other similar tools cannot precisely pinpoint a bottleneck in the system, thus requiring a deep analysis of system activity. In the same manner, application developers can also use SystemTap to monitor, in fine detail, how their application behaves within the Linux system. 1.1. DOCUMENTATION GOALS SystemTap provides the infrastructure to monitor the running Linux system for detailed analysis. This can assist administrators and developers in identifying the underlying cause of a bug or performance 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 users to gather the same information by simply running user-written SystemTap scripts. However, SystemTap was initially designed for users with intermediate to advanced knowledge of the Linux kernel. This makes SystemTap less useful to administrators or developers with limited knowledge of and experience with the kernel. Moreover, much of the existing SystemTap documentation is similarly aimed at knowledgeable and experienced users. To lower these barriers the SystemTap Beginners Guide was written with the following goals: To introduce users to SystemTap, familiarize them with its architecture, and provide setup instructions for all kernel types. To provide pre-written SystemTap scripts for monitoring detailed activity in different components of the system, along with instructions on how to run them and analyze their output. 1.2. SYSTEMTAP CAPABILITIES SystemTap was originally developed to provide functionality for Red Hat Enterprise Linux similar to previous Linux probing tools such as dprobes and the Linux Trace Toolkit. SystemTap aims to supplement the existing suite of Linux monitoring tools by providing users with the infrastructure to track kernel activity. In addition, SystemTap combines this capability with two attributes: Flexibility: SystemTap's framework allows users to develop simple scripts for investigating and monitoring a wide variety of kernel functions, system calls, and other events that occur in kernel space. With this, SystemTap is not so much a tool as it is a system that allows you to develop your own kernel-specific forensic and monitoring tools. Ease-of-Use: as mentioned earlier, SystemTap allows users to probe kernel-space events without having to resort to the lengthy instrument, recompile, install, and reboot the kernel process. Most of the SystemTap scripts enumerated in Chapter 4, Useful SystemTap Scripts demonstrate system forensics and monitoring capabilities not natively available with other similar tools (such as top, OProfile, or ps). These scripts are provided to give readers extensive examples of the application of 3 SystemTap Beginners Guide SystemTap, which in turn will educate them further on the capabilities they can employ when writing their own SystemTap scripts. 4 CHAPTER 2. USING SYSTEMTAP CHAPTER 2. USING SYSTEMTAP This chapter instructs users how to install SystemTap, and provides an introduction on how to run SystemTap scripts. 2.1. INSTALLATION AND SETUP To deploy SystemTap, SystemTap packages along with the corresponding set of -devel, -debuginfo and -debuginfo-common-arch packages for the kernel need to be installed. To use SystemTap on more than one kernel where a system has multiple kernels installed, 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 packages. Remember that the deployment of SystemTap requires the installation of the -debuginfo package of the kernel, not the - debug version of the kernel. 2.1.1. Installing SystemTap To deploy SystemTap, install the systemtap and systemtap-runtime packages by running the following command as root: ~]# yum install -y systemtap systemtap-runtime 2.1.2. Installing Required Kernel Information Packages SystemTap needs information about the kernel in order to place instrumentation in it (probe it). This information, which allows SystemTap to generate the code for the instrumentation, is contained in the matching kernel-devel, kernel-debuginfo, and kernel-debuginfo-common-arch packages (where arch is the hardware platform of your system, which you can determine by running the uname -m command). While the kernel-devel package is available from the default Red Hat Enterprise Linux repository, the kernel-debuginfo and kernel-debuginfo-common-arch packages are available from the debug repository. To install the required packages, enable the debug repository for your system: ~]# subscription-manager repos --enable=rhel-7-variant-debug-rpms In the above command, replace variant with server, workstation, or client, depending on the variant of the Red Hat Enterprise Linux system you are using. To determine the variant, you can use the following command: ~]# cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.2 (Maipo) The version, variant, and architecture of the kernel-devel, kernel-debuginfo, and kernel-debuginfo- common-arch packages must exactly match the kernel to be probed with SystemTap. To determine what kernel your system is currently running, use: 5 SystemTap Beginners Guide uname -r 3.10.0-327.el7.x86_64 For example, if you wish to use SystemTap on kernel version 3.10.0-327.4.4.el7 on an AMD64 or Intel 64 machine, then you need to install the.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages94 Page
-
File Size-