dist/monitor-all.js
function(monitorJSON, connection, callback) {

      // Build a key for this probe from the probeClass and initParams
      var t = this,
          errStr = '',
          probeKey = t.buildProbeKey(monitorJSON);

      // Get the probe proxy
      var probeId = connection.remoteProbeIdsByKey[probeKey];
      var probeProxy = connection.remoteProbesById[probeId];

      if (!probeProxy) {

        // Connect with the remote probe
        connection.emit('probe:connect', monitorJSON, function(error, probeJSON){
          if (error) {
            errStr = "probe:connect returned an error for probeClass '" + monitorJSON.probeClass +
              "' on " + Monitor.toServerString(monitorJSON);
            return callback({err: error, msg: errStr});
          }
          probeId = probeJSON.id;

          // See if the proxy was created while waiting for return
          probeProxy = connection.remoteProbesById[probeId];
          if (probeProxy) {
            probeProxy.refCount++;
            log.info('connectExternal.connected.existingProxy', {probeId: probeId, refCount: probeProxy.refCount, whileWaiting: true});
            return callback(null, probeProxy);
          }

          // Create the probe proxy
          probeProxy = new Probe(probeJSON);
          probeProxy.refCount = 1;
          probeProxy.connection = connection;
          connection.remoteProbeIdsByKey[probeKey] = probeId;
          connection.remoteProbesById[probeId] = probeProxy;
          connection.addEvent('probe:change:' + probeId, function(attrs){probeProxy.set(attrs);});
          log.info('connectExternal.connected.newProxy', {probeId: probeId});
          return callback(null, probeProxy);
        });
        return;
      }

      // Probes are released based on reference count
      probeProxy.refCount++;
      log.info('connectExternal.connected.existingProxy', {probeId: probeId, refCount: probeProxy.refCount});
      return callback(null, probeProxy);
    }
function(monitorJSON, connection, callback) {

      // Build a key for this probe from the probeClass and initParams
      var t = this,
          errStr = '',
          probeKey = t.buildProbeKey(monitorJSON);

      // Get the probe proxy
      var probeId = connection.remoteProbeIdsByKey[probeKey];
      var probeProxy = connection.remoteProbesById[probeId];

      if (!probeProxy) {

        // Connect with the remote probe
        connection.emit('probe:connect', monitorJSON, function(error, probeJSON){
          if (error) {
            errStr = "probe:connect returned an error for probeClass '" + monitorJSON.probeClass +
              "' on " + Monitor.toServerString(monitorJSON);
            return callback({err: error, msg: errStr});
          }
          probeId = probeJSON.id;

          // See if the proxy was created while waiting for return
          probeProxy = connection.remoteProbesById[probeId];
          if (probeProxy) {
            probeProxy.refCount++;
            log.info('connectExternal.connected.existingProxy', {probeId: probeId, refCount: probeProxy.refCount, whileWaiting: true});
            return callback(null, probeProxy);
          }

          // Create the probe proxy
          probeProxy = new Probe(probeJSON);
          probeProxy.refCount = 1;
          probeProxy.connection = connection;
          connection.remoteProbeIdsByKey[probeKey] = probeId;
          connection.remoteProbesById[probeId] = probeProxy;
          connection.addEvent('probe:change:' + probeId, function(attrs){probeProxy.set(attrs);});
          log.info('connectExternal.connected.newProxy', {probeId: probeId});
          return callback(null, probeProxy);
        });
        return;
      }

      // Probes are released based on reference count
      probeProxy.refCount++;
      log.info('connectExternal.connected.existingProxy', {probeId: probeId, refCount: probeProxy.refCount});
      return callback(null, probeProxy);
    }
function ( monitorJSON , connection , callback ) { // Build a key for this probe from the probeClass and initParams var t = this , errStr = '' , probeKey = t . buildProbeKey ( monitorJSON ) ; // Get the probe proxy var probeId = connection . remoteProbeIdsByKey [ probeKey ] ; var probeProxy = connection . remoteProbesById [ probeId ] ; if ( ! probeProxy ) { // Connect with the remote probe connection . emit ( 'probe:connect' , monitorJSON , function ( error , probeJSON ) { if ( error ) { errStr = "probe:connect returned an error for probeClass '" + monitorJSON . probeClass + "' on " + Monitor . toServerString ( monitorJSON ) ; return callback ( { err : error , msg : errStr } ) ; } probeId = probeJSON . id ; // See if the proxy was created while waiting for return probeProxy = connection . remoteProbesById [ probeId ] ; if ( probeProxy ) { probeProxy . refCount ++ ; log . info ( 'connectExternal.connected.existingProxy' , { probeId : probeId , refCount : probeProxy . refCount , whileWaiting : true } ) ; return callback ( null , probeProxy ) ; } // Create the probe proxy probeProxy = new Probe ( probeJSON ) ; probeProxy . refCount = 1 ; probeProxy . connection = connection ; connection . remoteProbeIdsByKey [ probeKey ] = probeId ; connection . remoteProbesById [ probeId ] = probeProxy ; connection . addEvent ( 'probe:change:' + probeId , function ( attrs ) { probeProxy . set ( attrs ) ; } ) ; log . info ( 'connectExternal.connected.newProxy' , { probeId : probeId } ) ; return callback ( null , probeProxy ) ; } ) ; return ; } // Probes are released based on reference count probeProxy . refCount ++ ; log . info ( 'connectExternal.connected.existingProxy' , { probeId : probeId , refCount : probeProxy . refCount } ) ; return callback ( null , probeProxy ) ; }
Connect to an external probe implementation.

This connects with a probe running in another process.  It will
coordinate the remote instantiation of the probe if it's not running.

@method connectExternal
@protected
@param monitorJSON {Object} - An object containing:
@param monitorJSON.probeClass {String} - The probe class name (required)
@param monitorJSON.initParams {Object} - Probe initialization parameters (if any)
@param connection {Connection} - The connection to use
@param callback {Function(error, probeProxy)} - Called when connected
Connect to an external probe implementation .