DTraceとは
DTrace(ダイナミックトレース)とはサン・マイクロシステムズが開発しSolaris 10およびOpenSolaris、Mac OS X、FreeBSDに搭載されているシステム情報取得機能
DTraceを使用することにより、システム、アプリケーションに手を加えることなく、動的なトレースができる
ユーザプロセスだけでなくカーネル内部まで追跡でき、非常に負荷が低いため本番環境でも利用可能
上記のOS以外については、”dtrace for linux”を利用してカーネルに組み込むことが可能
DTraceもどきインストール方法
Solarisの dtraceとは異なり、できることが限られる
root@hostname:/home/admin# aptitude install systemtap-sdt-dev 以下の新規パッケージがインストールされます: systemtap-sdt-dev root@hostname:/home/admin# dtrace Usage /usr/bin/dtrace [--help] [-h | -G] [-C [-I<Path>]] -s File.d [-o <File>]
DTraceインストール方法 -結局インストールできず-
http://www.blackpig.jp/?p=247
http://liberumvir.com/2012/06/01/zfs-and-dtrace-running-on-ubuntu.html
を参考にdebian7にDTraceをインストールしようとしたが、できなかった
READMEにArchLinux・Ubuntu・RedHat/Fedoraでできそうなことは確認したが、debianの文字はなく、ネットにて有力な情報も見つけられなかった
ここ(公式サイト含め)からダウンロードしろという情報がいくつかあるが、現在(2014/9/4)ホスト名が名前解決できない状態
ftp://crisp.dyndns-server.com/pub/release/website/dtrace
一応ログとしてあがいた記録を残しておく
root@hostname:/home/admin# aptitude install git
以下の新規パッケージがインストールされます:
git git-man{a} less{a} liberror-perl{a} patch{a}
root@hostname:/home/admin# cd /usr/local/src/
root@hostname:/usr/local/src# git clone git://github.com/ShepBook/dtrace-for-linux.git
root@hostname:/usr/local/src# cd dtrace-for-linux/
root@hostname:/usr/local/src/dtrace-for-linux# aptitude install build-essential
以下の新規パッケージがインストールされます:
binutils{a} build-essential cpp{a} cpp-4.7{a} dpkg-dev{a} fakeroot{a} g++{a} g++-4.7{a} gcc{a} gcc-4.7{a} libalgorithm-diff-perl{a} libalgorithm-diff-xs-perl{a} libalgorithm-merge-perl{a} libc-dev-bin{a}
libc6-dev{a} libdpkg-perl{a} libfile-fcntllock-perl{a} libgmp10{a} libgomp1{a} libitm1{a} libmpc2{a} libmpfr4{a} libquadmath0{a} libstdc++6-4.7-dev{a} libtimedate-perl{a} linux-libc-dev{a} make{a} manpages-dev{a}
更新: 0 個、新規インストール: 28 個、削除: 0 個、保留: 0 個。
root@hostname:/usr/local/src/dtrace-for-linux# aptitude install zlib1g-dev bison libc6-dev libelf-dev libdwaf-dev
名前か説明が "libdwaf-dev" にマッチするパッケージは見つかりませんでした
名前か説明が "libdwaf-dev" にマッチするパッケージは見つかりませんでした
以下の新規パッケージがインストールされます:
bison libbison-dev{a} libelf-dev libelf1{a} m4{a} zlib1g-dev
更新: 0 個、新規インストール: 6 個、削除: 0 個、保留: 0 個。
root@hostname:/usr/local/src/dtrace-for-linux# aptitude install libdwarf-dev
以下の新規パッケージがインストールされます:
libdwarf-dev
更新: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。
root@hostname:/usr/local/src/dtrace-for-linux# make all
BUILD_DIR=build-3.2.0-4-amd64 tools/build.pl build-3.2.0-4-amd64 `uname -m`
Sorry - but I cannot find flex on your system.
You may need to install more packages. See tools/get-deps.pl, or
tools/get-deps-fedora.pl which can automate package installation.
Continue ? [y/n] n
make: *** [all] エラー 1
root@hostname:/usr/local/src/dtrace-for-linux# aptitude install flex
以下の新規パッケージがインストールされます:
flex
更新: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。
root@hostname:/usr/local/src/dtrace-for-linux# make all
BUILD_DIR=build-3.2.0-4-amd64 tools/build.pl build-3.2.0-4-amd64 `uname -m`
tools/check_dep.pl
tools/mkport.pl
/usr/bin/ld: cannot find -lbfd
collect2: error: ld returned 1 exit status
grep: /usr/src/kernels/3.2.0-4-amd64/include/linux/fs.h: No such file or directory
tools/libgcc.pl
/usr/lib/gcc/x86_64-linux-gnu/4.7
tools/mksyscall.pl
mksyscall.pl: [x86] Unable to generate syscall table, syscall_count==0, which looks
suspiciously too low. Might have misparsed the sys_call_table
mksyscall.pl: [x86-64] Unable to generate syscall table, syscall_count==0, which looks
suspiciously too low. Might have misparsed the sys_call_table
make all0
cd tests ; make --no-print-directory
case `uname -m` in \
x86_64) \
cc -m64 -g -o ../build-3.2.0-4-amd64/sys64 syscalls.c ; \
cc -m32 -g -o ../build-3.2.0-4-amd64/sys32 syscalls.c ; \
;; \
i686) \
cc -m32 -g -o ../build-3.2.0-4-amd64/sys32 syscalls.c ; \
;; \
esac
In file included from /usr/include/stdio.h:28:0,
from syscalls.c:7:
/usr/include/features.h:323:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
make[2]: *** [all] Error 1
make[1]: *** [do_cmds] Error 2
tools/bug.sh
======================
== Sorry - but dtrace failed to compile on your system.
== Please forward the following file to:
==
== file: /tmp/dtrace-bug.19203.txt
== mail: Crisp.Editor@gmail.com
== mail: dtrace@crisp.demon.co.uk
==
== and the information provided will be used to help
== enhance the tool and fix the underlying issue.
==
== Latest news and blog updates on dtrace available here. Please
== check for latest problem reports.
==
== http://crtags.blogspot.com
== http://www.crisp.demon.co.uk/blog/
==
== Latest downloads available from here:
==
== ftp://crisp.dyndns-server.com/pub/release/website/dtrace
== ======================
(generating a make run - this may take a few moments...)
make: *** [all] エラー 1
root@hostname:/usr/local/src/dtrace-for-linux# aptitude install binutils-dev zlib1g-dev flex bison elfutils libdwarf-dev libelf-dev libc6-dev libc-dev zlib1g-dev linux-libc-dev
以下の新規パッケージがインストールされます:
binutils-dev elfutils libasm1{a} libdw1{a}
更新: 0 個、新規インストール: 4 個、削除: 0 個、保留: 0 個。
root@hostname:/usr/local/src/dtrace-for-linux# make all
BUILD_DIR=build-3.2.0-4-amd64 tools/build.pl build-3.2.0-4-amd64 `uname -m`
tools/check_dep.pl
tools/mkport.pl
grep: /usr/src/kernels/3.2.0-4-amd64/include/linux/fs.h: No such file or directory
tools/libgcc.pl
tools/mksyscall.pl
mksyscall.pl: [x86] Unable to generate syscall table, syscall_count==0, which looks
suspiciously too low. Might have misparsed the sys_call_table
mksyscall.pl: [x86-64] Unable to generate syscall table, syscall_count==0, which looks
suspiciously too low. Might have misparsed the sys_call_table
make all0
cd tests ; make --no-print-directory
case `uname -m` in \
x86_64) \
cc -m64 -g -o ../build-3.2.0-4-amd64/sys64 syscalls.c ; \
cc -m32 -g -o ../build-3.2.0-4-amd64/sys32 syscalls.c ; \
;; \
i686) \
cc -m32 -g -o ../build-3.2.0-4-amd64/sys32 syscalls.c ; \
;; \
esac
In file included from /usr/include/stdio.h:28:0,
from syscalls.c:7:
/usr/include/features.h:323:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
make[2]: *** [all] Error 1
make[1]: *** [do_cmds] Error 2
tools/bug.sh
make: *** [all] エラー 1
###### 方法変更、READMEにtarやzipファイルが記載されていたため、そちらでやってみることに ######
root@hostname:/usr/local/src# wget -d http://dl.dropbox.com/u/45405441/dtrace-latest.tar.gz
DEBUG output created by Wget 1.13.4 on linux-gnu.
(中略)
2014-09-04 13:31:10 エラー 404: Not Found。
root@hostname:/usr/local/src# wget -d https://github.com/dtrace4linux/linux/archive/master.zip
root@hostname:/usr/local/src# unzip master.zip
root@hostname:/usr/local/src# cd linux-master
root@hostname:/usr/local/src/linux-master# make all
BUILD_DIR=build-3.2.0-4-amd64 tools/build.pl build-3.2.0-4-amd64 `uname -m`
tools/check_dep.pl
tools/mkport.pl
/usr/bin/ld: cannot find -ldw
collect2: error: ld returned 1 exit status
grep: /usr/src/kernels/3.2.0-4-amd64/include/linux/fs.h: No such file or directory
Generating: build-3.2.0-4-amd64/port.h
tools/libgcc.pl
/usr/lib/gcc/x86_64-linux-gnu/4.7
tools/mksyscall.pl
mksyscall.pl: [x86] Unable to generate syscall table, syscall_count==0, which looks
suspiciously too low. Might have misparsed the sys_call_table
mksyscall.pl: [x86-64] Unable to generate syscall table, syscall_count==0, which looks
suspiciously too low. Might have misparsed the sys_call_table
make all0
cd tests ; make --no-print-directory
case `uname -m` in \
x86_64) \
cc -m64 -g -o ../build-3.2.0-4-amd64/sys64 syscalls.c ; \
cc -m32 -g -o ../build-3.2.0-4-amd64/sys32 syscalls.c || true ; \
;; \
i686) \
cc -m32 -g -o ../build-3.2.0-4-amd64/sys32 syscalls.c ; \
;; \
arm*) \
cc -g -o ../build-3.2.0-4-amd64/sys32 syscalls.c ; \
;; \
esac
In file included from /usr/include/stdio.h:28:0,
from syscalls.c:7:
/usr/include/features.h:323:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
cd libctf ; make --no-print-directory
gcc -g -I../common -I../common/ctf -I../uts/common/ -I../common/ctf -I. -I../linux -DCTF_OLD_VERSIONS -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -c -o ctf_lib.o ctf_lib.c
In file included from ../linux/sys/types.h:4:0,
from ctf_lib.c:29:
../linux/linux_types.h:142:38: fatal error: /usr/include/sys/types.h: No such file or directory
compilation terminated.
make[2]: *** [ctf_lib.o] Error 1
make[1]: *** [do_cmds] Error 2
tools/bug.sh
======================
== Sorry - but dtrace failed to compile on your system.
== Please forward the following file to:
==
== file: /tmp/dtrace-bug.19526.txt
== mail: Crisp.Editor@gmail.com
==
== and the information provided will be used to help
== enhance the tool and fix the underlying issue.
==
== Latest news and blog updates on dtrace available here. Please
== check for latest problem reports.
==
== http://crtags.blogspot.com
== http://www.crisp.demon.co.uk/blog/
==
== Latest downloads available from here:
==
== ftp://crisp.dyndns-server.com/pub/release/website/dtrace
== ======================
==
== Common problems:
== 1. Run tools/get-deps.pl or get-deps-fedora.sh or get-deps-arch.sh
== to ensure everything is needed or a build.
== 2. Currently (Nov 2012) issues on Xen guests (Amazon EC2). Working
== to fix.
(generating a make run - this may take a few moments...)
make: *** [all] エラー 1
root@hostname:/usr/local/src/linux-master# aptitude search libdw
p libdw-dev - libdw1 development libraries and header files
i A libdw1 - library that provides access to the DWARF debug information
i libdwarf-dev - library to consume and produce DWARF debug information
root@hostname:/usr/local/src/linux-master# aptitude install libdw-dev
以下の新規パッケージがインストールされます:
libdw-dev
更新: 0 個、新規インストール: 1 個、削除: 0 個、保留: 0 個。
151 k バイトのアーカイブを取得する必要があります。展開後に 629 k バイトのディスク領域が新たに消費されます。
以下のパッケージには満たされていない依存関係があります:
libdwarf-dev : 競合: libdw-dev [0.152-1+wheezy1 がインストール予定となっています]
以下のアクションでこれらの依存関係の問題は解決されます:
以下のパッケージを削除する:
1) libdwarf-dev
この解決方法を受け入れますか? [Y/n/q/?]y
以下の新規パッケージがインストールされます:
libdw-dev
以下のパッケージが削除されます:
libdwarf-dev{a}
更新: 0 個、新規インストール: 1 個、削除: 1 個、保留: 0 個。
151 k バイトのアーカイブを取得する必要があります。展開後に 552 k バイトのディスク領域が解放されます。
先に進みますか? [Y/n/?] y
root@hostname:/usr/local/src/linux-master# make all
BUILD_DIR=build-3.2.0-4-amd64 tools/build.pl build-3.2.0-4-amd64 `uname -m`
tools/check_dep.pl
tools/mkport.pl
grep: /usr/src/kernels/3.2.0-4-amd64/include/linux/fs.h: No such file or directory
Generating: build-3.2.0-4-amd64/port.h
tools/libgcc.pl
tools/mksyscall.pl
mksyscall.pl: [x86] Unable to generate syscall table, syscall_count==0, which looks
suspiciously too low. Might have misparsed the sys_call_table
mksyscall.pl: [x86-64] Unable to generate syscall table, syscall_count==0, which looks
suspiciously too low. Might have misparsed the sys_call_table
make all0
cd tests ; make --no-print-directory
case `uname -m` in \
x86_64) \
cc -m64 -g -o ../build-3.2.0-4-amd64/sys64 syscalls.c ; \
cc -m32 -g -o ../build-3.2.0-4-amd64/sys32 syscalls.c || true ; \
;; \
i686) \
cc -m32 -g -o ../build-3.2.0-4-amd64/sys32 syscalls.c ; \
;; \
arm*) \
cc -g -o ../build-3.2.0-4-amd64/sys32 syscalls.c ; \
;; \
esac
In file included from /usr/include/stdio.h:28:0,
from syscalls.c:7:
/usr/include/features.h:323:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
cd libctf ; make --no-print-directory
gcc -g -I../common -I../common/ctf -I../uts/common/ -I../common/ctf -I. -I../linux -DCTF_OLD_VERSIONS -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -c -o ctf_lib.o ctf_lib.c
In file included from ../linux/sys/types.h:4:0,
from ctf_lib.c:29:
../linux/linux_types.h:142:38: fatal error: /usr/include/sys/types.h: No such file or directory
compilation terminated.
make[2]: *** [ctf_lib.o] Error 1
make[1]: *** [do_cmds] Error 2
tools/bug.sh
make: *** [all] エラー 1
root@hostname:/usr# find / -name "fs.h"
/usr/include/linux/fs.h
root@hostname:/usr# cd src/
root@hostname:/usr/src# ls
root@hostname:/usr/src# mkdir -p kernels/3.2.0-4-amd64/
root@hostname:/usr/src# cd kernels/3.2.0-4-amd64/
root@hostname:/usr/src/kernels/3.2.0-4-amd64# ln -s /usr/include
root@hostname:/usr/src/kernels/3.2.0-4-amd64# cd /usr/local/src/linux-master/
root@hostname:/usr/local/src/linux-master# make all
BUILD_DIR=build-3.2.0-4-amd64 tools/build.pl build-3.2.0-4-amd64 `uname -m`
tools/check_dep.pl
tools/mkport.pl
tools/libgcc.pl
tools/mksyscall.pl
mksyscall.pl: [x86] Unable to generate syscall table, syscall_count==0, which looks
suspiciously too low. Might have misparsed the sys_call_table
mksyscall.pl: [x86-64] Unable to generate syscall table, syscall_count==0, which looks
suspiciously too low. Might have misparsed the sys_call_table
make all0
cd tests ; make --no-print-directory
case `uname -m` in \
x86_64) \
cc -m64 -g -o ../build-3.2.0-4-amd64/sys64 syscalls.c ; \
cc -m32 -g -o ../build-3.2.0-4-amd64/sys32 syscalls.c || true ; \
;; \
i686) \
cc -m32 -g -o ../build-3.2.0-4-amd64/sys32 syscalls.c ; \
;; \
arm*) \
cc -g -o ../build-3.2.0-4-amd64/sys32 syscalls.c ; \
;; \
esac
In file included from /usr/include/stdio.h:28:0,
from syscalls.c:7:
/usr/include/features.h:323:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
cd libctf ; make --no-print-directory
gcc -g -I../common -I../common/ctf -I../uts/common/ -I../common/ctf -I. -I../linux -DCTF_OLD_VERSIONS -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 -c -o ctf_lib.o ctf_lib.c
In file included from ../linux/sys/types.h:4:0,
from ctf_lib.c:29:
../linux/linux_types.h:142:38: fatal error: /usr/include/sys/types.h: No such file or directory
compilation terminated.
make[2]: *** [ctf_lib.o] Error 1
make[1]: *** [do_cmds] Error 2
tools/bug.sh
make: *** [all] エラー 1
参考
Dtraceインストール方法
http://askubuntu.com/questions/60940/how-do-i-install-dtrace
makeで「/usr/bin/ld: cannot find」と表示されるときは「-l」に続くライブラリをインストールすれば解消する
http://www.atmarkit.co.jp/flinux/rensai/linuxtips/a115makeerror.html
DTraceの簡単な使い方
http://d.hatena.ne.jp/amachang/20080401/1207037832
仕組み
http://www.itmedia.co.jp/enterprise/articles/0504/22/news030.html