Hey Ryan,
There''s no way to sum all values in an aggregation, instead I suggest
you
create another aggregation that holds the total:
@values[key] = sum(self->x);
@total = sum(self->x);
Then you can printa() the results:
printa("%s %@u\n", @values);
printf("total: ");
printa("%@u\n", @total);
There are, of course, numerous ways to achieve the same result, but something
like that should work.
Adam
On Sat, Dec 10, 2005 at 12:17:30PM -0500, Matty wrote:>
> Howdy,
>
> Is there by any chance a way to sum() all of the values in an aggregation?
> I can print the individual aggregations, but would like a way to print a
> Total after the results are printed:
>
> printf("%20s %20s\n","Column1","Column2");
> printa("%20s %@d\n", at foo);
>
> /* Is something like the following possible? */
> total = sum(@foo);
> printf("%20s %d\n","Total",total);
>
> I am currently using a self->total_count variable to control the total,
> but that gets incremented over and over and over and over again. If I can
> sum() the aggregation values once, that would be swell!
>
> Thanks for any insight,
> - Ryan
> --
> UNIX Administrator
> http://daemons.net/~matty
> _______________________________________________
> dtrace-discuss mailing list
> dtrace-discuss at opensolaris.org
--
Adam Leventhal, Solaris Kernel Development http://blogs.sun.com/ahl