systemtap-与 oracle 转
https://baoz.net/using-systemtap/
http://nanxiao.me/category/%E6%8A%80%E6%9C%AF/systemtap-%E7%AC%94%E8%AE%B0/
http://gmd20.blog.163.com/blog/static/168439232015475525227/
http://zhengheng.me/page/3/
http://www.golaravel.com/php/features.dtrace.systemtap.html
http://www.golaravel.com/php/features.dtrace.dtrace.html
http://www.golaravel.com/laravel/docs/5.1/
http://user.yeeyan.org/u/seth
SystemTap is commonly used to probe or trace kernel space system or function calls. Excellent examples are at
https://sourceware.org/systemtap ... temtap-scripts.html
Beginning with certain Linux kernel level, the uprobes kernel module allows SystemTap to probe user space processes. Newer kernel has uprobes module instead. Make sure you have one of the modules configured:
grep CONFIG_UTRACE /boot/config-`uname -r`
grep CONFIG_UPROBES /boot/config-`uname -r`
Other people have used SystemTap to probe Oracle user processes. See examples at
https://sourceware.org/systemtap/wiki/HomePage
Find (press ^F) "oracle" in browser to see them. But they all require that you already know the specific function to probe, such as kslwtbctx that signifies the beginning of a wait event.
Here, I'll use the para-callgraph.stp script from
https://www.sourceware.org/syste ... /paracallgraph.html
to probe Oracle server processes with no prior knowledge of which function to probe; I just want to see what function is called. Since I don't intend to pass the 2nd optional argument (used as trigger), I simplify the para-callgraph.stp script by removing the conditional compilation lines as follows (I renamed the filename to cg.stp to save typing):
# cat cg.stp
#! /usr/bin/env stap
function trace(entry_p, extra) {
printf("%s%s%s %s\n",
thread_indent (entry_p),
(entry_p>0?"->":"<-"),
ppfunc (),
extra)
}
probe $1.call { trace(1, $$parms) }
probe $1.return { trace(-1, $$return) }
Let's say I want to probe all Oracle server processes calling functions named like kks*:
# stap cg.stp 'process("/u01/app/oracle/product/11.2.0/db/bin/oracle").function("kks*")'
0 oracle(5588):->kksCompileCallNotifier
17 oracle(5588):<-kksCompileCallNotifier
0 oracle(5860):->kksMapCursor
16 oracle(5860):<-kksMapCursor
0 oracle(5860):->kksMapCursor
5 oracle(5860):<-kksMapCursor
^C
Two processes were captured calling kksCompileCallNotifier and kksMapCursor functions, respectively.
We can limit the probe to a specific process with -x option:
# stap cg.stp 'process("/u01/app/oracle/product/12c/db/bin/oracle").function("kks*")' -x 62148
0 oracle_62148_sa(62148):->kksMapCursor
43 oracle_62148_sa(62148): ->kksParentCursor
64 oracle_62148_sa(62148): <-kksParentCursor
71 oracle_62148_sa(62148): ->kksParentCursor
81 oracle_62148_sa(62148): <-kksParentCursor
90 oracle_62148_sa(62148):<-kksMapCursor
0 oracle_62148_sa(62148):->kksCloseCursor
19 oracle_62148_sa(62148): ->kksGetStats
36 oracle_62148_sa(62148): <-kksGetStats
47 oracle_62148_sa(62148): ->kksdip
64 oracle_62148_sa(62148): <-kksdip
89 oracle_62148_sa(62148): ->kksIsVPDCursorSessionCacheable
106 oracle_62148_sa(62148): <-kksIsVPDCursorSessionCacheable
121 oracle_62148_sa(62148):<-kksCloseCursor
0 oracle_62148_sa(62148):->kksMapCursor
^C
One issue is that because the oracle binary has tens of thousands of global and local functions (check with `nm $ORACLE_HOME/bin/oracle | egrep ' [Tt] ' | wc -l), if you simply pass * as the argument to function, stap hogs the CPU for a long time to enumerate the functions and no probe will be done. You have to limit the functions to a small set. My test shows that even trying to probe kk*, not alone k*, takes stap too long to prepare and I have to abort. Focusing on function main can be a start:
stap cg.stp 'process("/u01/app/oracle/product/11.2.0/db/bin/oracle").function("main")'
If you probe other binaries, such as sqlplus or tnslsnr or lsnrctl, passing * is fine. They don't contain too many functions.
Due to this issue, I didn't quite achieve the goal of "want to see what function is called", because I can't pass a simple * and have to qualify it to some extent.
Another issue is that $$parms and $$return, the two so-called pretty printing target variables, are always null for me. If they worked, they would show function parameters and function return value, respectively. See https://sourceware.org/systemtap ... rgetprettyprinting. I was able to use ulong_arg or s64_arg function to get a specific argument (e.g. the first one) in number format, e.g.
function trace(entry_p, extra) {
printf("%s%s%s %ld\n",
thread_indent (entry_p),
(entry_p>0?"->":"<-"),
ppfunc (),
extra)
}
function trace2(entry_p) {
printf("%s%s%s\n",
thread_indent (entry_p),
(entry_p>0?"->":"<-"),
ppfunc ())
}
//probe $1.call { trace(1, ulong_arg(1)) }
probe $1.call { trace(1, s64_arg(1)) }
probe $1.return { trace2(-1) }
I have to omit the second argument of the trace function used by return so I changed it to trace2. The result is
0 oracle(5588):->kksCompileCallNotifier 2
10 oracle(5588):<-kksCompileCallNotifier
0 oracle(5860):->kksMapCursor 139787894174976
9 oracle(5860):<-kksMapCursor
^C
systemtap-与 oracle 转的更多相关文章
- Life of an Oracle I/O: tracing logical and physical I/O with systemtap
https://db-blog.web.cern.ch/blog/luca-canali/2014-12-life-oracle-io-tracing-logical-and-physical-io- ...
- 使用动态跟踪技术SystemTap监控MySQL、Oracle性能
[IT168 技术]本文根据吕海波2018年5月11日在[第九届中国数据库技术大会]上的演讲内容整理而成. 讲师介绍: 吕海波,美创科技研究员,ITPUB管理版版主.出版技术书籍<Oracle内 ...
- oracle systemtap tracing
https://github.com/LucaCanali?tab=repositories https://github.com/LucaCanali/Linux_tracing_scripts/t ...
- systemtap dtrace与 oracle
https://fritshoogland.wordpress.com/page/3/ http://externaltable.blogspot.com/2013/06/dtrace-explora ...
- 动态追踪技术(中) - Dtrace、SystemTap、火焰图
http://openresty.org/cn/presentations.html http://weibo.com/agentzh?is_all=1 http://openresty.org/po ...
- 内核调试神器SystemTap — 简介与使用(一)
a linux trace/probe tool. 官网:https://sourceware.org/systemtap/ 简介 SystemTap是我目前所知的最强大的内核调试工具,有些家伙甚至说 ...
- linux 内核分析工具 Dtrace、SystemTap、火焰图、crash等
<< System语言详解 >> 关于 SystemTap 的书. 我们在分析各种系统异常和故障的时候,通常会用到 pstack(jstack) /pldd/ lsof/ tc ...
- Linux Perf Probes for Oracle Tracing
Luca Canali on 21 Jan 2016 Topic: this post is about Linux perf and uprobes for tracing and profilin ...
- Linux BPF/bcc for Oracle Tracing
Luca Canali on 26 May 2016 Topic: In this post you will find a short discussion and pointers to the ...
随机推荐
- ASP.NET MVC 常用内置验证特性 简介
1.[Required] : 必须输入 [Required(ErrorMessage = "请输入用户名")] 2.[StringLength] : 限制字符串长度 [String ...
- linux 新学到的命令
nohup python -u /data/daemon/daemon/run.py & 使py程序可以在后台运行 nohup php a.php & 在linux平台上,要在后台运行 ...
- SQL Server 系统视图
SQL Server系统视图非常的多,因此不可能一个一个地写,我最近一直在想,对于数据库的系统视图应该如何学,但是看了一下目录之后,我呆了,我觉得每个写一次,可能都要花费1个星期的时间,如果对每一个返 ...
- C++11变长参数模板
[C++11变长参数模板] C++03只有固定模板参数.C++11 加入新的表示法,允许任意个数.任意类别的模板参数,不必在定义时将参数的个数固定. 实参的个数也可以是 0,所以 tuple<& ...
- c语言指针详解(转载)
转自(http://blog.csdn.net/ad_ad_ad/article/details/1522145) 指针是C语言中广泛使用的一种数据类型. 运用指针编程是C语言最主要的风格之一.利用指 ...
- HDU2819Swap(二分图最大匹配)
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=2819 题目大意很明确,交换图的某些行或者是某些列(可以都换),使得这个N*N的图对角线上全部都是1. ...
- chrome emulator use-agent 设置 chrom模拟手机客户端
谷歌升级以后,发现找不到use-agent设置了 在Element 下点击ESC 出现console,再点击Emulation就出现了
- spring+jpg环境下,spring实现文件上传
jsp: <form method="post" action="excel.do?method=inputExcel" enctype="mu ...
- windows 下使用免安裝版MySql5.5
windows 下使用面安裝版MySql5.5步驟如下 1.解壓下載的壓縮文件到指定文件夾.如:F:\DB\mysql-5.5.18-win32\mysql-5.5.18-win32: 2.在根目錄F ...
- Fragment实现底部选项卡切换效果
现在很多APP的样式都是底部选项卡做为首页的,实现这样的效果,我们一般有这样几种方式,第一,最屌丝的做法,我直接自定义选项卡视图,通过监听选项卡视图,逻辑控制内容页的切换,这样做的想法一般是反正这几个 ...