Dealing with empty aggregates?

Jim Keniston jkenisto@linux.vnet.ibm.com
Thu May 19 22:05:00 GMT 2011


On Thu, 2011-05-19 at 15:46 +0100, Bryn M. Reeves wrote:
> On 05/19/2011 03:36 PM, Frank Ch. Eigler wrote:
> > The canonical construct doesn't require a hand-maintained flag:
> > 
> > probe timer.ms(1000) {
> >     if (@count(stuff))
> >        printf("Sum of stuff: %d\n", @sum(stuff))
> >     else
> >        printf("No stuff.")
> > }
> 
> Exactly what I was looking for, thanks! A count is not especially useful for the
> stuff I'm looking at (nfsd operations fwiw) and it didn't occur to me to gate on
> count (obvious really since it's the only one defined on an empty aggregate.. duh!).
> 
> Cheers,
> Bryn.

Another way: If all you're interested in is the sum, then you can
initialize it with
	stuff <<< 0
and then it'll never be empty.

Jim



More information about the Systemtap mailing list