pcp
[Top] [All Lists]

Re: [pcp] PMDAs for lm_sensors, HDD SMART monitoringâ

To: Ken McDonell <kenj@xxxxxxxxxxxxxxxx>
Subject: Re: [pcp] PMDAs for lm_sensors, HDD SMART monitoringâ
From: "David O'Shea" <dcoshea@xxxxxxxxx>
Date: Sat, 2 Jan 2016 21:37:42 +1030
Cc: pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=MAii+rYctqOztjrDeDRQslbIkZfusRyLLGCsF+Ltt1A=; b=s6GQ9OhnItZXXrP9ef4PxU3zBdHLG3DYrG65IdBiUxf3zU+9m2rcCHN78GwLTGkfig 6V5qi9adEdaHQiI7kjY7WhNik6alsEEEgw5zpWIpqSZuindf+zYanqmzgagAHY3YZmml dMiKx4OMMKJxRTsXh/eSK603unMwI06ALqplPACCw228A/a91aoFvhBiH7IssVc6WGj+ Hjw7PPW79UkHBHSZfYk4wIQXfH2P0rGKEjvjDihmSwEm61a+2SxdZqJtdsUkRy74Etiq 9XCeF2S/xxvoadpExOF1vxoOWCL4mIJ4euncUfHTiDZ1AbmTGJaQhIs9Lh8TFu7gWwPj xnVQ==
In-reply-to: <56833B81.2080605@xxxxxxxxxxxxxxxx>
References: <CAN0DjM1GGZJ2MOdDohbaf7WZ25j3g_7CxzfWxVvKH=a2pKcLAw@xxxxxxxxxxxxxx> <56833B81.2080605@xxxxxxxxxxxxxxxx>
Hi Ken,

Thanks for your response. Most of what you're saying confirmed what I found/assumed/expected/hoped, just a few comments below:

On Wed, Dec 30, 2015 at 12:33 PM, Ken McDonell <kenj@xxxxxxxxxxxxxxxx> wrote:

- In pmdasimple.python, simple_fetch_times_callback() for example
includes this code:

      Âreturn [valuep.contents.value, 1]
    Âreturn [c_api.PM_ERR_PMID, 0]

 ÂI assume the second element in the array - 0 or 1 in these examples -
corresponds to these definitions from pmda.h?

/*
 * return values for a pmdaFetchCallBack method
 */
#define PMDA_FETCH_NOVALUESÂ Â 0
#define PMDA_FETCH_STATICÂ Â 1
#define PMDA_FETCH_DYNAMICÂ Â 2Â Â /* free avp->vp after __pmStuffValue */

Correct. This is documented in pmdaFetch(3) under PMDA_INTERFACE_5 (the highest version of the interface supported by libpcp_pmda).

If so, it'd be nice if pmda.py defined those constants itself (or
possibly they could be extracted using something like SWIG but I have
never tried using that myself), as I struggled to work this out.

Looks like they are defined as I can see this code:

    pmda_dict_add(dict, "PMDA_FETCH_NOVALUES", PMDA_FETCH_NOVALUES);

but it looks like none of the Python PMDAs in the source tree are using it.

Ahh okay, I see it is in the *c*pmda module:

>>> import cpmda
>>> help(cpmda)
[...]
ÂÂÂ PMDA_FETCH_STATIC = 1
[...]

The man page isn't totally helpful here since the C and Python APIs are a bit different - the C one naturally has a single return value (PMDA_FETCH_*) and a pointer parameter that is an out (or in/out? I didn't pay that much attention) parameter, whereas Python basically has two return values (in a list), so I guess I could have figured that the return value specified in the C API is probably one of the return values in the Python API, but I wasn't all that sure.

Should I fork https://github.com/performancecopilot/pcp and file a pull request to improve the samples to refer to cpmda.PMDA_FETCH_*?
Â
- It would be nice if there was a sequence diagram (generated using e.g.
http://www.mcternan.me.uk/mscgen/ ) showing how PDUs being sent to the
PMDA get translated into various calls, and what order they are in. I
think I know how this works but I'm not totally sure yet!

OK. But "calls" in which context? ... at pmcd? at a client? at a PMDA?

I always err on the side of way too much detail in such diagrams, but in this case I'm personally interested just in what needs to happen in my PMDA. Specifically, if a client is monitoring a few of my metrics, how does that appear to the PMDA, since I want to run 'smartctl' just once. However, that is a moot point now that I'm going to change the PMDA to have a separate thread doing the polling.

Thanks!
David
<Prev in Thread] Current Thread [Next in Thread>