How to use the vaping.plugin.get_probe function in vaping

To help you get started, we’ve selected a few vaping examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 20c / vaping / tests / test_config.py View on Github external
def test_plugin_groups():

    """
    test plugin groups as per #44 implementation
    """

    probe = plugin.get_probe({
        "type" : "fping",
        "name" : "probe_c",
        "interval" : "3s",
        "groups": [{
            "name": "dns",
            "hosts": [{
                "host" : "1.1.1.1",
                "name" : "Cloudflare"
            }]
        }]
    }, {})


    expected = {
        "dns": {
            "name": "dns",
github 20c / vaping / tests / test_fping.py View on Github external
def test_run_probe(this_dir):
    config_dir = os.path.join(this_dir, 'data', 'config', 'fping')
    daemon = vaping.daemon.Vaping(config_dir=config_dir)
    probes = daemon.config.get('probes', None)

    fping = plugin.get_probe(probes[0], daemon.plugin_context)
    msg = fping.probe()
    print(msg)
github 20c / vaping / tests / test_vodka.py View on Github external
"dns": {
            "hosts": [{
                "host" : "1.1.1.1",
                "name" : "Cloudflare"
            }]
        }
    }, {})
    probe_to_graphsrv(probe)
    group = graphsrv.group.groups.get("probe_b").get("dns")

    assert group["targets"] == {"1.1.1.1":{"host":"1.1.1.1", "name":"Cloudflare"}}

    # vodka setup with plugin group implementation as
    # per #44

    probe = plugin.get_probe({
        "type" : "fping",
        "name" : "probe_c",
        "interval" : "3s",
        "groups": [{
            "name": "dns",
            "hosts": [{
                "host" : "1.1.1.1",
                "name" : "Cloudflare"
            }]
        }]
    }, {})
    probe_to_graphsrv(probe)
    group = graphsrv.group.groups.get("probe_c").get("dns")

    assert group["targets"] == {"1.1.1.1":{"host":"1.1.1.1", "name":"Cloudflare"}}
github 20c / vaping / tests / test_plugin.py View on Github external
obj = plugin.get_instance(each['name'], None)
        for k,v in list(each.items()):
            assert v == obj.config[k]

    obj = plugin.get_instance(anon_config, None)
    assert obj.config == anon_config

    # copy ctor
    obj = plugin.get_instance('fancy_copy', None)
    assert 'reeb' == obj.config['str0']

    obj = plugin.get_instance({'fancy_copy': {'var0': 'luggage'}}, None)
    assert 'reeb' == obj.config['str0']

    with pytest.raises(TypeError):
        plugin.get_probe('emit0', None)
    assert None != plugin.get_probe('probe1', None)
    assert not hasattr(plugin.get_probe('probe1', None), 'emit')

    with pytest.raises(TypeError):
        plugin.get_output('emit_abc', None)
    with pytest.raises(TypeError):
        plugin.get_output('probe1', None)
    assert None != plugin.get_output('emit0', None)
github 20c / vaping / vaping / daemon.py View on Github external
def _main(self):
        """
        process
        """
        probes = self.config.get('probes', None)
        if not probes:
            raise ValueError('no probes specified')

        for probe_config in self.config['probes']:
            probe = plugin.get_probe(probe_config, self.plugin_context)
            # FIXME - needs to check for output defined in plugin
            if 'output' not in probe_config:
                raise ValueError("no output specified")

            # get all output targets and start / join them
            for output_name in probe_config['output']:
                output = plugin.get_output(output_name, self.plugin_context)
                if not output.started:
                    output.start()
                    self.joins.append(output)
                probe._emit.append(output)

            probe.start()
            self.joins.append(probe)

        vaping.io.joinall(self.joins)
github 20c / vaping / vaping / plugins / vodka.py View on Github external
def start(self):

        if self._is_started:
            return
        self._is_started = True
        vodka.run(self.config, self.vaping.config)

        if graphsrv:
            # if graphsrv is installed proceed to generate
            # target configurations for it from probe config

            for node in self.vaping.config.get("probes", []):
                probe = vaping.plugin.get_probe(node, self.vaping)
                probe_to_graphsrv(probe)