pcp
[Top] [All Lists]

writing a PMDA: multiple instances to a metric

To: pcp@xxxxxxxxxxx
Subject: writing a PMDA: multiple instances to a metric
From: Madhu Sudhan R Tera <mst9696@xxxxxxxxxxx>
Date: Mon, 1 Oct 2001 00:36:15 -0500 (CDT)
Sender: owner-pcp@xxxxxxxxxxx
Hello all!
I have problem in writing a pmda.
I am writing a pmda called netstat. There are five metrics in it:
pid, sport, saddr, dport,bandwidth (indicating the network bandwidth used
by the corresponding connection).
All these metrics have multiple instances (same number of instances for all).
I have a method which evaluates all the connections and generates the
corresponding values and stores them in a list.Each node in the list
is a structure containing pid, sport, saddr, dport,bandwidth.
Now I am calling this method in netstat_fetchCallBack method.

In netstat_fetchCallBack I check for each metric as follows:

if (idp->cluster == 0) {
   if (idp->item == 0) // netstat.pid
   {
        traverse the above generated list and assign  pid in each list  node 
        as an instance of my pid metric
        (
         atom->cp = val  is i suppose can be done if my pid metric has
         only one instance.I DONT KNOW HOW TO DO IT WHEN IT HAS MULTIPLE
         INSTANCES
        )       
   } 
  else if (idp->item == 1) // netstat.sport
   {    
        traverse and assign;
   }    
   .... //similarly for other metrics.
        ALL THE METRICS ARE OF TYPE PM_TYPE_STRING AND HAVE MULTIPLE
        INSTANCES.
}


my pmdaMetric structure is initialized in the beginning as follows:

static pmdaMetric metrictab[] = {
/* netstat */
    { NULL,
      { PMDA_PMID(0,0), PM_TYPE_STRING, PM_INDOM_NULL,
PM_SEM_DISCRETE,//see pamapi.h for PM_SEM_DISCRETE
        PMDA_PMUNITS(0,0,0,0,0,0) }, },
    { NULL,
      { PMDA_PMID(0,1), PM_TYPE_STRING, PM_INDOM_NULL,
PM_SEM_DISCRETE,//see pamapi.h for PM_SEM_DISCRETE
        PMDA_PMUNITS(0,0,0,0,0,0) }, },
    { NULL, 
      { PMDA_PMID(0,2), PM_TYPE_STRING, PM_INDOM_NULL,
PM_SEM_DISCRETE,//see pamapi.h for PM_SEM_DISCRETE
        PMDA_PMUNITS(0,0,0,0,0,0) }, },
    { NULL,
      { PMDA_PMID(0,3), PM_TYPE_STRING, PM_INDOM_NULL,
PM_SEM_DISCRETE,//see pamapi.h for PM_SEM_DISCRETE
        PMDA_PMUNITS(0,0,0,0,0,0) }, },
    { NULL,
      { PMDA_PMID(0,4), PM_TYPE_STRING, PM_INDOM_NULL,
PM_SEM_DISCRETE,//see pamapi.h for PM_SEM_DISCRETE
        PMDA_PMUNITS(0,0,0,0,0,0) }, }
  
};

HOW can i assign values to a metric that has multiple instances??

I have one more question. HOW MANY TIMES IS netstat_fetchCallBack method
is invoked.Is it true that it is called as many times as there are metrics
(in my case 5 times, as i have 5 metrics pid, sport, saddr, dport,bandwidth)


Thank you,
With regards,           
MadhuSudhan Reddy Tera
              
 --------------------------------------------------
|Department of Computing and Information Sciences, |          
|Kansas State University,                          |
|Manhattan, KS 66502.                              |
|ph no:785-537-3276                                |
 --------------------------------------------------


<Prev in Thread] Current Thread [Next in Thread>
  • writing a PMDA: multiple instances to a metric, Madhu Sudhan R Tera <=