takes a probe instance and generates
    a graphsrv data group for it using the
    probe's config
960898
def probe_to_graphsrv(probe):
    

    config = probe.config

    # manual group set up via `group` config key

    if "group" in config:
        source, group = config["group"].split(".")
        group_field = config.get("group_field", "host")
        group_value = config[group_field]
        graphsrv.group.add(source, group, {group_value:{group_field:group_value}}, **config)
        return

    # automatic group setup for fping
    # FIXME: this should be somehow more dynamic

    for k, v in list(config.items()):
        if isinstance(v, dict) and "hosts" in v:
            r = {}
            for host in v.get("hosts"):
                if isinstance(host, dict):
                    r[host["host"]] = host
                else:
                    r[host] = {"host":host}
            graphsrv.group.add(probe.name, k, r, **v)
551738
def get_probes_config(self):
        """"""
        probes = {}

        probes_table = junos_views.junos_rpm_probes_config_table(self.device)
        probes_table.get()
        probes_table_items = probes_table.items()

        for probe_test in probes_table_items:
            test_name = py23_compat.text_type(probe_test[0])
            test_details = {
                p[0]: p[1] for p in probe_test[1]
            }
            probe_name = napalm_base.helpers.convert(
                py23_compat.text_type, test_details.pop('probe_name'))
            target = napalm_base.helpers.convert(
                py23_compat.text_type, test_details.pop('target', ''))
            test_interval = napalm_base.helpers.convert(int, test_details.pop('test_interval', '0'))
            probe_count = napalm_base.helpers.convert(int, test_details.pop('probe_count', '0'))
            probe_type = napalm_base.helpers.convert(
                py23_compat.text_type, test_details.pop('probe_type', ''))
            source = napalm_base.helpers.convert(
                py23_compat.text_type, test_details.pop('source_address', ''))
            if probe_name not in probes.keys():
                probes[probe_name] = {}
            probes[probe_name][test_name] = {
                'probe_type': probe_type,
                'target': target,
                'source': source,
                'probe_count': probe_count,
                'test_interval': test_interval
            }

        return probes
435127
static void constructAvgHitsGraph(Map.Entry<String, LrProjectScenarioResults> scenarioResults,
                                      JSONObject scenarioGraphData) {
        Map<Integer, WholeRunResult> avgHitsPerSec = scenarioResults.getValue().getAverageHitsPerSecondResults();
        JSONObject avgHitsPerSecGraphSet = extractWholeRunSlaResult(avgHitsPerSec, "Hits/Sec");
        if (!avgHitsPerSecGraphSet.getJSONArray(LABELS).isEmpty()) {
            avgHitsPerSecGraphSet.put(TITLE, "Average Hits per Second");
            avgHitsPerSecGraphSet.put(X_AXIS_TITLE, "Build number");
            avgHitsPerSecGraphSet.put(Y_AXIS_TITLE, "Hits");
            avgHitsPerSecGraphSet.put(DESCRIPTION,
                    "Displays the number of hits made on the Web server by Vusers " +
                            "during each second of the load test. This graph helps you evaluate the amount of load " +
                            "Vusers" +
                            " " +
                            "generate, in terms of the number of hits.");
            scenarioGraphData.put("avgHitsPerSec", avgHitsPerSecGraphSet);
        }
    }
823657
def _expand_probes(probes, defaults):

    '''
    
    '''

    expected_probes = {}

    for probe_name, probe_test in six.iteritems(probes):
        if probe_name not in expected_probes.keys():
            expected_probes[probe_name] = {}
        probe_defaults = probe_test.pop('defaults', {})
        for test_name, test_details in six.iteritems(probe_test):
            test_defaults = test_details.pop('defaults', {})
            expected_test_details = deepcopy(defaults)  # copy first the general defaults
            expected_test_details.update(probe_defaults)  # update with more specific defaults if any
            expected_test_details.update(test_defaults)  # update with the most specific defaults if possible
            expected_test_details.update(test_details)  # update with the actual config of the test
            if test_name not in expected_probes[probe_name].keys():
                expected_probes[probe_name][test_name] = expected_test_details

    return expected_probes
23909
function(params, callback) {
      callback = callback || function(){};
      var t = this,
          errorText = '',
          router = Monitor.getRouter(),
          probeId = params.probeId,
          monitorProxy = t.incomingMonitorsById[probeId],
          firewall = t.get('firewall'),
          logCtxt = null,
          probe = null;

      // Already disconnected
      if (!monitorProxy || !monitorProxy.probe) {
        return callback(null);
      }

      // Get a good logging context
      probe = monitorProxy.probe;
      logCtxt = {
        probeClass: monitorProxy.get('probeClass'),
        initParams: monitorProxy.get('initParams'),
        probeId: probeId
      };

      // Called upon disconnect (internal or external)
      var onDisconnect = function(error) {
        if (error) {
          log.error(t.logId + 'probeDisconnect', error);
          return callback(error);
        }
        var duration = logCtxt.duration = Date.now() - probe.connectTime;
        probe.off('change', monitorProxy.probeChange);
        monitorProxy.probe = monitorProxy.probeChange = null;
        delete t.incomingMonitorsById[probeId];
        log.info(t.logId + 'probeDisconnected', logCtxt);
        stat.time(t.logId + 'probeDisconnected', duration);
        return callback(null);
      };

      // Disconnect from an internal or external probe
      if (probe && probe.connection) {
        router.disconnectExternal(probe.connection, probeId, onDisconnect);
      } else {
        router.disconnectInternal(probeId, onDisconnect);
      }
    }
349629
function Probe(collector) {
  this.fuse();

  //
  // Add _auth if username and password are provided via options.
  //
  var config = collector.options.npm || { loglevel: 'silent' };
  if (config.username && config.password) {
    config._auth = new Buffer(config.username +':'+ config.password).toString('base64');
  }

  //
  // Name of the probe and the registries the probe should run against.
  //
  this.readable('name', 'publish');
  this.readable('list', ['npmjs']);
  this.readable('config', config);
  this.readable('collector', collector);

  //
  // References to the test package that will be published.
  //
  this.readable('live', require('../registries').npmjs.href + 'npm-publish-probe');
  this.readable('map', path.join(__dirname, '..', 'publish'));
  this.readable('package', path.join(this.map, 'package.json'));
  this.writable('module', require(this.package));

  //
  // Test the publish module every 6 minutes.
  //
  this.readable('interval', interval);
}
511837
def probes_used_generate_vector(probe_files_full, probe_files_model):
  """"""
  import numpy as np
  C_probesUsed = np.ndarray((len(probe_files_full),), 'bool')
  C_probesUsed.fill(False)
  c=0
  for k in sorted(probe_files_full.keys()):
    if probe_files_model.has_key(k): C_probesUsed[c] = True
    c+=1
  return C_probesUsed
1080518
def resp_graph_raw(dataframe, image_name, dir='./'):
    
    factor = int(len(dataframe) / 10)
    df = dataframe.reset_index()
    fig = pygal.Dot(stroke=False,
                    x_label_rotation=25,
                    x_title='Elapsed Time In Test (secs)',
                    y_title='Average Response Time (secs)',
                    js=('scripts/pygal-tooltip.min.js',))
    try:
        grp = df.groupby(pd.cut(df.index, np.arange(0, len(df), factor)))
        fig.x_labels = [x for x in grp.first()['epoch']]
        fig.title = image_name.split('.')[0]
        fig.add('Time', [x for x in grp.describe()['scriptrun_time'].unstack()['mean'].round(2)])
    except ZeroDivisionError:
        print("Not enough data for raw graph")
    fig.render_to_file(filename=os.path.join(dir, image_name))
932705
def build_class_graph(modules, klass=None, graph=None):
        
        if klass is None:
            class_graph = nx.DiGraph()
            for name, classmember in inspect.getmembers(modules, inspect.isclass):
                if issubclass(classmember, Referent) and classmember is not Referent:
                    TaxonomyCell.build_class_graph(modules, classmember, class_graph)
            return class_graph
        else:
            parents = getattr(klass, '__bases__')
            for parent in parents:
                if parent != Referent:
                    graph.add_edge(parent.__name__, klass.__name__)
                    # store pointer to classes in property 'class'
                    graph.node[parent.__name__]['class'] = parent
                    graph.node[klass.__name__]['class'] = klass 
                    if issubclass(parent, Referent):
                        TaxonomyCell.build_class_graph(modules, parent, graph)
1149443
def _probe_positions(probe, group):
    """"""
    positions = probe['channel_groups'][group]['geometry']
    channels = _probe_channels(probe, group)
    return np.array([positions[channel] for channel in channels])
852606
def _get_graph_properties(self, plot, element, data, mapping, ranges, style):
        ""
        sources = []
        properties, mappings = {}, {}

        for key in ('scatter_1', self.edge_glyph):
            gdata = data.pop(key, {})
            group_style = dict(style)
            style_group = self._style_groups.get('_'.join(key.split('_')[:-1]))

            with abbreviated_exception():
                group_style = self._apply_transforms(element, gdata, ranges, group_style, style_group)

            # Get source
            source = self._init_datasource(gdata)
            self.handles[key+'_source'] = source
            sources.append(source)

            # Get style
            others = [sg for sg in self._style_groups.values() if sg != style_group]
            glyph_props = self._glyph_properties(
                plot, element, source, ranges, group_style, style_group)
            for k, p in glyph_props.items():
                if any(k.startswith(o) for o in others):
                    continue
                properties[k] = p
            mappings.update(mapping.pop(key, {}))
        properties = {p: v for p, v in properties.items() if p not in ('legend', 'source')}
        properties.update(mappings)

        # Initialize graph layout
        layout = data.pop('layout', {})
        layout = StaticLayoutProvider(graph_layout=layout)
        self.handles['layout_source'] = layout

        return tuple(sources+[layout]), properties
977540
def add_probe(self, probe):
        """"""
        if self.probes:
            probe_last = self.probes[-1]
            if not probe.ip:
                probe.ip = probe_last.ip
                probe.name = probe_last.name
        self.probes.append(probe)
552546
def make_dict_config(graph):
    
    formatters = {}
    handlers = {}
    loggers = {}

    # create the console handler
    formatters["ExtraFormatter"] = make_extra_console_formatter(graph)
    handlers["console"] = make_stream_handler(graph, formatter="ExtraFormatter")

    # maybe create the loggly handler
    if enable_loggly(graph):
        formatters["JSONFormatter"] = make_json_formatter(graph)
        handlers["LogglyHTTPSHandler"] = make_loggly_handler(graph, formatter="JSONFormatter")

    # configure the root logger to output to all handlers
    loggers[""] = {
        "handlers": handlers.keys(),
        "level": graph.config.logging.level,
    }

    # set log levels for libraries
    loggers.update(make_library_levels(graph))

    return dict(
        version=1,
        disable_existing_loggers=False,
        formatters=formatters,
        handlers=handlers,
        loggers=loggers,
    )
221234
def _generate_graph_controls(self):
        
        # setup mode radio buttons
        stress_modes = self.controller.stress_conroller.get_modes()
        group = []
        for mode in stress_modes:
            self.mode_buttons.append(radio_button(group, mode,
                                                  self.on_mode_button))

        # Set default radio button to "Monitor" mode
        self.mode_buttons[0].set_state(True, do_callback=False)

        # Create list of buttons
        control_options = list()
        control_options.append(button('Graphs',
                                      self.on_graphs_menu_open))
        control_options.append(button('Summaries',
                                      self.on_summary_menu_open))
        if self.controller.stress_exe:
            control_options.append(button('Stress Options',
                                          self.on_stress_menu_open))
        control_options.append(button("Reset", self.on_reset_button))
        control_options.append(button('Help', self.on_help_menu_open))
        control_options.append(button('About', self.on_about_menu_open))
        control_options.append(button("Save Settings",
                                      self.on_save_settings))
        control_options.append(button("Quit", self.on_exit_program))

        # Create the menu
        animate_controls = urwid.GridFlow(control_options, 18, 2, 0, 'center')

        # Create smooth graph selection button
        default_smooth = self.controller.smooth_graph_mode
        if urwid.get_encoding_mode() == "utf8":
            unicode_checkbox = urwid.CheckBox(
                "UTF-8", state=default_smooth,
                on_state_change=self.on_unicode_checkbox)
            # Init the state of the graph accoding to the selected mode
            self.on_unicode_checkbox(state=default_smooth)
        else:
            unicode_checkbox = urwid.Text(
                "[N/A] UTF-8")

        install_stress_message = urwid.Text("")
        if not self.controller.stress_exe:
            install_stress_message = urwid.Text(
                ('button normal', u"(N/A) install stress"))

        controls = [urwid.Text(('bold text', u"Modes"), align="center")]
        controls += self.mode_buttons
        controls += [
            install_stress_message,
            urwid.Text(('bold text', u"Stress Timer"), align="center"),
            self.clock_view,
            urwid.Divider(),
            urwid.Text(('bold text', u"Control Options"), align="center"),
            animate_controls,
            urwid.Divider(),
            urwid.Text(('bold text', u"Visual Options"), align="center"),
            unicode_checkbox,
            self.refresh_rate_ctrl,
            urwid.Divider(),
            urwid.Text(('bold text', u"Summaries"), align="center"),
        ]

        return controls
485365
def mapper_graph(df, lens_data=None, lens='pca', resolution=10, gain=0.5, equalize=True, clust='kmeans', stat='db',
                 max_K=5):
    
    if lens_data is None:
        lens_data = apply_lens(df, lens=lens)

    patch_clusterings = {}
    counter = 0
    patches = covering_patches(lens_data, resolution=resolution, gain=gain, equalize=equalize)
    for key, patch in patches.items():
        if len(patch) > 0:
            patch_clusterings[key] = optimal_clustering(df, patch, method=clust, statistic=stat, max_K=max_K)
            counter += 1
    print 'total of {} patches required clustering'.format(counter)

    all_clusters = []
    for key in patch_clusterings:
        all_clusters += patch_clusterings[key]
    num_nodes = len(all_clusters)
    print 'this implies {} nodes in the mapper graph'.format(num_nodes)

    A = np.zeros((num_nodes, num_nodes))
    for i in range(num_nodes):
        for j in range(i):
            overlap = set(all_clusters[i]).intersection(set(all_clusters[j]))
            if len(overlap) > 0:
                A[i, j] = 1
                A[j, i] = 1

    G = nx.from_numpy_matrix(A)
    total = []
    all_clusters_new = []
    mapping = {}
    cont = 0
    for m in all_clusters:
        total += m
    for n, m in enumerate(all_clusters):
        if len(m) == 1 and total.count(m) > 1:
            G.remove_node(n)
        else:
            all_clusters_new.append(m)
            mapping[n] = cont
            cont += 1
    H = nx.relabel_nodes(G, mapping)
    return H, all_clusters_new, patches
380129
async def probe(self):
        

        for adapter in self.adapters:
            if adapter.get_config('probe_supported', False):
                await adapter.probe()
386428
def probe(self):
        

        # make sure the filehandler is still valid
        # (e.g. file stat hasnt changed, file exists etc.)
        if not self.validate_file_handler():
            return []

        messages = []

        # read any new lines and push them onto the stack
        for line in self.fh.readlines(self.max_lines):
            data = {"path":self.path}
            msg = self.new_message()

            # process the line - this is where parsing happens
            parsed = self.process_line(line, data)
            if not parsed:
                continue
            data.update(parsed)

            # process the probe - this is where data assignment
            # happens
            data = self.process_probe(data)
            msg["data"] = [data]
            messages.append(msg)


        # process all new messages before returning them
        # for emission
        messages = self.process_messages(messages)

        return messages