pcp
[Top] [All Lists]

Re: [pcp] python pmapi interface

To: Stan Cox <scox@xxxxxxxxxx>, "Frank Ch. Eigler" <fche@xxxxxxxxxx>
Subject: Re: [pcp] python pmapi interface
From: Nathan Scott <nathans@xxxxxxxxxx>
Date: Thu, 05 Apr 2012 20:11:18 +1000
Cc: pcp@xxxxxxxxxxx
In-reply-to: <y0m62dfla0c.fsf@xxxxxxxx>
References: <4F7C76E2.2010507@xxxxxxxxxx> <y0m62dfla0c.fsf@xxxxxxxx>
Sender: ndsco1@xxxxxxxxxxxxxxxxxx
Hi guys,

On 5 April 2012 02:47, Frank Ch. Eigler <fche@xxxxxxxxxx> wrote:

Hi, Stan -


scox wrote:
> [...]
> pm_code = pcp.pmNewContext()
> if (pm_code < 0):
>     print "PCP is not running"
>     exit

Some encoding of the error would be nice.  Is the context value hidden
inside the pm_code object, or inside the pcp library?  If the latter,

Its in the result returned from pmNewContext (for the C API, that is - and
pmErrStr converts it to something more human readable).

Also, not clear how the args to pmNewContext (to enter archive mode, for
example, or a remote host) can be passed in?  This seems to assume
live-host mode only at the moment.


> cpu_name = pcp.pmLookupName("hinv.ncpu")
> cpu_desc = pcp.pmLookupDesc(cpu_name)
> cpu_result = pcp.pmFetch(cpu_name)
> ncpu = pcp.pmExtractValue(cpu_result, cpu_desc, cpu_name[0], 0, "PM_TYPE_U32")

I wonder if it should be necessary to do all that
LookupDesc/Fetch/ExtractValue as separate steps.  Could these be
combined into a single

ncpu = pcp.pmFetch("hinv.ncpu" /* or array of same */,
                  [0] /* instances */,
                  PM_TYPE_U32 /* requested format */)

and have pmFetch internally do the pmLookupDesc / pmFetch / pmExtractValue?
(Or else have another combined function that does the same?)


I don't know enough about python to know if that kind of overloading is supported,
I'd punt that it is ... but, you probably would want both forms I think (exposing the
C API pmid fetch still as well).
 
cheers.

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