This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Dealing with empty aggregates?


Hi Folks,

I have a script that uses the aggregation operator to accumulate a bunch of
samples in probes that fire when stuff happens. Stuff may or may not be
happening on the system at any given moment.

These are then extracted and reported by a timer probe that runs once per second.

If it happens that no "stuff" happened before the first timer I hit the
following error:

ERROR: empty aggregate near identifier '@sum' at <input>:1:42

for e.g.:

stap -e 'global foo; probe begin { printf("%d\n", @sum(foo)); } probe end {foo
<<< 1}'
ERROR: empty aggregate near identifier '@sum' at <input>:1:42

Right now I handle this with script like:

global have_stuff
probe kernel.stuff {
    stuff <<< nonsense
    have_stuff = 1
}

probe timer.ms(1000) {
    if (have_stuff) {
        printf("Sum of stuff: %d\n", @sum(stuff))
    } else {
        print("Sum of stuff: n/a\n")
    }
}

I wondered if there was a more elegant way? I have a few of these in the script
I'm working on and the special casing/flags are looking a bit kludgey.

Sorry if there's something obvious I missed!

Regards,
Bryn.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]