pcp
[Top] [All Lists]

Re: writing a PMDA: multiple instances to a metric

To: Madhu Sudhan R Tera <mst9696@xxxxxxxxxxx>
Subject: Re: writing a PMDA: multiple instances to a metric
From: Nathan Scott <nathans@xxxxxxx>
Date: Thu, 4 Oct 2001 14:53:48 +1100
Cc: pcp@xxxxxxxxxxx
In-reply-to: <Pine.GSO.4.21.0110032229430.20931-100000@chara.cis.ksu.edu>; from mst9696@cis.ksu.edu on Wed, Oct 03, 2001 at 10:38:58PM -0500
References: <20011004091558.K472533@wobbly.melbourne.sgi.com> <Pine.GSO.4.21.0110032229430.20931-100000@chara.cis.ksu.edu>
Sender: owner-pcp@xxxxxxxxxxx
User-agent: Mutt/1.2.5i
hi,

On Wed, Oct 03, 2001 at 10:38:58PM -0500, Madhu Sudhan R Tera wrote:
> Hello Mr Nathan!
> I appreciate your quick response.

No problem.

> Do you mind if I ask one more question??

Sure, though you can probably guess what my response will
be at this stage... ;-)

> 
> My question, in simple.c the number of instances is already known
> at the beginning of the program.for example simple.color has 
> three and are known already.

Have a look at the simple.now metrics - these have a "variable"
instance domain, just like what you want.  This instance domain
is calculated at run time, based on the contents of a file - if
you change the file (even which the PMDA is running), the next
fetch will show the new instance domain.

Here's a little example that shows what I'm talking about:

13:48 nathans@troppo /var/pcp/pmdas/simple 16> cat simple.conf 
sec,min,hour
13:48 nathans@troppo /var/pcp/pmdas/simple 17> pminfo -f simple.now

simple.now
    inst [1 or "sec"] value 31
    inst [60 or "min"] value 48
    inst [3600 or "hour"] value 13
13:48 nathans@troppo /var/pcp/pmdas/simple 18> sudo echo min > simple.conf
simple.conf: Permission denied.
13:48 nathans@troppo /var/pcp/pmdas/simple 19> sudo "echo min > simple.conf"
13:48 nathans@troppo /var/pcp/pmdas/simple 20> pminfo -f simple.now

simple.now
    inst [60 or "min"] value 49
13:49 nathans@troppo /var/pcp/pmdas/simple 21> pminfo -Tt simple.now

simple.now [Time of day with a configurable instance domain]
Help:
The value reflects the current time of day through a dynamically
reconfigurable instance domain.  On each metric value fetch request,
the agent checks to see whether the configuration file in
/var/pcp/pmdas/simple/simple.conf has been modified - if it has then
the file is re-parsed and the instance domain for this metric is again
constructed according to its contents.

This configuration file contains a single line of comma-separated time
tokens from this set:
  "sec"  (seconds after the minute),
  "min"  (minutes after the hour),
  "hour" (hour since midnight).

An example configuration file could be:  sec,min,hour
and in this case the simple.now metric would export values
for the three instances "sec", "min" and "hour" corresponding
respectively to the components seconds, minutes and hours of the
current time of day.

The instance domain reflects each token present in the file, and the
values reflect the time at which the PMDA processes the fetch.


> But in our case, the number of instances that pid or saddr metrics
> have is the number of nodes in the linked list( each node is a structure
> contaninig pid, saddr,daddr,sport,dport,and bandwidth).And this
> list is generated in a method which you asked us to call in fetch routine,
> in your previous mail.So i do not know before hand how many instances my
> metric has.

Yes, that sounds exactly like the simple.now metric.

> Is my pmda design wrong??

No, not wrong at all - that design is fine.  There are many PMDAs
which do exactly what you plan on doing.

cheers.

-- 
Nathan

<Prev in Thread] Current Thread [Next in Thread>