Fedora 18で確認。
下記の2パッケージをダウンロードする。
・trace-cmd-1.2-4.20120606git8266dff.fc18.i686.rpm
・kernelshark-1.2-4.20120606git8266dff.fc18.i686.rpm
下記からパッケージダウンロードしてやりました。
yum、apt-get、git等を使う方がよいです。 (例:yum install trace-cmd)
http://pkgs.org/fedora-18/fedora-updates-testing-i386/kernelshark-1.2-4.20120606git8266dff.fc18.i686.rpm.html
http://pkgs.org/fedora-18/fedora-updates-testing-i386/trace-cmd-1.2-4.20120606git8266dff.fc18.i686.rpm.html
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
・使い方
よく使うlist、record、report、kernelsharkについてまとめる。
【利用可能なイベント、プラグイン、オプションの表示:list】
# trace-cmd
list
plugins:
blk function_graph wakeup_rt wakeup function
sched_switch nop
【イベントの記録:record】
-oで出力ファイル指定、-eでトレース対象イベント指定、-pでPlugin指定。function_graphは
# trace-cmd record
-e block:block_sleeprq -o output.dat
# trace-cmd record -p function_graph ls
# trace-cmd record -e block:block_sleeprq -p function_graph ls
【traceファイルの読み出し:report】
-iで入力ファイル指定。 フィルタもできる。
# trace-cmd report
-i trace.dat
-i:入力ファイル指定。(デフォルトはtrace.dat)
【kernelsharkでグラフィカルに表示:kernelshark】
# kernelshark
trace.dat
-------------------
usage:
trace-cmd [COMMAND] ...
commands:
record - record a trace into a trace.dat file
start - start tracing without recording into a file
extract - extract a trace from the kernel
stop - stop the kernel from recording trace data
reset - disable all kernel tracing and clear the trace buffers
report - read out the trace stored in a trace.dat file
split - parse a trace.dat file into smaller file(s)
options - list the plugin options available for trace-cmd report
listen - listen on a network socket for trace clients
list - list the available events, plugins or options
restore - restore a crashed record
stack - output, enable or disable kernel stack tracing
check-events - parse trace event formats
-------------------
usage:
trace-cmd record [-v][-e event [-f filter]][-p plugin][-F][-d][-o file] \
[-s usecs][-O option ][-l func][-g func][-n func] \
[-P pid][-N host:port][-t][-r prio][-b size][command ...]
-e run command with event enabled
-f filter for previous -e event
-p run command with plugin enabled
-F filter only on the given process
-P trace the given pid like -F for the command
-c also trace the childen of -F or -P
-T do a stacktrace on all events
-l filter function name
-g set graph function
-n do not trace function
-v will negate all -e after it (disable those events)
-d disable function tracer when running
-o data output file [default trace.dat]
-O option to enable (or disable)
-r real time priority to run the capture threads
-s sleep interval between recording (in usecs) [default: 1000]
-N host:port to connect to (see listen)
-t used with -N, forces use of tcp in live trace
-b change kernel buffersize (in kilobytes per CPU)
-k do not reset the buffers after tracing.
-i do not fail if an event is not found
--func-stack perform a stack trace for function tracer
(use with caution)
-------------------
usage:
trace-cmd report [-i file] [--cpu cpu] [-e][-f][-l][-P][-L][-N][-r][-E]\
[-F filter][-v][-V][-T][-O option]
-i input file [default trace.dat]
-e show file endianess
-f show function list
-P show printk list
-E show event files stored
-F filter to filter output on
-r raw format: ignore print format and only show field data
-v will negate all -F after it (Not show matches)
-T print out the filter strings created and exit
-V verbose (shows plugins being loaded)
-L load only local (~/.trace-cmd/plugins) plugins
-N do not load any plugins
-w show wakeup latencies
-l show latency format (default with latency tracers)
-O plugin option -O [plugin:]var[=val]
--check-events return whether all event formats can be
parsed
-------------------