Example #1
0
 def test_as_influx(self, monkeypatch):
     monkeypatch.setattr(time, 'time', lambda: 100)
     m1 = metrics.Metrics(src='a', dst='b')
     m1.rtt = 70
     m1.loss = 1.2
     point1 = {
         'measurement': 'rtt',
         'tags': {
             'src_host': 'a',
             'dst_host': 'b',
         },
         'time': 100000000000,
         'fields': {
             'value': 70
         }
     }
     point2 = {
         'measurement': 'loss',
         'tags': {
             'src_host': 'a',
             'dst_host': 'b',
         },
         'time': 100000000000,
         'fields': {
             'value': 1.2
         }
     }
     assert type(m1.as_influx) is list
     assert point1 in m1.as_influx
     assert point2 in m1.as_influx
Example #2
0
def m1():
    m = metrics.Metrics('host1',
                        src='host2',
                        metro='iad',
                        facility='iad2',
                        cluster='iad2a')
    return m
Example #3
0
    def __init__(self, config, use_udp=False):
        """Constructor.

        Args:
            config: (config.CollectorConfig) of targets
            udp: (bool) Use UDP datagrams for probes (requires Reflectors)
        """
        self.method = ping.hping3
        if use_udp:
            self.method = ping.send_udp
        self.metrics = {}
        self.config = config
        for dst_ip, tags in self.config.targets:
            logging.info('Creating metrics for %s: %s', dst_ip, tags)
            self.metrics.setdefault(dst_ip, metrics.Metrics(**dict(tags)))