0

I have a 4 socket server having 24 core cpu's. 96 cores total. How can I, in RHEL 7/8 Linux, get the value that is %CPU as shown by top for every core in the system?

I plan on writing C code that will periodically gather all these numbers to calculate a system utilization value.

1 Answer 1

1

Assuming you have procfs mounted at /proc, then the first line of /proc/stat has the summary for the system, and the next N lines have the values for each CPU. man procfs will point out the fields.

These are the amount of time spent in user, nice, system, iowait, etc.

You need to read the data twice with a delay between the two reads, calculate the differences in the readings, divide by the time between the readings.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .