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 17:27:06 +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=q6p+GeFz2ZPk9jogTB9Ewarr/Jp9aj+M268yv+C+NGw=; b=JIp6gq9ISPkk54fcB9t2BtvZ6FsgAJvqXxIrCBPjhLdDj6Rcmg9vWHzUnsspJqgXft /eFqr0zU/AjsjAK46g76o+qkernyZuwFGt0lhQcjX9FoBWfVah+PJuJcPjus9MeGt1hu WfR57OBmFkmvLULOvmceMQi4JtSDSLu7dgOxPzkT8chk/Zrt7Bpqw/Y4ECai0rpDO4Sf 4fDsUIpgRdtGGssvf1QTtYPAlRy/75lFOJqfeA/2xzstPxQVxSh9f+AqYZJHxtacfOxF O7t+lpRbbheWGrtsUMAo+8xQXjbCknAQsMduTLcPtVyIWnzU4BYVsrHBzd03gQlP2dCd 35cQ==
In-reply-to: <CANbxzdXrhBZO1fOKU+31a+mpTq1JDiNuhXO=QUEkyeKypD-aZg@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>
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>