Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to display the CPU usage for each processing core on a single shared-memory 12-core (SMP) machine. I don't have access to install htop, else I would simply use that. I don't need fancy graphs or meters, though they would be nice.

For example, simply displaying:

X   X   X   X   X   X   X   X   X   X   X   X

where each X is the percentage utilization of 1 of the 12 processing cores on my machine.

FYI: I know I can simply look at the utilization in "top" and divide that number by the number of cores on my machine, but I prefer a solution that shows each core separately.

share|improve this question
add comment

1 Answer

  grep ^cpu /proc/stat 

The columns are

  • user: normal processes executing in user mode
  • nice: niced processes executing in user mode
  • system: processes executing in kernel mode
  • idle: twiddling thumbs
  • iowait: waiting for I/O to complete
  • irq: servicing interrupts
  • softirq: servicing softirqs

Time units are in USER_HZ or Jiffies (typically hundredths of a second).

So you can do

  grep ^cpu[0-9] /proc/stat | cut -d' ' -f1,5

Or maybe use awk to convert these numbers into percentages and display them the way you want.

References: Linux Howtos

share|improve this answer
    
This is great... but how can I compute utilization percentage given those values? –  synaptik Nov 22 '12 at 5:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.