hi,
On Mon, Oct 01, 2001 at 12:36:15AM -0500, Madhu Sudhan R Tera wrote:
> 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
Have a look at the code in /var/pcp/pmdas/simple/simple.c -
that does exactly this sort of thing and will show you what
you need to do here.
> ...
> { PMDA_PMID(0,0), PM_TYPE_STRING, PM_INDOM_NULL,
You will need to use something other than PM_INDOM_NULL here
(for all of your metrics).
These metrics also look like they should be of type PM_TYPE_U32
- refer to the pmLookupDesc(3) man page for a description of the
different types (better than pamapi.h).
> I have one more question. HOW MANY TIMES IS netstat_fetchCallBack method
The fetch callback is called once per metric instance - there is
also a fetch routine [as opposed to a fetch _callback routine ;)]
which gets called once per fetch request from pmcd. The way most
agents work is to refresh their internal state (all the values)
in the fetch request, and then pick the values for each individual
instance out during the fetchCallback.
Again, the "simple" PMDA is a working example of this and is just the
sort of code you need, I think - its a good reference implementation
of a PMDA.
cheers.
--
Nathan
|