G'day Frank.
On 20/11/14 04:18, Frank Ch. Eigler wrote:
> ...
Fair enough observation. My only defence is that for about 8 years there was
no justification for dynamic metrics as all the PMDAs we needed had predefined
sets of possible metrics. Dynamic metrics were added quite late in the game,
when it seemed like I could kill 2 birds with almost one stone, giving us
derived metrics (long realized as useful) and dynamic metrics (believed at the
time to be in the nice to have bucket).
It is not surprising that the libpcp_pmda design (first written in Cuneiform)
did not accommodate all the nuances of dynamic metrics that have become more
important than derived metrics ... 8^)>
>
> I started prototyping a change to pmdaFetch() (patch below) to fall
> back to a call into the pmda desc callback function pointer, but
> unfortunately pmdaFetch() is not given enough parameters to find it:
> only a pmdaExt*, from which it appears impossible to find the
> associated pmdaInterface*.
>
> What shall we do about this? ...
You could try the patch below ... the e_ext field of pmdaExt is already a
pointer to a private helper structure that holds the pmda_interface (version)
number that is needed for similar situations ... extending this to also have a
back pointer seems safe for everyone.
kenj@bozo:~/src/pcp/src/libpcp_pmda/src$ cat /tmp/patch.pmdainterface
diff --git a/src/libpcp_pmda/src/libdefs.h b/src/libpcp_pmda/src/libdefs.h
index 1d8b1c6..35554c2 100644
--- a/src/libpcp_pmda/src/libdefs.h
+++ b/src/libpcp_pmda/src/libdefs.h
@@ -27,6 +27,7 @@
* when multiple DSO PMDAs are in use
*/
typedef struct {
+ pmdaInterface *dispatch; /* back pointer to our pmdaInterface */
int pmda_interface;
pmResult *res; /* high-water allocation for */
int maxnpmids; /* pmResult for each PMDA */
diff --git a/src/libpcp_pmda/src/open.c b/src/libpcp_pmda/src/open.c
index 340f363..ab554d8 100644
--- a/src/libpcp_pmda/src/open.c
+++ b/src/libpcp_pmda/src/open.c
@@ -920,6 +920,7 @@ __pmdaSetup(pmdaInterface *dispatch, int version, char
*name)
dispatch->status = PM_ERR_GENERIC;
return;
}
+ extp->dispatch = dispatch;
extp->pmda_interface = version;
pmda->e_ext = (void *)extp;
|