Dスクリプトを使うときの参考資料
ある程度DTraceの使い方がわかったら、
- Appendix A DTrace Tunable Variables
- Appendix B D Language Reference
- Appendix C Privider Arguments Reference
- Appendix D DTrace on FreeBSD
- Appendix E USDT Example
- Appendix F DTrace Error Messages
- Appendix G DTrace Cheat Sheet
この手の参考資料としては次のPDFドキュメントも参考になります。上記Appendix的な使い方ができます。
もうちょっとチュートリアル的な要素が強くなりますが、
多くのドキュメントはSolarisを前提に書いてあったりしますので、
あとは、
% pkg search -f dtrace-toolkit dtrace-toolkit-1.0_1 Name : dtrace-toolkit Version : 1.0_1 Origin : sysutils/DTraceToolkit Architecture : freebsd:11:x86:64 Prefix : /usr/local Repository : FreeBSD [pkg+http://pkg.FreeBSD.org/FreeBSD:11:amd64/quarterly] Categories : sysutils Licenses : Maintainer : skreuzer@FreeBSD.org WWW : https://github.com/opendtrace/toolkit Comment : Collection of useful scripts for DTrace Annotations : Flat size : 2.98MiB Pkg size : 323KiB Description : The DTraceToolkit is a collection of useful documented scripts developed by the DTrace community and maintained as part of Open DTrace. WWW: https://github.com/opendtrace/toolkit %
%
cat /usr/local/share/dtrace-toolkit/Cpu/cpuwalk.d
#!/usr/sbin/dtrace -s
/*
* cpuwalk.d - Measure which CPUs a process runs on.
* Written using DTrace (Solaris 10 3/05)
*
* This program is for multi-CPU servers, and can help identify if a process
* is running on multiple CPUs concurrently or not.
*
* $Id: cpuwalk.d 3 2007-08-01 10:50:08Z brendan $
*
* USAGE: cpuwalk.d [duration]
* eg,
* cpuwalk.d 10 # sample for 10 seconds
* cpuwalk.d # sample until Ctrl-C is hit
*
* FIELDS:
* value CPU id
* count Number of 1000 hz samples on this CPU
*
* COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at Docs/cddl1.txt
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* CDDL HEADER END
*
* 22-Sep-2005 Brendan Gregg Created this.
* 14-Feb-2006 " " Last update.
*/
#pragma D option quiet
#pragma D option defaultargs
inline int MAXCPUID = 1024;
dtrace:::BEGIN
{
$1 ? printf("Sampling...\n") :
printf("Sampling... Hit Ctrl-C to end.\n");
seconds = 0;
}
profile:::profile-1000hz
/pid/
{
@sample[pid, execname] = lquantize(cpu, 0, MAXCPUID, 1);
}
profile:::tick-1sec
{
seconds++;
}
profile:::tick-1sec
/seconds == $1/
{
exit(0);
}
dtrace:::END
{
printa("\n PID: %-8d CMD: %s\n%@d", @sample);
}
% sudo /usr/local/share/dtrace-toolkit/Cpu/cpuwalk.d
Sampling... Hit Ctrl-C to end.
^C
PID: 557 CMD: vmtoolsd
value ------------- Distribution ------------- count
< 0 | 0
0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
1 | 0
PID: 769 CMD: sshd
value ------------- Distribution ------------- count
< 0 | 0
0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
1 | 0
PID: 8001 CMD: dtrace
value ------------- Distribution ------------- count
< 0 | 0
0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
1 | 0
PID: 11 CMD: idle
value ------------- Distribution ------------- count
< 0 | 0
0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2999
1 | 0
%
DTraceToolkitはFreeBSD専用というわけではないのでFreeBSDでは動作しないDスクリプトも多いのですが、
勉強会
第62回 4月28日(火)19:00~FreeBSD勉強会 エンジニアのための英会話入門~なぜ英語ができないのか~講師: 後藤大地(BSDコンサルティング株式会社)
FreeBSDの情報の多くは英語で入手できます。ほかの言語と比べると日本語は翻訳されたドキュメントが豊富にありますが、
日本は義務教育の間に英語を学びますが、
参加申し込みはこちらから。
第63回 5月23日(火)19:00~FreeBSD勉強会
現在検討中です。
FreeBSD勉強会 発表者募集
FreeBSD勉強会では発表者を募集しています。FreeBSDに関して発表を行いたい場合、
