pcp
[Top] [All Lists]

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

To: Rohan Arora <rarora2012@xxxxxxxxx>
Subject: Re: [pcp] Fetch User CPU Usage as a Percentage?
From: Nathan Scott <nathans@xxxxxxxxxx>
Date: Wed, 29 Jul 2015 20:45:14 -0400 (EDT)
Cc: pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <CANbxzdXXmYefH5B1in5zYSkAT8gOieN387sNXDTvTR=9gyUNOw@xxxxxxxxxxxxxx>
References: <CANbxzdXXmYefH5B1in5zYSkAT8gOieN387sNXDTvTR=9gyUNOw@xxxxxxxxxxxxxx>
Reply-to: Nathan Scott <nathans@xxxxxxxxxx>
Thread-index: CCelNtcaL9cqEj0aYuPPYuoPDeKkEQ==
Thread-topic: Fetch User CPU Usage as a Percentage?
Hi Rohan,

----- Original Message -----
> Is there a way to fetch the User CPU Usage as a Percentage directly, having
> PCP take more than one sample, and doing the rate-conversion itself using
> the Python API? Currently what I am doing is running pmFetch twice for the
> "kernel.all.cpu.user". I then calculate the percentage using (val2 - val1) /
> (timestamp2 - timestamp1) * 100. Is there a way that I can just have PCP do
> this automatically? This would also be really nice for working with an
> archive, as I wouldn't have to do this for each and every result that I get.
> 
> If there is not a way to get the percentage directly, is there a better way
> of going about doing this?

The pcp.pmcc module will do rate conversion for you - see the Metric class,
metricConvert() method.  You'll still need to do the percentage conversion,
but that's the easy bit.

cheers.

--
Nathan

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