/*
 * Network statistics
 */

var exec = require('child_process').exec;

function get_netstat(callback)
{
  switch (process.platform) {
  case 'linux':
    exec('netstat -ant', function (err, stdout, stderr) {
      var ret = {};
      stdout.split('\n').forEach(function (line) {
        var vals = line.split(/\s+/);
        if (vals[0].match(/^tcp/)) {
          var key = ['net.state', vals[0], vals[5].toLowerCase()].join(".");
          if (!ret[key]) {
            ret[key] = 1;
          } else {
            ret[key] += 1;
          }
        }
      }, ret);
      callback(ret);
    });
    break;
  }
}

module.exports.probes = {
  'net.state': get_netstat,
}

@@ -64,16 +64,40 @@
 ').exec;
+%0Avar fs = require('fs');
 %0A%0Afuncti
@@ -448,11 +448,11 @@
 oin(
-%22.%22
+'.'
 );%0A 
@@ -633,16 +633,727 @@
 %0A  %7D%0A%7D%0A%0A
+function get_net_traffic(callback)%0A%7B%0A  switch (process.platform) %7B%0A  case 'linux':%0A    var format = %7B%0A      'rx.bytes': 1,%0A      'rx.packets': 2,%0A      'tx.bytes': 9,%0A      'tx.packets': 10,%0A    %7D%0A    fs.readFile('/proc/net/dev', 'ascii', function (err, data) %7B%0A      var ret = %7B%7D;%0A      data.split('%5Cn').forEach(function (line) %7B%0A        line = line.replace(/%5E%5Cs+/, '');%0A        var vals = line.split(/%5Cs+/);%0A        if (vals%5B0%5D.match(/:$/)) %7B%0A          var iface = vals%5B0%5D.replace(/:$/, '');%0A          for (var f in format) %7B%0A            var key = %5B'net.traffic', iface, f%5D.join('.');%0A            ret%5Bkey%5D = vals%5Bformat%5Bf%5D%5D;%0A          %7D%0A        %7D%0A      %7D, ret);%0A      callback(ret);%0A    %7D);%0A    break;%0A  %7D%0A%7D%0A%0A
 module.e
@@ -1398,10 +1398,44 @@
 etstat,%0A
+  'net.traffic': get_net_traffic,%0A
 %7D%0A

Add get_net_traffic, again Linux-only for now.