[pcp] python pmapi interface
nathans at debian.org
Thu Apr 5 05:11:18 CDT 2012
On 5 April 2012 02:47, Frank Ch. Eigler <fche at redhat.com> 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,
> 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 */,
>  /* 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
I'd punt that it is ... but, you probably would want both forms I think
C API pmid fetch still as well).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the pcp