[pcp] python pmapi interface

Nathan Scott nathans at debian.org
Thu Apr 5 05:11:18 CDT 2012


Hi guys,

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], 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://oss.sgi.com/pipermail/pcp/attachments/20120405/dd06c8ae/attachment.htm>


More information about the pcp mailing list