示例#1
0
    def test_init_default_tcp_udp(self):
        modconf = Module({
            'module_name': 'carbon',
            'module_type': 'carbon',
            'use_tcp': 'True',
            'use_udp': 'True'
        })

        arbiter = get_instance(modconf)
        self.assertEqual(arbiter.tcp['host'], "0.0.0.0")
        self.assertEqual(arbiter.tcp['port'], 2003)
        self.assertEqual(arbiter.udp['host'], "239.192.74.66")
        self.assertEqual(arbiter.udp['port'], 2003)
        self.assertEqual(arbiter.udp['multicast'], False)
示例#2
0
    def test_get_check_result_perfdata_points(self):
        tags = {"host_name": "testname"}
        data = {
            'perf_data': 'ramused=1009MB;;;0;1982 swapused=540PT;;;0;3827 \
                memused=1550GB;2973;3964;0;5810'
        }
        timestamp = 1403618279

        expected = [
            {'fields':
                {'max': 1982.0,
                 'unit': 'MB',
                 'value': 1009.0,
                 'min': 0.0},
                'time': 1403618279,
                'tags': {'host_name': 'testname'},
                'measurement': 'metric_ramused'},
            {'fields':
                {'min': 0.0,
                 'max': 5810.0,
                 'value': 1550.0,
                 'warning': 2973.0,
                 'critical': 3964.0,
                 'unit': 'GB'},
                'time': 1403618279,
                'tags': {'host_name': 'testname'},
                'measurement': 'metric_memused'},
            {'fields':
                {'max': 3827.0,
                 'unit': 'PT',
                 'value': 540.0,
                 'min': 0.0},
                'time': 1403618279,
                'tags': {'host_name': 'testname'},
                'measurement': 'metric_swapused'}]

        result = InfluxdbBroker.get_check_result_perfdata_points(
            get_instance(self.basic_modconf),
            data['perf_data'],
            timestamp,
            tags
        )

        # print result

        self.assertEqual(expected, result)
示例#3
0
    def test_init(self):
        modconf = Module({
            'module_name': 'carbon',
            'module_type': 'carbon',
            'use_tcp': 'True',
            'host_tcp': 'testhost',
            'port_tcp': '1111',
            'use_udp': 'True',
            'host_udp': 'testhost2',
            'port_udp': '1112',
            'multicast': 'False',
            'interval': '25',
            'grouped_collectd_plugins': 'disk,cpu,df'
        })

        arbiter = get_instance(modconf)
        self.assertEqual(arbiter.tcp['host'], "testhost")
        self.assertEqual(arbiter.tcp['port'], 1111)
        self.assertEqual(arbiter.udp['host'], "testhost2")
        self.assertEqual(arbiter.udp['port'], 1112)
        self.assertEqual(arbiter.udp['multicast'], False)
        self.assertEqual(arbiter.interval, 25)
        self.assertEqual(arbiter.grouped_collectd_plugins,
                         ['disk', 'cpu', 'df'])
示例#4
0
 def test_get_instance(self):
     result = get_instance(self.basic_modconf)
     self.assertIsInstance(result, InfluxdbBroker)
示例#5
0
 def test_init_defaults(self):
     arbiter = get_instance(self.basic_modconf)
     self.assertEqual(arbiter.tcp, {})
     self.assertEqual(arbiter.udp, {})
     self.assertEqual(arbiter.interval, 10)
     self.assertEqual(arbiter.grouped_collectd_plugins, [])
示例#6
0
 def test_get_instance(self):
     result = get_instance(self.basic_modconf)
     self.assertIsInstance(result, CarbonArbiter)