[lkml]   [1996]   [Jun]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: CPU Utilization
Followup to:  <>
By author: Systemkennung Linux <>
In newsgroup:
> Hi,
> > What's the best way to get the instantaneous CPU utilization? I am
> > trying to build-a-better-CPUMeter and I want a routine I can call about 4
> > times per second with little CPU overhead...
> Under Linux you can use the values in /proc/uptime. The first of the
> numbers is the number of seconds since the system was rebooted, the second
> the number of seconds idle time that were burned in the swapper process.
> It should be obvious how to compute the CPU usage % from these numbers.
> Or use the numbers from /proc/loadavg if they should fit your purpose
> better.
> It isn't really required to measure the CPU usage yourself unless you want
> to port this program to non-Linux operating systems which apparently still
> exist :-)

The *instantaneous* CPU usage, when measured, is always 100% since
your measuring process is obviously running at that time, the CPU is
being utilized... hence, it is a useless metric, and the reason a
decaying average is used instead.


PGP public key available - finger
I don't work for Yggdrasil, but they sponsor the linux.* hierarchy.
"The earth is but one country, and mankind its citizens." -- Bahá'u'lláh
Just Say No to Morden * Save Babylon 5:

 \ /
  Last update: 2005-03-22 13:37    [W:0.066 / U:0.988 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site