2.7.1 Example: Counting the Number of write() System Calls Invoked by Processes

In the following example, the command counts the number of write() system calls that are invoked by processes, until you type Ctrl-C.

# dtrace -n 'syscall::write:entry { @["write() calls"] = count(); }'
dtrace: description 'syscall:::' matched 1 probe
^C

  write() calls                                              9
Note

Rather than create a separate D script for this simple example, the probe and the action is specified on the dtrace command line.

DTrace prints the result of the aggregation automatically. Alternatively, you can use the printa() function to format the result of the aggregation.