title: How to get system statistics with node.js
body: <p>I have a distributed server system.</p>
  
  <p>There are a lot of servers, coordinated through PubSub.
  All of them are connected to the statistics server.
  Every minute servers send their stats to the stat server (how many requests was processed, average time etc.).</p>
  
  <p>So... It would be nice to include system status in this stat-messages.
  I need CPU load (every core) and amount of free memory.</p>
  
  <p>I made a little workaround and decided to call a linux command with "exec", parse answer and form a JSON data for sending.</p>
  
  <p>But how can I get this data from command line?</p>
  
  <p>On Mac OS X I can easily get all I need with geektool scripts, but on linux (debian) they don't work.</p>
  
  <p>For example: </p>
  
  <pre><code>top -l 1 | awk '/PhysMem/ {print "Used: " $8 " Free: " $10}'
  </code></pre>
  
  <p>On Mac OS X Lion I get:</p>
  
  <pre><code>Used: 3246M Free: 848M
  </code></pre>
  
  <p>And just an error in debian...</p>