A DTrace aggregation takes the following general form:
@name[ keys ] = aggfunc( args );
In this general form, the variables are defined as follows:
The name of the aggregation, preceded by the @ character.
A comma-separated list of D expressions.
One of the DTrace aggregating functions.
A comma-separated list of arguments appropriate to the aggregating function.
Function Name |
Arguments |
Result |
---|---|---|
count |
none |
The number of times that the count function is called. |
sum |
scalar expression |
The total value of the specified expressions. |
avg |
scalar expression |
The arithmetic average of the specified expressions. |
min |
scalar expression |
The smallest value among the specified expressions. |
max |
scalar expression |
The largest value among the specified expressions. |
lquantize |
scalar expression, lower bound, upper bound, step value |
A linear frequency distribution of the values of the specified expressions that is sized by the specified range. This aggregating function increments the value in the highest bucket that is less than the specified expression. |
quantize |
scalar expression |
A power-of-two frequency distribution of the values of the specified expressions. This aggregating function increments the value in the highest power-of-two bucket that is less than the specified expression. |
This example uses the count aggregating function to count the number of write(2) system calls per process. The aggregation does not output any data until the dtrace command is terminated. The output data represents a summary of the data collected during the time that the dtrace command was active.
# cat writes.d #!/usr/sbin/dtrace -s syscall::write:entry] { @numWrites[execname] = count(); } # ./writes.d dtrace: script 'writes.d' matched 1 probe ^C dtrace 1 date 1 bash 3 grep 20 file 197 ls 201 |