月曜日 6 23, 2008

以前ブログで公開するといってすっかり忘れていた、Ruby on Rails with DTrace デモ の構築方法をアップします。

RubyにDTrace Patchを当てる方法は、すでに高井さんがプレゼンにしていたり、Ruby DTraceのProbeの概要は、舞波さんがブログにしていたりいるのでそちらを参照してください。

私の方では、DTraceの結果をGUI化するツールChimeのインストール方法や設定方法を書きます。

chimeのインストールは非常に簡単です。

以下のURLからpackageをダウンロードして、pkgaddしてください。

http://opensolaris.org/os/project/dtrace-chime/install/

pkgaddすると、/opt/OSOL0chimeにchimeがインストールされますので

# /opt/OSOL0chim/bin/chime

で、chimeを起動できます。

以下のURLにRuby on Rails用の設定ファイルをアップロードしました。

/opt/OSOL0chime/displarysにコピーすると、chimeから使用できるようになります。

Chime上で 右クリックをすると、Source Fileごとなどに絞って監視ができるようになっています。

自分でカスタマイズしてみたい人は、以下のブログ記事が参考になりますので、是非挑戦してみてください!

http://blogs.sun.com/tomee/entry/chime_and_the_dtracetoolkit

http://blogs.sun.com/tomee/entry/chime_and_the_dtracetoolkit_part



月曜日 8 01, 2005

OpenSolarisのDTrace Communityでは、DTraceスクリプトをまとめたものを、DTrace Toolkitとして公開しています。

(先日、DTrace Toolkitのバージョンがあがり、スクリプトが増えました。)

今回は、DTrace Toolkitの紹介をしてみたいと思います。
DTrace Toolkit DTrace Toolkitは、サン・マイクロシステムズが作成した、DTraceのスクリプトを、機能別に分類してまとめたものです。

(なかにはまだ分類されていないスクリプトもいくつかあります。)

 

配布形態はフリーウェアとなっており、最新のバージョン0.82では、82個のスクリプトが入っています。

また、スクリプト以外にも、ドキュメントやスクリプトを作成する際のテンプレート等も入っています。

DTraceToolkit

* dappprof : profile user and lib function usage

* dapptrace : trace user and lib function usage

* dexplorer : run a series of scripts and archive output

* dtruss : process syscall info. DTrace truss

* dvmstat : vmstat by PID/name/command

* errinfo : report syscall failures with details

* execsnoop : snoop process execution as it occurs

* iosnoop : snoop I/O events as they occur

* iotop : display top disk I/O events by process

* opensnoop : snoop file opens as they occur

* procsystime : analyse process system call times

* rwsnoop : snoop read/write events

* rwtop : display top read/write bytes by process

 

Cpu/

* cputypes.d : list CPU types

* dispqlen.d : dispatcher queue length by CPU

* intbycpu.d : interrupts by CPU

* intoncpu.d : interrput on-cpu usage

* inttimes.d : interrput on-cpu time total

* loads.d : print load averages

 

Disk/

* bitesize.d : print disk event size report

* diskhits : disk access by file offset

* hotspot.d : print disk event by location

* iofile.d : I/O wait time by filename and process

* iopattern : print disk I/O pattern

* pathopens.d : pathnames successfully opened count

* seeksize.d : print disk seek size report

 

Docs/

* oneliners.txt : DTrace oneliners

 

Extra/

* guess.d : guessing game

 

Kernel/

* cputimes : print time by Kernel/Idle/Process

* cpudists : time distribution by Kernel/Idle/Process

* cswstat.d : context switch time statistics

* dnlcps.d : DNLC stats by process

* dnlcsnoop.d : snoop DNLC activity

* dnlcstat : DNLC statistics * pridist.d : process priority distribution

 

Locks/

* lockbyproc.d : lock time by process name

* lockbydist.d : lock time distribution by process name

 

Mem/

* anonpgpid.d : anonymous memory paging info by PID on CPU

* minfbypid.d : minor faults by PID

* minfbyproc.d : minor faults by process name

* pgpginbypid.d : pages paged in by PID

* pgpginbyproc.d : pages paged in by process name

* swapinfo.d : print virtual memory info

* vmbypid.d : virtual memory stats by PID

* vmstat.d : vmstat demo using DTrace

* vmstat-p.d : vmstat -p demo using DTrace

* xvmstat : extended vmstat demo using DTrace

 

Net/

* connections : print inbound TCP connections by process

* icmpstat.d : print ICMP statistics

* tcpsnoop : snoop TCP network packets by process

* tcpsnoop.d : snoop TCP network packets by process

* tcpstat.d : print TCP statistics

* tcptop : display top TCP network packets by process

* tcpwdist.d : simple TCP write distribution by process

* udpstat.d : print UDP statistics

 

Proc/

* crap.d : crashed application report

* creatbyproc.d : snoop file creat() by process name

* fddist : file descriptor usage distribution

* fileproc.d : snoop files opened by process

* kill.d : snoop process signals

* lastwords : print syscalls before exit

* newproc.d : snoop new processes

* pidpersec.d : print new PIDs per sec

* readbytes.d : read bytes by process name

* readdist.d : read distribution by process name

* rwbbypid.d : read/write bytes by PID

* rwbypid.d : read/write calls by PID

* sampleproc : sample processes on the CPUs

* shortlived.d : check short lived process time

* sigdist.d : signal distribution by process name

* sysbypid.d : system stats by PID

* syscallbyproc.d : system calls by process name

* syscallbypid.d : system calls by process ID

* threaded.d : sample multi-threaded CPU usage

* topsysproc : display top syscalls by process name

* writebytes.d : write bytes by process name

* writedist.d : write distribution by process name

 

System/

* sar-c.d : sar -c demo using DTrace

* syscallbysysc.d : system calls by system call

* topsyscall : display top system call type

* uname-a.d : uname -a demo using DTrace

 

User/

* setuids.d : snoop setuid calls

 

Zones/

* zvmstat : vmstat info by zone

 

興味があるスクリプトがありましたら、是非試してみてください。

また、ご自分でスクリプトを作成する際には、DTrace Toolkitに入っているテンプレートを使ってみてください。

 

参考リンク OpenSolaris DTrace Community

水曜日 7 27, 2005

opensolaris.orgでは、いろいろなCommunityがあり、盛んに情報交換が行われています。

dtrace-communityではdtraceの技術情報や便利なスクリプト、ツール等が紹介されています。

今回は、その中からいくつかのスクリプトを紹介してみたいと思います。

 

iosnoop iosnoopは、diskのI/Oを動的に監視するスクリプトです。

Solarisに標準で提供されているiostatとは違い、どのプロセスからI/Oが発生しているのかをリアルタイムで追跡する事ができます。

スクリプトの起動時にオプションを与えることによって、タイムスタンプやI/Oの発生しているディスクを表示することができます。 このスクリプトを使って、1日のDisk I/Oの推移や、I/Oを頻繁に発生させてシステムに負荷をかけているプロセスの発見などに使用できそうです。

iosnoopの実行例:http://users.tpg.com.au/adsln4yb/DTrace/iosnoop_example.html

 

shellsnoop.d shellsnoop.dは、システム上で動作しているshellでどのようなコマンドが実行されて、どのような出力がでているのかをリアルタイムで監視するスクリプトです。

オプションをつけることによって、タイムスタンプや特定のユーザが使用しているshellの状態を表示することができます。

このスクリプトを使って、特定ユーザーの操作履歴を取得したりできそうです。
 

shellsnoop.dの実行例:http://users.tpg.com.au/adsln4yb/DTrace/shellsnoop_example.txt

 

connections connectionsは、生成されたTCPコネクションをリアルタイムに表示するスクリプトです。

Solarisに標準で提供されているsnoopとは違い、システム上でどのようなTCPコネクションが生成されているのかをリアルタイムで表示することができます。

(snoopだと情報が詳細すぎて、追いきれない場合があります)

このスクリプトを使って、不正なTCPコネクションを監視したり、アクセス履歴を作成したりできそうです。
 

connectionsの実行例:http://users.tpg.com.au/adsln4yb/DTrace/connections_example.txt

 

このように、DTraceを使うと、システムのいろいろな情報をリアルタイムに収集することができます。

みなさんもこれらのスクリプトを参考にして、いろいろ試してみてください。

また、有用なツールが作成できたら、ぜひこのCommunityに公開して全世界の人に自慢してください!


参考リンク OpenSolaris DTrace community Solaris 動的トレース(DTrace)ガイド

This blog copyright 2008 by kawaiti