accessing cpu information from linux kernel module -
i need access cpu idle time every 1 minute linux kernel module , print kern.log can plot graph statistics. please help.
thanks in advance.
you don't need write kernel module that, information provided in /proc/stat
:
$ awk ' /^cpu/ { print $1, $5 / 100; } ' /proc/stat cpu 251908 cpu0 63149.6 <--- total idle time in seconds cpu1 62053.2 ...
where 100 user_hz
constant (100 on systems).
if still wish write kernel module, can re-use /proc/stat
code here: fs/proc/stat.c.
Comments
Post a Comment