System Information (CPU Usage, Temp) lazarus / 32-Linux ---------------------------------------------------------------------- mbdev · 2013-09-12 18:04 Hello, I'm trying to read the system information and statistics and I want to get the CPU usage and temperature on linux. Are they specific system functions or components for that? ---------------------------------------------------------------------- wcleyton · 2013-09-12 20:02 I use tsmbios: http://code.google.com/p/tsmbios/ ---------------------------------------------------------------------- mbdev · 2013-09-14 09:46 But this system information are "static". I don't want to know which CPU is used, I want to get the current cpu usage for monitoring. ---------------------------------------------------------------------- greyspammer · 2013-11-02 20:06 It's an older thread but hopefully someone's still interested. Global load information is available through /proc/loadavg. Code: [Select]$ cat /proc/loadavg 0.97 0.56 0.40 2/551 29552 The numbers from left to right are: load within the last minute, the last five minutes, the last 15 minutes, currently running vs. total process and finally the last pid used. The file only exists on Linux systems. POSIX should support similar information through the 'uptime' command. Keep in mind that the numbers are not percentages or factors but represent the average number of processes that waited for the CPU in that specific period. That means: There's no real upper limitA load of 1 means that the system is well- balanced, i.e. it performs its task without wasting resources (every process gets a CPU when needed and no CPUs idle around)A load less than 1 means the system was bored for some timeA load greater than 1 means that the system was "overloaded", i.e. it could not service everyone immediately If you want absolute values, check /proc/stat. Code: [Select]$ cat /proc/stat cpu  705503 9604 259502 12059770 220545 378 5430 0 0 0 cpu0 177253 2254 63467 3036769 38763 1 1126 0 0 0 cpu1 172838 2670 65522 3023042 39920 7 3406 0 0 0 [...] The lines are cpu total and then each cpu/core seperately. The first for values are use time for the cpu for user, nice, system and idle. That allows you to calculate a percentage. For example: Code: [Select]  Times not idle: 705503+9604+259502 =    974.609 ÷ Total CPU time: 705503+9604+259502+12059770 = 13.034.379 ---------------------------------------------------------------------- --------- = System usage since start:       7,48% Of course, a smaller interval (like CPU usage for the last 5 minutes) requires you to watch the changes in the stats over time. There are also tools which you could execute to do the job for you (like 'top') but if you want to be independent from them and go directly to the system interface, the above is probably what you want. Temperatures are more problematic because there's no real standard for that which you can rely on. There are tools like lm-sensors and /proc and /sys are populated with some information files. But those strongly depend on the system and configuration in question (which hardware, which modules are loaded, etc.).