Hi Rohan,
----- Original Message -----
> Hi,
> I was working on a project where I wanted to be able to collect information
> from pmcd on remote computers using Python. I have tried looking through the
> *.py files and looked at the help on each part of the pcp module, but I am
> unable to really wrap my head around how to go about doing this. I saw that
> in the pcpgui module there was a record host function, which seemed like it
> might be what I wanted, but I am confused about how to use it and how to
> pull the metrics that I want, where it will record things, etc.
The python module uses the underlying C code from libpcp_gui, and some of the
documentation there is relevant (I recently needed to use this code too - so,
happy to help if you need more info) - see pmRecordSetup(3) man page. The
src/pcp/collectl/pcp-collectl.py tool uses these interfaces, for reference.
> Also, would
> I want to be using pmwebd on the central computer that I am running the
> Python script on, or would this not be necessary?
Python code can talk directly to pmcd using the native PCP protocol - I would
definitely advise that. If you use pmcd directly there is no need for pmwebd.
> Would you be able to point me in the right direction? Also, are there any
> more examples similar to the example given by Python's help(pmapi) command?
There's quite a few examples in the pcp git tree now, hopefully one gives a
starting point close to what you need. Refer to:
- src/pcp/iostat/pcp-iostat.py
- src/pcp/numastat/pcp-numastat.py
- src/pcp/uptime/pcp-uptime.py
- src/pcp/free/pcp-free.py
- src/pcp/dmcache/pcp-dmcache.py
- src/pcp/collectl/pcp-collectl.py
> I found it to be very useful and feel like I could start to wrap my head
> around things more if there were more examples that I could find.
Let me know if none of the above suit. I'd recommend using the pcp.pmcc py
module too, it simplifies quite a few things for simple tools (e.g. iostat,
above).
cheers.
--
Nathan
|