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   荣锋亮  阅读(263)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示