title: Calculating CPU usage from /proc/stat
body: <p>When reading <code>/proc/stat</code>, I get these return values:</p>
  
  <pre><code>cpu  20582190 643 1606363 658948861 509691 24 112555 0 0 0                      
  cpu0 3408982 106 264219 81480207 19354 0 35 0 0 0                               
  cpu1 3395441 116 265930 81509149 11129 0 30 0 0 0                               
  cpu2 3411003 197 214515 81133228 418090 0 1911 0 0 0                            
  cpu3 3478358 168 257604 81417703 30421 0 29 0 0 0                               
  cpu4 1840706 20 155376 83328751 1564 0 7 0 0 0                                  
  cpu5 1416488 15 171101 83410586 1645 13 108729 0 0 0                            
  cpu6 1773002 7 133686 83346305 25666 10 1803 0 0 0                              
  cpu7 1858207 10 143928 83322929 1819 0 8 0 0 0
  </code></pre>
  
  <p>Some sources state to read only the first four values to calculate CPU usage, while some sources say to read all the values.</p>
  
  <p>Do I read only the first four values to calculate CPU utilization; the values <code>user</code>, <code>nice</code>, <code>system</code>, and <code>idle</code>? Or do I need all the values? Or not all, but more than four? Would I need <code>iowait</code>, <code>irq</code>, or <code>softirq</code>?</p>
  
  <pre><code>cpu  20582190 643 1606363
  </code></pre>
  
  <p>Versus the entire line.</p>
  
  <pre><code>cpu  20582190 643 1606363 658948861 509691 24 112555 0 0 0
  </code></pre>
  
  <p><strong>Edits:</strong> Some sources also state that <code>iowait</code> is added into <code>idle</code>.</p>
  
  <p>When calculating a specific process' CPU usage, does the method differ?</p>