pcp
[Top] [All Lists]

Re: [pcp] Confusion about metricConvert() value for kernel.all.cpu.user

To: Rohan Arora <rarora2012@xxxxxxxxx>
Subject: Re: [pcp] Confusion about metricConvert() value for kernel.all.cpu.user
From: Lukas Berk <lberk@xxxxxxxxxx>
Date: Thu, 06 Aug 2015 16:09:16 -0400
Cc: "pcp\@oss.sgi.com" <pcp@xxxxxxxxxxx>
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <CANbxzdVdC91nn8WG8MXNu=LjP32ehO4VAa7tKNVuUONOyJh8uA@xxxxxxxxxxxxxx> (Rohan Arora's message of "Thu, 06 Aug 2015 13:21:51 +0000")
References: <CANbxzdVdC91nn8WG8MXNu=LjP32ehO4VAa7tKNVuUONOyJh8uA@xxxxxxxxxxxxxx>
Reply-to: pcp@xxxxxxxxxxx
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
Hi,

Rohan Arora <rarora2012@xxxxxxxxx> writes:
> I am using the Python API, and if I run a couple of mgFetch() calls
> using the MetricGroup class, and then use the metricConvert()
> function, I end up getting a value like 308.4132647893692. I had
> thought that to convert this rate converted value to a percentage, all
> I had to do was multiply by 100, but that would result in 30,800% of
> the CPU being used, and that is just by the user.

Assuming this is a continuation from your former thread, looking into
the metric description can help explain this;

% pminfo -dT kernel.all.cpu.user

kernel.all.cpu.user
    Data Type: 64-bit unsigned int  InDom: PM_INDOM_NULL 0xffffffff
    Semantics: counter  Units: millisec
Help:
total user CPU time from /proc/stat for all CPUs, including guest CPU
    time

Notice the semantics lists it as a 'counter' metric, not a percentage,
so we can't simply multiply by 100 and call it a day.  (check Section
2.3.3.2 in the PCP Programmer's Guide[1] for more details on semantics).

Second, the metricConvert() function doesn't convert from a counter
value to a percentage.  Instead, it calculates the delta between the
most current value you've fetched and the previously stored value.

Therefore, you'll have to fetch the other various cpu states (`pminfo
kernel.all.cpu` on the commandline for a full list of them) and
calculate the percentage as a total of all the cpu counters.

Hope that helps,

Lukas

[1] - http://www.pcp.io/doc/pcp-programmers-guide.pdf

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