[collectd] cpu-idle greater than 100?

Florian Forster octo at verplant.org
Tue Jul 15 08:08:17 CEST 2008


Hi Pavel,

On Fri, Jul 11, 2008 at 07:32:29PM +0300, Pavel Georgiev wrote:
> Is it OK that I get values larger than 100 for cpu-idle?

definitely. For one, under Linux the plugin counts ``jiffies'', and
there may be more than 100 jiffies in one second. This can be configured
when compiling the kernel and typical values are 100, 250, and 1000.

> rrdtool fetch  cpu-1/cpu-idle.rrd MIN -s 'end - 10min' |tail
> 1215793540: 1.0042000000e+02

By the look of it your kernel is configured for 100 jiffies per second.
However, it doesn't quite get it. My guess is that this is some sort of
timing issue. I've seen that a lot on virtual machines, especially
VMWare instances.. Maybe `idle' is a bad example, but in general I'd say
the busier a system the less accurate these counters become.

> Also, what is the best practice for calculating total cpu time? I`m
> trying to use 100 - cpu-idle but since cpu-idle does not look to be
> reported correctly.

You don't really mean ``total'' CPU time, right? The values should add
up to more or less the same value and all you could tell from the
variance is that the world is not as ideal as we'd like it to be ;)
I think you want ``the number of (split-)seconds spend in a non-idle
state'', right? You'll have to calculate that yourself:
  temp = nice + user + system + ...;
  non_idle = temp / (temp + idle);
The value `non_idle' is of type `seconds per second' and is an
approximation of the real thing! If you multiply it by 100 you'll get a
percentage.

> Is there an easy way to get the total CPU regardless of the number of
> CPUs or I need to calculate the average from all cpus?

You simply have to adapt the above formula:
  temp = nice0 + nice1 + ... + user0 + user1 + ... + system0 + ...;
  non_idle = num_cpus * temp / (temp + idle0 + idle1 + ...);
Again `non_idle' holds the number of seconds spent in a non-idle state
per second, and because you have `n' CPUs you can spend up to `n'
seconds in such a state - each second.

Hope this helps..
Regards,
-octo
-- 
Florian octo Forster
Hacker in training
GnuPG: 0x91523C3D
http://verplant.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20080715/61ddd88b/attachment.pgp 


More information about the collectd mailing list