function update_stats(data)
{
  var timenow = parseInt(new Date().getTime() / 1000);
  for (var v in data) {
    switch (config.output_format) {
    case 'console':
      console.log([[os.hostname(), v].join('.'), data[v], timenow].join(' '));
      break;
    case 'graphite':
      console.log([[os.hostname(), v].join('.'), data[v], timenow].join(' '));
      break;
    case 'rrd-simple':
      /*
       * rrd-simple doesn't support sub-minute granularity, and RRD is
       * notoriously bad at being able to sample accurate data, so we round to
       * the nearest minute.
       */
      var off = timenow % 60;
      timenow = (off <= 30) ? timenow - off : timenow + (60 - off);
      /*
       * POST data
       */
      var data = [[timenow, v].join('.'), data[v]].join(' ');
      var http = require('http');
      var opts = {
        host: config.rrdsimple.host,
        port: config.rrdsimple.port,
        path: config.rrdsimple.path,
        method: 'POST',
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
          'Content-Length': data.length
        }
      }
      console.log('[' + new Date().toISOString() + '] ' +
                  [timenow, v].join('.') + ' -> ' + opts['host']);
      var req = http.request(opts, function (res) {
        // We currently fire-and-forget..
      }).write(data);
      break;
    }
  }
}
function update_stats(data)
{
  var timenow = parseInt(new Date().getTime() / 1000);
  for (var v in data) {
    switch (config.output_format) {
    case 'console':
      console.log([[os.hostname(), v].join('.'), data[v], timenow].join(' '));
      break;
    case 'graphite':
      console.log([[os.hostname(), v].join('.'), data[v], timenow].join(' '));
      break;
    case 'rrd-simple':
      
      var off = timenow % 60;
      timenow = (off <= 30) ? timenow - off : timenow + (60 - off);
      
      var data = [[timenow, v].join('.'), data[v]].join(' ');
      var http = require('http');
      var opts = {
        host: config.rrdsimple.host,
        port: config.rrdsimple.port,
        path: config.rrdsimple.path,
        method: 'POST',
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
          'Content-Length': data.length
        }
      }
      console.log('[' + new Date().toISOString() + '] ' +
                  [timenow, v].join('.') + ' -> ' + opts['host']);
      var req = http.request(opts, function (res) {
        
      }).write(data);
      break;
    }
  }
}
function update_stats ( data ) { var timenow = parseInt ( new Date ( ) . getTime ( ) / 1000 ) ; for ( var v in data ) { switch ( config . output_format ) { case 'console' : console . log ( [ [ os . hostname ( ) , v ] . join ( '.' ) , data [ v ] , timenow ] . join ( ' ' ) ) ; break ; case 'graphite' : console . log ( [ [ os . hostname ( ) , v ] . join ( '.' ) , data [ v ] , timenow ] . join ( ' ' ) ) ; break ; case 'rrd-simple' : /*
       * rrd-simple doesn't support sub-minute granularity, and RRD is
       * notoriously bad at being able to sample accurate data, so we round to
       * the nearest minute.
       */ var off = timenow % 60 ; timenow = ( off <= 30 ) ? timenow - off : timenow + ( 60 - off ) ; /*
       * POST data
       */ var data = [ [ timenow , v ] . join ( '.' ) , data [ v ] ] . join ( ' ' ) ; var http = require ( 'http' ) ; var opts = { host : config . rrdsimple . host , port : config . rrdsimple . port , path : config . rrdsimple . path , method : 'POST' , headers : { 'Content-Type' : 'application/x-www-form-urlencoded' , 'Content-Length' : data . length } } console . log ( '[' + new Date ( ) . toISOString ( ) + '] ' + [ timenow , v ] . join ( '.' ) + ' -> ' + opts [ 'host' ] ) ; var req = http . request ( opts , function ( res ) { // We currently fire-and-forget.. } ) . write ( data ) ; break ; } } }
/*
The callback function applied to each probe, its responsibility is to
return the results back to the appropriate collection system.
/ * The callback function applied to each probe its responsibility is to return the results back to the appropriate collection system .