systemtap 安装试用

1. 安装
yum install -y systemtap systemtap-runtime
2. 环境准备
 
 a. 自动安装依赖
stap-prep
b. 手动安装依赖
kernel-debuginfo
kernel-debuginfo-common
kernel-devel

简单的方式使用yum install 或者 debuginfo-install 
实在不行可以下载rpm手工安装,地址:
http://debuginfo.centos.org/7/x86_64/

注意:需要选择对应操作系统kernel 版本
3. 简单测试使用
stap -ve 'probe vfs.read {printf("read test"); exit()}'
4. 测试结果
stap -ve 'probe vfs.read {printf("read test"); exit()}'
Pass 1: parsed user script and 466 library scripts using 226620virt/39692res/3312shr/36508data kb, in 310usr/10sys/329real ms.
Pass 2: analyzed script: 1 probe, 1 function, 7 embeds, 0 globals using 370760virt/179584res/4632shr/180648data kb, in 1700usr/220sys/1922real ms.
Pass 3: translated to C into "/tmp/stapgCuafC/stap_ce7abe45c93b347a24b025ea2830bd0d_2681_src.c" using 370760virt/179856res/4904shr/180648data kb, in 0usr/0sys/9real ms.
Pass 4: compiled C into "stap_ce7abe45c93b347a24b025ea2830bd0d_2681.ko" in 1700usr/550sys/3127real ms.
Pass 5: starting run.
read testPass 5: run completed in 10usr/20sys/335real ms.
5. 生成机器对应的内核模块
stap -r kernel-version  script -m module_name
参考:
 stap    -ve 'probe vfs.read {printf("read test"); exit()}' -m dalongdemo
 会生成 dalongdmeo.ko
 运行: staprun dalongdemo.ko
6. stap 运行命令参考
 
-v  可以重复多次,次数越多,显示的信息月详细
-o  将信息输出到文件
-S  指定输出文件的大小
-e  包含的script 
-F  进行记录录制
-m  指定生成的内核模块的名称
7. 参考资料
http://debuginfo.centos.org/7/x86_64/
https://sourceware.org/systemtap/

posted on 2017-11-23 17:34  荣锋亮  阅读(252)  评论(0编辑  收藏  举报

导航