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 16:36:49 -0400
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:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=0Ld2b+Ry3zUHeIsS0jHsZrZ+FU/kYlwO9WbMqVSqVRA=; b=XweMU0CtIJ5spA7ufg6zdKEq3DCxa8AuhDvEd5ibHYEbKRur2kzH5Yfk+YhsXImMWf eQFhSuY39jmoyxSxGNIFDvazvn57njwXZSKqS5SVtIdUhslDC6MzagoYNohrbg/8aSay Vtw2PB0KnJNR30VCRsTUyHLEDLNsMvG/UhZ2Q22zIZ/Yo0cbIe8b4REF67X7vQGDrS2y lxNIVlzyXqrS713jvo/KwWdqyUEzrIwCVIEyxqQwHfOBlpVXeTGiu1IFJGPEJiQz/Js2 miKOlJYmDt4Kvk+oFWRu7zxgaN6VnJEYqX6x81OvxXEdR/R4xVkjGY7VrcebdrX3rACJ 929g==
In-reply-to: <CANbxzdUaNPg6NV28OdAj+iOUNPBSb3mmvjOdUgrE8KFRCj8rqQ@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> <CANbxzdUaNPg6NV28OdAj+iOUNPBSb3mmvjOdUgrE8KFRCj8rqQ@xxxxxxxxxxxxxx>
Now I am running into an issue in the metricPrint() function in the Metric class, which is defined as follows:
def metricPrint(self):
    print self.ctx.pmIDStr(self.pmid), self.name
    indomstr = self.ctx.pmInDomStr(self.desc.indom)
    print "  ", "indom:", indomstr
    instD = self.ctx.mcGetInstD(self.desc.indom)
    for inst, name, val in self.netValues:
      print "  ", name, val

Calling metric.metricPrint() results in the following error:
.../pmcc.py", line 158, in metricPrint
  indomstr = self.ctx.pmInDomStr(self.desc.indom)
AttributeError: 'LP_pmDesc' object has no attribute 'indom'


If I change the line to self.desc.contents.indom I get the error:
pmapi.py", line 450, in get_indom
  value.pval = pmdesc
TypeError: expected LP_pmDesc instance, got longÂ


If I change the line to self.desc, the function at least gets past that line. However, when I do get past that line, the function then fails with the following error, about which I am not sure what to do:
... in metricPrint
  instD = self.ctx.mcGetInstD(self.desc.indom)
AttributeError: 'pmContext' object has no attribute 'mcGetInstD'


I see that mcGetInstD() is defined under the MetricCache class, but I don't really know how that helps to be honest. I'm lost with where to go from here.

Thanks,
Rohan


On Thu, Jul 30, 2015 at 2:56 PM Rohan Arora <rarora2012@xxxxxxxxx> wrote:
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>