今天主要分享下systemtap安装的一些内容。Ubuntu是我在家用的linux发行版,一直以来用Ubuntu 10.04LTS,最近彻底重装了,用了Ubuntu 12.04 LTS。 systemtap的安装排在了优先级比较高的位置。
我的Ubuntu的版本信息如下:
- 17:25:43 UTC 2012 i686 i686 i386 GNU/Linux
安装systemtap,有两篇文章介绍的比较好,一篇是,步骤有点多,可能不太适合初学者,另外还有一片文章,Running systemtap on Ubuntu,这篇文章讲的非常的详细,可惜是英文,如果英文水平高的筒子可以直接跳过我这篇博文,直接看原著。
第一步:安装systemtap
- sudo apt-get install systemtap
- root@manu:~/code/shell# stap -e 'probe kernel.function("sys_open") {log("hello world") exit()}'
- semantic error: missing i386 kernel/module debuginfo under '/lib/modules/3.2.0-29-generic-pae/build' while resolving probe point kernel.function("sys_open")
- Pass 2: analysis failed. Try again with another '--vp 01' option.
- root@manu:~/code/shell#
上面提到的第二个博文的作者,十分kind的提供了个脚本工具,他的博文 getting debug kernel on Ubuntu 讲了这个步骤,我仔细看过了他的脚本,非常的好。
第二步:下载这位外国高手提供的脚本。并且chmod 提供执行权限
- root@manu:~/code/shell# wget
- root@manu:~/code/shell# chmod a+x get-dbgsym
第三步 就是执行这个脚本,这个脚本会下载需要的软件包,并且安装:
- root@manu:~/code/shell# ./get-dbgsym
这个包安装好之后,就可以用systemtap来探测内核信息了。
- root@manu:~/code/shell# stap -e 'probe kernel.function("sys_open") {log("hello world") exit()}'
- hello world
- root@manu:~/code/shell#
这个安装方法比较简单,一共就4个步骤,而且还可以欣赏下国外coder写的脚本,我很喜欢。这个coder十分周到的提到了其他需要注意的事情,比如如何给某个非root用户赋予权限,感兴趣的筒子可以去看下。
参考文献:
1 systemtap wiki
2 文中提到外国coder的两篇博文。