Nik Clayton
2006-Aug-06 17:32 UTC
[dtrace-discuss] Printing aggregations, multiple values per line?
Is it possible, when printing aggregations, to get multiple values per
line, or somehow link different aggregations that use the same keys to
extract the values?
An example might explain better. I''m using DTrace to instrument a
function in an application. When a particular probe is hit I start
counting all the system calls that the app makes, the total time for
these system calls, and the average time, in three aggregations.
I stop doing this when a second probe is hit.
The D looks something like this (and is, I think, fairly normal for this
sort of thing).
sendmail*:::queue-createentry-start
{ self->trace = 1; }
sendmail*:::queue-createentry-end
/self->trace/
{ self->trace = 0; }
syscall:::entry
/self->trace/
{
self->start = timestamp;
}
syscall:::return
/self->trace/
{
this->time = timestamp - self->start;
@func_count[probefunc] = count();
@func_time[probefunc] = sum(this->time);
@func_avgtime[probefunc] = avg(this->time);
}
END
{
printf("%20s\t%20s\n", "SYSCALL", "COUNT");
printa("%20s\t%@20d\n", @func_count);
printf("\n");
printf("%20s\t%20s\n", "SYSCALL", "ELAPSED
(ns)");
printa("%20s\t%@20d\n", @func_time);
printf("\n");
printf("%20s\t%20s\n", "SYSCALL", "AVERAGE
(ns)");
printa("%20s\t%@20d\n", @func_avgtime);
}
This gives me some reasonably nicely formatted tables.
SYSCALL COUNT
brk 120
close 30000
...
SYSCALL ELAPSED (ns)
brk 868871
close 62427883
...
SYSCALL AVERAGE (ns)
fxstat 1040
fcntl 1498
...
That''s great if I want to review the data on screen, not so great if I
want to import it into a spreadsheet, or do any other automated munging
with it -- I need to construct an awk or Perl pipeline to munge the
format in to something a little more regular. That''s not a horrendous
task, but it''s a minor annoyance.
I''d like to be able to produce CSV, or thereabouts. So it would look
something like this:
SYSCALL,COUNT,ELAPSED,AVERAGE
brk,120,868871,7240
close,30000,137680912,4589
...
Since the three aggregations all have the same key (the syscall name)
I''m hoping there''s some way to ''link'' them
to produce this sort of output.
N
Bryan Cantrill
2006-Aug-07 04:12 UTC
[dtrace-discuss] Printing aggregations, multiple values per line?
Hey Nik, On Sun, Aug 06, 2006 at 06:32:06PM +0100, Nik Clayton wrote:> Is it possible, when printing aggregations, to get multiple values per > line, or somehow link different aggregations that use the same keys to > extract the values?Yes, it is -- but the work was done after we wrote the doc, I''m afraid, so the documentation is a little...informal. In particular, details are here: http://mail.opensolaris.org/pipermail/dtrace-discuss/2005-November/000602.html Sorry to have that be in such an odd-ball place. Maybe someone could update the FAQ when they get the chance? http://www.genunix.org/wiki/index.php/DTrace_FAQ - Bryan -------------------------------------------------------------------------- Bryan Cantrill, Solaris Kernel Development. http://blogs.sun.com/bmc
Nik Clayton
2006-Aug-07 07:56 UTC
[dtrace-discuss] Printing aggregations, multiple values per line?
Bryan, Bryan Cantrill wrote:> On Sun, Aug 06, 2006 at 06:32:06PM +0100, Nik Clayton wrote: >> Is it possible, when printing aggregations, to get multiple values per >> line, or somehow link different aggregations that use the same keys to >> extract the values? > > Yes, it is -- but the work was done after we wrote the doc, I''m afraid, > so the documentation is a little...informal. In particular, details are > here: > > http://mail.opensolaris.org/pipermail/dtrace-discuss/2005-November/000602.html > > Sorry to have that be in such an odd-ball place.Ah, perfect. In particular, the bit that I was missing was that printa() could take multiple aggregations as arguments. Is the DTrace Guide (http://docs.sun.com/app/docs/doc/817-6223) in a repository anywhere public? It strikes me as the document to which patches should be applied. N