Skip to content

Instantly share code, notes, and snippets.

@wolfeidau wolfeidau/systemtap.md
Last active Oct 29, 2018

Embed
What would you like to do?
Configuring system tap on ubuntu 13.04, yeah so it will work.. like at all..
  • Install a base server with open ssh server enabled.
  • Update the OS.
sudo apt-get update
sudo apt-get upgrade
  • Install developement tools.
sudo apt-get install build-essential
  • Install system tap
sudo apt-get install systemtap
sudo apt-get install systemtap-sdt-dev
  • Configure debug debian package source.
sudo tee /etc/apt/sources.list.d/ddebs.list << EOF
deb http://ddebs.ubuntu.com/ quantal          main restricted universe multiverse
deb http://ddebs.ubuntu.com/ quantal-security main restricted universe multiverse
deb http://ddebs.ubuntu.com/ quantal-updates  main restricted universe multiverse
deb http://ddebs.ubuntu.com/ quantal-proposed main restricted universe multiverse
EOF
  • Add the key for the DDEB package source and update.
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ECDCAD72428D7C01
sudo apt-get update
  • Install the debug version of the current kernel.
sudo apt-get install linux-image-$(uname -r)-dbgsym
  • Install git.
sudo apt-get install git
  • Clone the fork of nodejs owned by @tjfontaine and checkout the systemtap branch.
$ git clone git://github.com/tjfontaine/node.git 
$ cd node
$ git checkout systemtap
  • Create a install location for this test install of nodejs
mkdir $HOME/nodejs
  • Build nodejs with dtrace support enabled.
./configure --prefix=$HOME/nodejs/head --with-dtrace
make -j5 install
  • Run node in another shell, then query the node process for available probes.
$ stap -L 'process("node").mark("*")'
process("node").mark("gc__done") $arg1:long $arg2:long
process("node").mark("gc__start") $arg1:long $arg2:long
process("node").mark("http__client__request") $arg1:long $arg2:long $arg3:long $arg4:long $arg5:long $arg6:long $arg7:long
process("node").mark("http__client__response") $arg1:long $arg2:long $arg3:long $arg4:long
process("node").mark("http__server__request") $arg1:long $arg2:long $arg3:long $arg4:long $arg5:long $arg6:long $arg7:long
process("node").mark("http__server__response") $arg1:long $arg2:long $arg3:long $arg4:long
process("node").mark("net__server__connection") $arg1:long $arg2:long $arg3:long $arg4:long
process("node").mark("net__socket__read") $arg1:long $arg2:long $arg3:long $arg4:long $arg5:long
process("node").mark("net__socket__write") $arg1:long $arg2:long $arg3:long $arg4:long $arg5:long
process("node").mark("net__stream__end") $arg1:long $arg2:long $arg3:long $arg4:long
  • Give your logged in user rights to run stap.
$ sudo usermod -a -G stapsys,stapdev,stapusr markw
  • Tweak the sources for stap so it doesn't bomb out creating the probes.
markw@ubuntu1210server01:~$ diff /usr/share/systemtap/runtime/uprobes-inode.c /usr/share/systemtap/runtime/uprobes-inode.c.bak
94c94
<   	uprobe_unregister(uc->target->inode, uc->offset,
---
> 		unregister_uprobe(uc->target->inode, uc->offset,
107c107
< 		ret = uprobe_register(uc->target->inode, uc->offset,
---
> 		ret = register_uprobe(uc->target->inode, uc->offset,
  • Using these probes I am currently running into the following error.
$ stap --vp 00001 --vp 00001 --vp 00001 --vp 00001 --vp 00001 --vp 00001 -I ~/nodejs/head/share/systemtap/tapset/ -e 'probe node_http_server_request { println(probestr); }'
Pass 5: starting run.
Running /usr/bin/staprun -v -v -R /tmp/staphqkfwG/stap_d99f81d30be4ba5ed701ceb812886f06_3389.ko
staprun:main:385 modpath="/tmp/staphqkfwG/stap_d99f81d30be4ba5ed701ceb812886f06_3389.ko", modname="stap_d99f81d30be4ba5ed701ceb812886f06_3389"
staprun:init_staprun:303 init_staprun
staprun:insert_module:72 inserting module /tmp/staphqkfwG/stap_d99f81d30be4ba5ed701ceb812886f06_3389.ko
staprun:insert_module:98 module options: _stp_bufsize=0
staprun:insert_module:106 module path canonicalized to '/tmp/staphqkfwG/stap_d99f81d30be4ba5ed701ceb812886f06_3389.ko'
staprun:check_signature:428 checking signature for /tmp/staphqkfwG/stap_d99f81d30be4ba5ed701ceb812886f06_3389.ko
Signature file /tmp/staphqkfwG/stap_d99f81d30be4ba5ed701ceb812886f06_3389.ko.sgn not found
staprun:check_signature:441 verify_module returns 0
staprun:insert_module:169 Renaming module 'stap_d99f81d30be4ba5ed701ceb812886f06_3389'
staprun:insert_module:177 Renamed module to 'stap_d99f81d30be4ba5ed701ceb812886f06_3723'
staprun:init_ctl_channel:31 Opened /sys/kernel/debug/systemtap/stap_d99f81d30be4ba5ed701ceb812886f06_3723/.cmd (3)
staprun:remove_module:221 stap_d99f81d30be4ba5ed701ceb812886f06_3723
staprun:init_ctl_channel:31 Opened /sys/kernel/debug/systemtap/stap_d99f81d30be4ba5ed701ceb812886f06_3723/.cmd (3)
Error, 'stap_d99f81d30be4ba5ed701ceb812886f06_3723' is not a zombie systemtap module.
Spawn waitpid result (0x100): 1
WARNING: /usr/bin/staprun exited with status: 1
Pass 5: run completed in 0usr/0sys/11real ms.
Pass 5: run failed.  Try again with another '--vp 00001' option.
Running rm -rf /tmp/staphqkfwG
Spawn waitpid result (0x0): 0

So @tjfontaine says in #libuv..

wolfeida_: do-release-upgrade -d bet it will just work after that :)

And it it fkn did too.. after upgrading to 13.04 I started a simple node.js server in another terminal and ran the following stap one liner.

markw@ubuntu1210server01:~$ stap -I ~/nodejs/head/share/systemtap/tapset/ -e 'probe node_http_server_request { println(probestr); }'
http__server__request(remote=192.168.198.1, port=64913, method=GET, url=/, fd=11)
http__server__request(remote=192.168.198.1, port=64913, method=GET, url=/favicon.ico, fd=11)

Post upgrade I am running.

markw@ubuntu1210server01:~$ lsb_release -a
No LSB modules are available.
Distributor ID:  Ubuntu
Description:	Ubuntu Raring Ringtail (development branch)
Release:	13.04
Codename:	raring
@jamesbloomer

This comment has been minimized.

Copy link

commented Nov 13, 2013

Is 13.04 a requirement then? Got servers on 12.04 that I want to use it on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.