I have to get the cpu usage on Linux from a file located on my hard drive. But after some research about it, I didn’t find a proper file which informs me about the CPU usage.
The best solution would be to find the file which contains these information and updated frequently.
If you know one file which make this, it would be great, thank you.
This sort of information is available under the
/procfilesystem. Seeman proc.In particular:
/proc/loadavggives load averages;/proc/statgives information on the amount of time the system spent in user/kernel mode, etc (thanks @Mat!)/proc/[pid]/statcontains information on CPU times for the given process.man procwill give further details.