systemtap 在Ubuntu上安装

来源:互联网 发布:mac怎么关闭访客模式 编辑:程序博客网 时间:2024/05/17 22:39
http://blog.chinaunix.net/uid-24774106-id-3404192.html

    systemtap是一个很有用的工具,熟悉我博客的可以看出我以前用过这个工具,这个工具的有点就在于高度的可定制,只要你对内核足够的熟悉,你可以观测很多参数或者数据,得到Linux很多的信息。在这方面,淘宝的霸爷是大师级的高手。我最早接触systemtap就是从霸爷的博客里面接触的。

    今天主要分享下systemtap安装的一些内容。Ubuntu是我在家用的linux发行版,一直以来用Ubuntu 10.04LTS,最近彻底重装了,用了Ubuntu 12.04 LTS。 systemtap的安装排在了优先级比较高的位置。

    我的Ubuntu的版本信息如下:
   

  1.  17:25:43 UTC 2012 i686 i686 i386 GNU/Linux

    安装systemtap,有两篇文章介绍的比较好,一篇是官方文档A guide on how to install systemtap on an ubuntu system,步骤有点多,可能不太适合初学者,另外还有一片文章,Running systemtap on Ubuntu,这篇文章讲的非常的详细,可惜是英文,如果英文水平高的筒子可以直接跳过我这篇博文,直接看原著。

    第一步:安装systemtap

  1. sudo apt-get install systemtap
    仅仅有systemtap,是不能探测Linux内核信息的,需要装内核的debuginfo。看下面我没装debuginfo 之前的报错:

  
  1. root@manu:~/code/shell# stap -e 'probe kernel.function("sys_open") {log("hello world") exit()}'
  2. 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")
  3. Pass 2: analysis failed. Try again with another '--vp 01' option.
  4. root@manu:~/code/shell#
    这个淘宝的霸爷解释过,我就不浪费口舌了。一般来说装systemtap,就会卡壳在这个debuginfo步骤。

    上面提到的第二个博文的作者,十分kind的提供了个脚本工具,他的博文 getting debug kernel on Ubuntu 讲了这个步骤,我仔细看过了他的脚本,非常的好。

     第二步:下载这位外国高手提供的脚本。并且chmod 提供执行权限

  1. root@manu:~/code/shell# wget http://www.domaigne.com/download/tools/get-dbgsym

  2. root@manu:~/code/shell# chmod a+x get-dbgsym
    这个脚本写的很cool,主要的思路就是去http://ddebs.ubuntu.com/pool/main/l/linux/路径下找到自己的Ubuntu对应版本的debuginfo,下载下来,然后安装。感兴趣的筒子可以去读一下他的shell脚本。

    第三步 就是执行这个脚本,这个脚本会下载需要的软件包,并且安装:

  1. root@manu:~/code/shell# ./get-dbgsym
    这一步比较费时间,,因为脚本要去下载ddeb包,而这个包好几百M。

    这个包安装好之后,就可以用systemtap来探测内核信息了。


  1. root@manu:~/code/shell# stap -e 'probe kernel.function("sys_open") {log("hello world") exit()}'
  2. hello world
  3. root@manu:~/code/shell#

    这个安装方法比较简单,一共就4个步骤,而且还可以欣赏下国外coder写的脚本,我很喜欢。这个coder十分周到的提到了其他需要注意的事情,比如如何给某个非root用户赋予权限,感兴趣的筒子可以去看下。

参考文献:
1 systemtap wiki
2 文中提到外国coder的两篇博文。


<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(748) | 评论(0) | 转发(3) |
0

上一篇:K-Means++ 聚类之数据可视化:使用gnuplot

下一篇:Linux 从虚拟地址到物理地址

相关热门文章
  • linux 常见服务端口
  • xmanager 2.0 for linux配置
  • 【ROOTFS搭建】busybox的httpd...
  • openwrt中luci学习笔记
  • 什么是shell
  • linux dhcp peizhi roc
  • 关于Unix文件的软链接
  • 求教这个命令什么意思,我是新...
  • sed -e "/grep/d" 是什么意思...
  • 谁能够帮我解决LINUX 2.6 10...
给主人留下些什么吧!~~
原创粉丝点击