Is there a way to access an aggregation''s value in a variable or an arithmetic expression. I know that we can access its value in a printa statement by using "%@". I am trying to do the following. 1) this->load = @client_ops[self->ip]/@total_ops where @total_ops = sum(self->numops); 2) this->temp = @total_ops Thanks for your help, Piyush This message posted from opensolaris.org
Hi Piyush, Aggregations represent a specific methodology for data collection and are designed for that use. This allows to make certain optimizations around data collection that aren''t possible with stricter constraints (this is one of the key differences between DTrace and previous tracing frameworks). As a result, you can''t "read" the value of an aggregation. What are you trying to do exactly? You maybe be able to use the normalize() subroutine or associative arrays to solve your problem. Adam On Wed, Jun 07, 2006 at 03:52:27PM -0700, Piyush Shivam wrote:> Is there a way to access an aggregation''s value in a variable or an arithmetic expression. I know that we can access its value in a printa statement by using "%@". > > I am trying to do the following. > > 1) > > this->load = @client_ops[self->ip]/@total_ops > > where @total_ops = sum(self->numops); > > > 2) > > this->temp = @total_ops > > > Thanks for your help, > Piyush > > > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org-- Adam Leventhal, Solaris Kernel Development http://blogs.sun.com/ahl
Hi Adam, Thanks for your response. I am trying to do the following. Count the number of NFS operations by a client on an NFS server (@clients[self->ip] = sum(self->numops) Collect total number of NFS operations by all clients (@total= sum(self->numops) Find the load of a given client (IP address) on the NFS server by dividing the two. @clients[self->ip]/@total I could just use a simple scalar variable/associative array for the totals but would that be threadsafe? Thanks, Piyush This message posted from opensolaris.org
As Adam said, seems that the dtrace normalize() function can help you. -r Piyush Shivam writes: > Hi Adam, > > Thanks for your response. I am trying to do the following. > > Count the number of NFS operations by a client on an NFS server (@clients[self->ip] = sum(self->numops) > Collect total number of NFS operations by all clients (@total= sum(self->numops) > > Find the load of a given client (IP address) on the NFS server by dividing the two. @clients[self->ip]/@total > > I could just use a simple scalar variable/associative array for the totals but would that be threadsafe? > > Thanks, > Piyush > > > This message posted from opensolaris.org > _______________________________________________ > dtrace-discuss mailing list > dtrace-discuss at opensolaris.org
Here is a use case from a customer, I did not know how to solve. The load is a threaded request/response. We''d like to construct a script that would hit a probe (presumably tick) as soon as any request is not being handled within a given timeout. So if we had a MIN() function that apply to associative arrays: request:entry{a[curthread]=timestamp}; request:return{a[curthread]=<INFINITY>}; tick-1s/timestamp > (MIN(a) + timeout)/ {bingo!}; /* oldest pending request is older than we''d like*/ In the end, what we did was to have a single ''observed'' request at a time. We pick one, if it''s not answered within the timeout, we hit our probe, and if it is, we then pick a new one etc...and that was fine. But the general situation, I don''t know how to handle. -r
Hi Piyush, The normalize() action _almost_ does what you need, but not quite. normalize() takes an aggregation and a scalar, but you can''t use a scalar because you could lose data. I suggest you a) file an RFE through opensolaris.org that normalize be allowed to take a scalar _or_ a scalar aggregation unit (we may or may not be able to implement this, and b) for the time being post process the DTrace output in a perl script (or whatever) to get what you need. Adam On Thu, Jun 08, 2006 at 02:43:26PM -0600, Piyush Shivam wrote:> Hi Adam, > > Thanks for your response. I am trying to do the following. > > Count the number of NFS operations by a client on an NFS server > (@clients[self->ip] = sum(self->numops) > Collect total number of NFS operations by all clients (@total= > sum(self->numops) > > Find the load of a given client (IP address) on the NFS server by > dividing the two. @clients[self->ip]/@total > > I could just use a simple scalar variable/associative array for the > totals but would that be threadsafe? > > Thanks, > Piyush > > > > > > Adam Leventhal wrote On 06/08/06 14:31,: > > >Hi Piyush, > > > >Aggregations represent a specific methodology for data collection and are > >designed for that use. This allows to make certain optimizations around > >data > >collection that aren''t possible with stricter constraints (this is one of > >the key differences between DTrace and previous tracing frameworks). As a > >result, you can''t "read" the value of an aggregation. > > > >What are you trying to do exactly? You maybe be able to use the normalize() > >subroutine or associative arrays to solve your problem. > > > >Adam > > > >On Wed, Jun 07, 2006 at 03:52:27PM -0700, Piyush Shivam wrote: > > > > > >>Is there a way to access an aggregation''s value in a variable or an > >>arithmetic expression. I know that we can access its value in a printa > >>statement by using "%@". > >> > >>I am trying to do the following. > >> > >>1) > >> > >>this->load = @client_ops[self->ip]/@total_ops > >> > >>where @total_ops = sum(self->numops); > >> > >> > >>2) > >> > >>this->temp = @total_ops > >> > >> > >>Thanks for your help, > >>Piyush > >> > >> > >>This message posted from opensolaris.org > >>_______________________________________________ > >>dtrace-discuss mailing list > >>dtrace-discuss at opensolaris.org > >> > >> > > > > > >-- Adam Leventhal, Solaris Kernel Development http://blogs.sun.com/ahl
I''m not sure this does exactly what you need, but what if you used aggregations to get something like this: request:entry { self->ts = timestamp; @[curthread] = sum(self->ts); } request:return /self->ts/ { @[curthread] = sum(-self->ts); self->ts = 0; } tick-1s { printf("%u", timestamp); printa(@); } Then you could process the output appropriately. Adam On Fri, Jun 09, 2006 at 10:47:10AM +0200, Roch wrote:> > Here is a use case from a customer, I did not know how to > solve. The load is a threaded request/response. We''d like to > construct a script that would hit a probe (presumably tick) > as soon as any request is not being handled within a given > timeout. So if we had a MIN() function that apply to > associative arrays: > > request:entry{a[curthread]=timestamp}; > request:return{a[curthread]=<INFINITY>}; > tick-1s/timestamp > (MIN(a) + timeout)/ {bingo!}; /* oldest pending request is older than we''d like*/ > > > > > In the end, what we did was to have a single ''observed'' > request at a time. We pick one, if it''s not answered within > the timeout, we hit our probe, and if it is, we then pick a new > one etc...and that was fine. > > But the general situation, I don''t know how to handle. > > -r-- Adam Leventhal, Solaris Kernel Development http://blogs.sun.com/ahl
What we wanted is to generate a dump as soon as _any_ request was pending for N sec. What is possible is pick a request and generate dump if the _selected request_ take more than N sec; otherwise pick another request etc... We manage to make progress with that so that''s cool. I guess that this raises the issue of how much work is reasonable in probe context. I don''t know how one could address the preceived need to sometimes do a lot and the need for DTrace to not perturb a system too much. -r Adam Leventhal writes: > I''m not sure this does exactly what you need, but what if you used aggregations > to get something like this: > > request:entry > { > self->ts = timestamp; > @[curthread] = sum(self->ts); > } > > request:return > /self->ts/ > { > @[curthread] = sum(-self->ts); > self->ts = 0; > } > > tick-1s > { > printf("%u", timestamp); > printa(@); > } > > Then you could process the output appropriately. > > Adam > > On Fri, Jun 09, 2006 at 10:47:10AM +0200, Roch wrote: > > > > Here is a use case from a customer, I did not know how to > > solve. The load is a threaded request/response. We''d like to > > construct a script that would hit a probe (presumably tick) > > as soon as any request is not being handled within a given > > timeout. So if we had a MIN() function that apply to > > associative arrays: > > > > request:entry{a[curthread]=timestamp}; > > request:return{a[curthread]=<INFINITY>}; > > tick-1s/timestamp > (MIN(a) + timeout)/ {bingo!}; /* oldest pending request is older than we''d like*/ > > > > > > > > > > In the end, what we did was to have a single ''observed'' > > request at a time. We pick one, if it''s not answered within > > the timeout, we hit our probe, and if it is, we then pick a new > > one etc...and that was fine. > > > > But the general situation, I don''t know how to handle. > > > > -r > > -- > Adam Leventhal, Solaris Kernel Development http://blogs.sun.com/ahl