pcp
[Top] [All Lists]

Re: [pcp] Fetch User CPU Usage as a Percentage?

To: Lukas Berk <lberk@xxxxxxxxxx>
Subject: Re: [pcp] Fetch User CPU Usage as a Percentage?
From: Rohan Arora <rarora2012@xxxxxxxxx>
Date: Thu, 30 Jul 2015 18:56:50 +0000
Cc: Nathan Scott <nathans@xxxxxxxxxx>, pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=C01ae9bTP5Mt2A5RMkE3loPerSLSi0J8xTFopnLOnZI=; b=bPOBEPNWjDCqO/nZHy7Rb7zRe90T/Fd7+Y2NmshKjd/fWTTqpKuzIgaflm1kdmSiFS IH0tnwE50rGj0pE+yAXswcnFiD9AsJBJHnkrjyM9dAO0jEbJye0GGjZJVUHO5WEpcEp9 z6QEVkuuG+IDtRCV1oqXsaDtVqVUjOG9FnSI0FN7C+GaBUAMQq9pXh06SF3j1bQk4K8I Y3LFyA59+oXlYlCIl4uqTe4x7CgUiLlnrjdtHOX/W4KGlnYdtOcA4vipTyW7XUPK+6CN QNd9/tSVLvP4BWxxbyLLjWNghAlErcHRD3jHBOBtapAYwu9M1RGz2LAhWPzpT21LAwfM 8JSg==
In-reply-to: <CANbxzdWJPJwB0FtAnBtRe--XWKmaK4c9h5vJAhAZzF=GmUf3Hw@xxxxxxxxxxxxxx>
References: <CANbxzdXXmYefH5B1in5zYSkAT8gOieN387sNXDTvTR=9gyUNOw@xxxxxxxxxxxxxx> <706968281.687935.1438217114363.JavaMail.zimbra@xxxxxxxxxx> <CANbxzdVytisK4mkTUrK-diaFXV6qoa27HcND9r444nQ-fU_wzA@xxxxxxxxxxxxxx> <87egjp3ffv.fsf@xxxxxxxxxx> <CANbxzdXrhBZO1fOKU+31a+mpTq1JDiNuhXO=QUEkyeKypD-aZg@xxxxxxxxxxxxxx> <CANbxzdWJPJwB0FtAnBtRe--XWKmaK4c9h5vJAhAZzF=GmUf3Hw@xxxxxxxxxxxxxx>
Nevermind, sorry about that, realized I was just forgetting to get the descs with context.pmLookupDescs.

Thanks,
Rohan

On Thu, Jul 30, 2015 at 1:26 PM Rohan Arora <rarora2012@xxxxxxxxx> wrote:
So dropping the new files in seems to have worked fine. All of the .py files are from version 3.10.5. Now I am running into some trouble trying to create the Metric objects. I use the following code to create the MetricCore objects:
metrics = (
   Â"mem.physmem",
   Â"mem.util.used",
   Â"kernel.all.cpu.idle",
   Â"kernel.all.cpu.sys",
   Â"kernel.all.cpu.user"
  )

context = pmapi.pmContext(PM_CONTEXT_HOST, "127.0.0.1")

metric_ids = context.pmLookupName(metrics)

metric_cores = []
for i in range(len(metrics)):
metric_cores.append(pmcc.MetricCore(context, metrics[i], metric_ids[i]))



Now, if I try to make a Metric object using the following:
metrics = []
for core in metric_cores:
metrics.append(pmcc.Metric(core))



I get an error, because in the constructor for the Metric class, the following lines fail:
self._convType = core.desc.contents.type
self._convUnits = core.desc.contents.units


This is due to core.desc not being defined, so I get None as the result for it. Am I creating the MetricCore objects incorrectly?

Thanks,
Rohan

On Thu, Jul 30, 2015 at 10:55 AM Rohan Arora <rarora2012@xxxxxxxxx> wrote:
I am using 3.9.4 as that was what installed through "yum" but I have the source from git. I will try to see if I can just replace the older Python files for the new ones.

Thanks,
Rohan

On Thu, Jul 30, 2015 at 10:09 AM Lukas Berk <lberk@xxxxxxxxxx> wrote:
Hi,

Rohan Arora <rarora2012@xxxxxxxxx> writes:
> As far as I can tell, there is no metricConvert() function defined in
> pmcc.py. Is it available in the Python version of pmcc?

In the current upstream source it should be defined as:
src/python/pcp/pmcc.py:237:Â Â def metricConvert(self, delta):

git blame points to it being present since at least Oct 2014, so
depending on what version of PCP you're using (3.10.0+ aiui),
metricConvert() should be available.

Cheers,

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