pcp
[Top] [All Lists]

Re: [pcp] Help with Python API

To: Rohan Arora <rarora2012@xxxxxxxxx>
Subject: Re: [pcp] Help with Python API
From: Nathan Scott <nathans@xxxxxxxxxx>
Date: Mon, 29 Jun 2015 18:50:33 -0400 (EDT)
Cc: pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <CANbxzdX_4yDiOBqU954wjfbKOFOXnB8SJ_uiRsKEBdUk-hxF1w@xxxxxxxxxxxxxx>
References: <CANbxzdXmsRFyF_J_7c93uBuKWJHZikoRs6xmSPQC91rALtZbNA@xxxxxxxxxxxxxx> <CANbxzdUCUZcj4pF32CufxXAt452WUhJkCcjOT+XLZ+4pgcmNsg@xxxxxxxxxxxxxx> <CANbxzdXGZosHkKZXrcvJMoaPb=2YOY7_Rhw6cs2y-vp0Jhj8Vg@xxxxxxxxxxxxxx> <CANbxzdXVmBE1qRoHQQTy9VvbAt4rqppwEL-xizSUH7cKOswNzQ@xxxxxxxxxxxxxx> <CANbxzdV7Vndvczvo9OLgc8CpQ20wBK=YUD6v87ewVBa6yrTXKQ@xxxxxxxxxxxxxx> <CANbxzdXcqg=sRYa0JwETB+RHChw42uAeZE-n+bABUjV-FD9TDg@xxxxxxxxxxxxxx> <587447889.27462536.1435530714712.JavaMail.zimbra@xxxxxxxxxx> <CANbxzdX_4yDiOBqU954wjfbKOFOXnB8SJ_uiRsKEBdUk-hxF1w@xxxxxxxxxxxxxx>
Reply-to: Nathan Scott <nathans@xxxxxxxxxx>
Thread-index: 0wG9LqobV19AwQcNWlOow/zpz1yzAg==
Thread-topic: Help with Python API
Hi Rohan,

----- Original Message -----
> I'm having difficulty finding documentation on how to use pmcc and it's
> functions. Can you point me to a man page, or any other documentation?
> 
> Would the results of using pmcc be any different than using pmapi.py
> directly?

Same end result - pmcc adds 'Convenience Classes' on top of pmapi.py,
so makes for less code that you have to write.

> Right now I have it so that I am fetching metrics from an archive
> using pmFetch, and I put the values into a Python dictionary manually.

*nod*, this is the sort of thing that is done for you by pmcc.

> Would using pmcc allow me to do this much more easily/with significantly
> less code?

Yep.  The documentation leaves a bit to be desired, but there are several
good examples in the PCP git tree.

src/pcp/dmcache/pcp-dmcache.py
src/pcp/iostat/pcp-iostat.py
src/pcp/verify/pcp-verify.py
qa/src/test_pmcc.py

> I tried looking through the pmcc.py file to figure it out, but I am unsure
> about how to actually use it. Do I need to use the MetricGroupManager
> class, or do I use the MetricGroup class directly if I have a set list of
> metrics that I want to be able to retrieve data from. Also, how do make it
> use the PM_CONTEXT_ARCHIVE type instead of PM_CONTEXT_HOST? It looks like
> it defaults to host, does it know to use archive if the context used for
> creating the MetricCache had type archive?

Yep.  Usually this is all handled by the 'builder' interface, which takes
a pmOptions class (command line interface handling) and turns the standard
command line options - see PCPIntro(1) - into the correct context creation
parameters.

> Also, if I use the
> MetricGroupManager, how would I fetch again? MetricGroup has the mgFetch
> function, but I don't see how I could call it with a MetricGroupManager
> instance.

It handles all of the low level fetch logic, and calls a 'printer' method
once for each sample - that has access to all of the metrics (names, descs,
instances, values, etc), which can be looked up by name.

cheers.

--
Nathan

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