title: Convert the output of os.cpus() in Node.js to percentage
body: <p>Is there a way to convert the os.cpus() info to percentage? Just like the output of iostat (on the CPU section).</p>
  
  <p>My code:</p>
  
  <pre><code>var os = require('os');
  console.log(os.cpus());
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>[ { model: 'MacBookAir4,2',
      speed: 1800,
      times: 
       { user: 5264280,
         nice: 0,
         sys: 4001110,
         idle: 58703910,
         irq: 0 } },
    { model: 'MacBookAir4,2',
      speed: 1800,
      times: 
       { user: 2215030,
         nice: 0,
         sys: 1072600,
         idle: 64657440,
         irq: 0 } },
    { model: 'MacBookAir4,2',
      speed: 1800,
      times: 
       { user: 5973360,
         nice: 0,
         sys: 3197990,
         idle: 58773760,
         irq: 0 } },
    { model: 'MacBookAir4,2',
      speed: 1800,
      times: 
       { user: 2187650,
         nice: 0,
         sys: 1042550,
         idle: 64714820,
         irq: 0 } } ]
  </code></pre>
  
  <p>I would like to have the "times" metric converted to percentage, just like is show on the <code>iostat</code> command:</p>
  
  <pre><code>  cpu
  us sy id
  6  3 91
  </code></pre>
  
  <p>I understand that the values in the nodejs function are in CPU ticks, but I have no idea what formula should I use to convert them to percentage :)</p>
  
  <p>Thanks.</p>