什么是SystemTap以及如何使用它?
环境
问题
决议SystemTap is an innovative tool which allows for simplified information gathering on the running Linux kernel. The purpose of using SystemTap is to obtain information on either performance issues or functional problems (bugs). By using SystemTap,developers and system administrators can debug problems and gather profiling and performance data without having to create and install instrumented kernels or other packages. In essence,SystemTap provides the infrastructure (a command line interface and scripting language) needed to gather information. The actual job that SystemTap performs relies on user-developed scripts tailored to a specific purpose. Currently,there are a number of example SystemTap scripts pre-made for general use. The operation of SystemTap is quite simple. The? RequirementsBecause SystemTap compiles scripts from C code and launches probes for kernel instrumentation,it requires several packages in order to function. See the?Installing SystemTap?chapter of the?SystemTap Beginners Guide?for detailed installation instructions. The easiest way to satisfy the requirements is to simply?subscribe the system to the relevant debuginfo channels?in RHN,then run the following commands which should set up the environment for SystemTap: yum install systemtap stap-prep To set the environment up manually,in addition to the?
For example,for a? kernel-debuginfo-2.6.32-71.18.2.el6.x86_64 kernel-debuginfo-common-x86_64-2.6.32-71.18.2.el6.x86_64 kernel-devel-2.6.32-71.18.2.el6.x86_64 As well as the? The? LegacyOn RHEL 4,use? For RHEL 5,you can download the? Using SystemtapYou can verify the SystemTap environment with the? An example script is shown below: #! /usr/bin/env stap # Using statistics and maps to examine kernel memory allocations global kmalloc probe kernel.function("__kmalloc") { kmalloc[execname()] <<< $size } # Exit after 10 seconds probe timer.ms(10000) { exit () } probe end { foreach ([name] in kmalloc) { printf("Allocations for %sn",name) printf("Count: %d allocationsn",@count(kmalloc[name])) printf("Sum: %d Kbytesn",@sum(kmalloc[name])/1000) printf("Average: %d bytesn",@avg(kmalloc[name])) printf("Min: %d bytesn",@min(kmalloc[name])) printf("Max: %d bytesn",@max(kmalloc[name])) print("nAllocations by size in bytesn") print(@hist_log(kmalloc[name])) printf("-------------------------------------------------------nn"); } } This script,drawn from the SystemTap project wiki,can be used to print information kernel memory allocations of the system. The script can be invoked as follows: stap kmalloc2.stp For issues during the compile or loading of the module within the? SystemTap will then translate the probe into C,compile the C program,and insert the probe into the running kernel. Truncated output is below: ------------------------------------------------------- Allocations for httpd Count: 10 allocations Sum: 0 Kbytes Average: 0 bytes Min: 0 bytes Max: 0 bytes Allocations by size in bytes value |-------------------------------------------------- count 0 |@@@@@@@@@@ 10 1 | 0 2 | 0 ------------------------------------------------------- Allocations for sendmail Count: 2 allocations Sum: 0 Kbytes Average: 24 bytes Min: 24 bytes Max: 24 bytes Allocations by size in bytes value |-------------------------------------------------- count 4 | 0 8 | 0 16 |@@ 2 32 | 0 64 | 0 ------------------------------------------------------- This is a simple example that just touches the surface of the capabilities offered by SystemTap. System Administrators could use this information to better understand kernel memory allocation on the running system and adjust kernel tuning parameters accordingly. Application developers can use this information as an overview of which applications are receiving more kernel memory allocations,which can be used as a starting point for deeper application profiling. Additional Information about SystemTap
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |