CPU load average in /proc
Ξ November 8th, 2009 | → 0 Comments |
∇ Development | ∇ getloadavg, man, proc |
One of my C/C++ applications needed to provide information about CPU usage for debug and monitoring purposes. I never had to do anything like this, but quickly found what something interesting. The getloadavg is a standard library function that provides simplified information on CPU load average.
Because the function seems to point to /proc as source of information, I got to “take a look under the hood” and search for more information about /proc. I already knew that this so called filesystem (which in fact is only virtual) provides an easily accessible interface to kernel information.
Inside, it contains a folder called pid for each process running in the machine and several other folders/files that contain information on available memory, devices (e.g. disks) or kernel version.
If you take the usual look at the man page for proc, I’m sure you’ll find it interesting. it contains much more information than the one I was expecting.





