systemtap打点方法
CentOS/RedHat发行版
使用yum安装下列rpm包即可:
systemtap:SystemTap包
gcc:c语言编译器
elfutils:提供库函数来分析调试信息
kernel-devel:编译内核模块所需的内核头文件及模块配置信息
kernel-debuginfo:提供所需的内核调试信息来定位内核函数和变量的位置
使用
一些例子SystemTap的简单例子。
(1) stap
通常直接使用stap执行用SystemTap语法编写的脚本即可。
stap - systemtap script translator/driver
stap test.stp // .stp后缀的文件是用SystemTap语法编写的脚本
脚本主要元素:probe point + probe handler
stap [options] FILE // Run script in file
stap [options] -e SCRIPT // Run given script.
stap [options] -l PROBE // List matching probes.
stap [options] -L PROBE // List matching probes and local variables.
常用选项
-h:帮助
-g:guru模式,嵌入式C代码需要
-m:指定编译成的模块名称
-v:add verbosity to all passes
-k:不删除临时目录
-p NUM:stop after pass NUM 1-5, instead of 5 (parse, elaborate, translate, compile, run)
-b:bulk (percpu file) mode, 使用RelayFS将数据从内核空间传输到用户空间
-o FILE:输出到指定文件,而不是stdout
-c CMD:start the probes, run CMD, and exit when it finishes
stap是SystemTap的前端,当出现以下情况时退出:
1. The user interrupts the script with a CTRL-C.
2. The script executes the exit() function.
3. The script encounters a sufficient number of soft errors.
4. The monitored command started with the stap program's -c option exits.
(2) staprun
如果我们的输入不是.stp脚本,而是一个用stap生成的模块,那么就用staprun来执行。
staprun - systemtap runtime
staprun [OPTIONS] MODULE [MODULE-OPTIONS]
staprun的作用:
The staprun program is the back-end of the Systemtap tool. It expects a kernel module produced by
the front-end stap tool.
Splitting the systemtap tool into a front-end and a back-end allows a user to compile a systemtap script
on a development machine that has the kernel debugging information (need to compile the script) and
then transfer the resulting kernel module to a production machine that doesn't have any development
tools or kernel debugging information installed.
staprun is a part of the SystemTap package, dedicated to module loading and unloading and kernel-to-user
data transfer.
常用选项
-o FILE:Send output to FILE.
-D:Run in background. This requires '-o' option.
(3) 监测内核函数
一个简单脚本,每当内核函数do_fork()被调用时,显示调用它的进程名、进程ID、函数参数。
global proc_counter
probe begin {
print("Started monitoring creation of new processes...Press ^C to terminate\n")
printf("%-25s %-10s %-s\n", "Process Name", "Process ID", "Clone Flags")
}
probe kernel.function("do_fork") {
proc_counter++
printf("%-25s %-10d 0x%-x\n", execname(), pid(), $clone_flags)
}
probe end {
printf("\n%d processes forked during the observed period\n", proc_counter)
}
(4) 监测系统调用
一个简单脚本,显示4秒内open系统调用的信息:调用进程名、进程ID、函数参数。
[java] view plain copy
probe syscall.open
{
printf("%s(%d) open(%s)\n", execname(), pid(), argstr)
}
probe timer.ms(4000) # after 4 seconds
{
exit()
}
(5) 监测源文件中所有函数入口和出口
括号内的探测点描述包含三个部分:
function name part:函数名
@file name part:文件名
function line part:所在行号
例如:
probe kernel.function("*@net/socket.c") {}
probe kernel.function("*@net/socket.c").return {}
这里指定函数名为任意(用*表示),指定文件名为net/socket.c,探测函数的入口和返回。
还可以用“:行号”来指定行号。
(6) 查找匹配的内核函数和变量
查找名字中包含nit的内核函数:
stap -l 'kernel.function("*nit*")'
查找名字中包含nit的内核函数和变量:
stap -L 'kernel.function("*nit*")'
(7) 自带的用例集
/usr/share/systemtap/tapset/ /usr/share/systemtap/example/s包含了许多用例脚本。
主要有几个方面:
network、io、interrupt、locks、memory、process、virtualization等
systemtap打点方法相关推荐
- 内核探测工具systemtap简介
systemtap是内核开发者必须要掌握的一个工具,本文我将简单介绍一下此工具,后续将会有系列文章介绍systemtap的用法. 什么是systemtap 假如现在有这么一个需求:需要获取正在运行的L ...
- 三层内网 外网打点到内网域 sec123 复现
文章目录 三层内网 外网打点到内网域 sec123 复现 项目介绍 网络配置图 环境搭建 账号和密码 外网打点 端口扫描 网上银行系统漏洞 网上银行系统Hsql注入漏洞 tomexam SQL注入漏洞 ...
- 论坛论坛发帖html功能,论坛发帖报错解决方法
报错模式: PHP Warning: Illegal string offset 'special' in E:\xxx...\wwwroot\论坛\forumdata\templates\1_pos ...
- vue中使用mapboxgl 加载天地图初始化并打点marker以及逆地理编码
1.首先这个是中文文档地址开发文档 | Mapbox 2.先注册一个token 具体文档流程,这边不过多介绍 3.下载npm install mapbox-gl --save 4.不多说 直接上代码 ...
- Android逆向之路---Faceu的登录功能真的只提交了用户名和密码吗
问题 几乎99%的软件都有登录功能,而登录这一个动作真的将我们的用户名和密码上传到了服务器吗,会不会有个人隐私呢.根据我们这个问题,我们用FaceU这个软件,逆向来看看他的登录功能到底都传了什么数据. ...
- 微信小程序开发优秀教程及文章合集第一期
2019独角兽企业重金招聘Python工程师标准>>> 我会不定期的选取一些优质教程,整理成辑,以便大家集中阅读: 新手向!微信小程序开发手记系列: 微信小程序开发手记<一&g ...
- 小程序异常监控及错误处理
小程序异常监控收集 web端与小程序错误监控差异 在 Web 端监测的是页面完整的 url,而小程序端监测的是路由地址: 小程序页面属于app内部的页面,使用时已全部加载完毕,因此监控页面性能时不统计 ...
- Openlayers中使用Overlay实现点击要素显示html内容弹窗并且动态更改弹窗内容
场景 Openlayers中使用Overlay实现点击要素弹窗并且弹窗随之移动: Openlayers中使用Overlay实现点击要素弹窗并且弹窗随之移动_BADAO_LIUMANG_QIZHI的博客 ...
- Openlayers中使用Overlay实现点击要素弹窗并且弹窗随之移动
场景 Vue+Openlayer使用overlay实现弹窗弹出显示与关闭: Vue+Openlayer使用overlay实现弹窗弹出显示与关闭_BADAO_LIUMANG_QIZHI的博客-CSDN博 ...
- android应用APP中的页面响应时间测试
说明:这里只介绍基本测试逻辑 整理出 整个APP需要关注的一级页面列表 基本工具:ut(内部工具,不便透露细节) 在开发代码中引入TimeProfile类:这个类是ut的最上层,暴露出一些简单的时间打 ...
最新文章
- 解决“SSL handshake failed“问题
- iBatis.Net(C#)数据库查询
- 利用docker中的nginx镜像部署angular项目
- celery4不支持djcelery
- 岁月划过生命线(从0到阿里)
- 中国人民大学金琴老师组,AI·M^3实验室招募视觉与语言方向硕博
- linux18.04忘记账号密码,Ubuntu18.04忘记超级用户root密码,重新设置密码
- 一块神奇的树莓派电子板竟让我学会了Linux系统
- 基于Java实现宠物领养救助交流平台设计和实现
- somachine3.1 注册
- 半连续性:上半连续与下半连续
- 关于含税单价和不含税单价的关系记录
- 序列的算法(一·a)马尔可夫模型
- 红黑树删除操作的各种情况分析
- 魔兽美服服务器维护,魔兽《军团再临》美服开启 服务器不卡如丝般顺滑
- 天津理工大学《操作系统》实验二,存储器的分配与回收算法实现,代码详解,保姆式注释讲解
- Redis Sentinel主从复制自动切换方案
- 打字会覆盖后面原有的字解决方案
- python中res代表什么_Python数据类型的用法
- Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn分别代表什么意思
热门文章
- jquery.blockUI.2.31.js 弹出层项目介绍
- golang调用c++的dll库文件
- Boost-IO学习 异步数据处理Simple(转)
- excel甘特图模板_不做规范!收数就是个灾难!Excel收集数据套路了解一下
- kafka 0.8.2版本配置选项翻译
- 你不主动去要世界也不会给你 漫话开源项目的可持续发展之路
- makefile中的wildcard和notdir和patsubst
- 代理设计模式 实现 Retrofit 的 create
- 文件和目录属性ls which alias
- 个人信息保护须形成更大合力