1 Star2 Stars3 Stars4 Stars5 Stars (还没有评分)
Loading...

如何执行DTrace脚本

以下面脚本(hello.d)为例,讲述执行DTrace脚本的方法:

BEGIN
{
  /* This is a C-style comment */
  trace("hello, world");
  exit(0);
}

(1)在命令行运行dtrace -s hello.d命令:

# dtrace -s hello.d
dtrace: script 'hello.d' matched 1 probe
CPU     ID                    FUNCTION:NAME
  0      1                           :BEGIN   hello, world

(2)在脚本第一行加上“#!/usr/sbin/dtrace -s”:

#!/usr/sbin/dtrace -s

BEGIN
{
  /* This is a C-style comment */
  trace("hello, world");
  exit(0);
}

在命令行直接执行hello.d即可:

# ./hello.d
dtrace: script './hello.d' matched 1 probe
CPU     ID                    FUNCTION:NAME
  0      1                           :BEGIN   hello, world

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.