3.3.1 Basic Aggregation

To count the number of write() system calls in the system, you could use an informative string as a key and the count aggregating function and save it to file named writes.d:

syscall::write:entry
{
  @counts["write system calls"] = count();
}

The dtrace command prints aggregation results by default when the process terminates, either as the result of an explicit END action or when you press Ctrl-C. The following example shows the result of running this command, waiting a few seconds, and then pressing Ctrl-C:

# dtrace -s writes.d
dtrace: script './writes.d' matched 1 probe
^C
write system calls                               179
#