Linux 本番サーバーの詳細を抽出するために systemtap を使用したいと考えています。私のsystemtapスクリプトは
global bt;
global quit = 0
probe begin {
printf("start profiling...\n")
}
probe timer.profile {
if (pid() == target()) {
if (!quit)
{
bt[backtrace(), ubacktrace()] <<< 1
}
else
{
foreach ([sys, usr] in bt- limit 1000)
{
print_stack(sys)
print_ustack(usr)
printf("\t%d\n", @count(bt[sys, usr]))
}
exit()
}
}
}
probe timer.s(20) {
quit = 1
}
コマンドでこのスクリプトを実行し始めると
sudo stap --ldd -d $program_name --all-modules \
-D MAXMAPENTRIES=10240 -D MAXACTION=20000 -D MAXTRACE=40 \
-D MAXSTRINGLEN=4096 -D MAXBACKTRACE=40 -x $program_pid \
profile.stp --vp 00001 > profile.out
失敗し、次のエラーが出力されます。
ERROR: error allocating hash
ERROR: global variable 'bt' allocation failed
WARNING: /usr/bin/staprun exited with status: 1
私の本番サーバーのメモリ情報は
total used free shared buffers cached
Mem: 16008 15639 368 0 80 3090
-/+ buffers/cache: 12468 3539
私のテストサーバーには2Gメモリしかなく、systemtapスクリプトは別のサーバーでうまく動作するため、それで十分だと思います