コード例 #1
0
class JMXTestCase(unittest.TestCase):

    def setUp(self):
        aggregator = MetricsAggregator("test_host")
        self.server = Server(aggregator, "localhost", STATSD_PORT)
        self.reporter = DummyReporter(aggregator)

        self.t1 = threading.Thread(target=self.server.start)
        self.t1.start()

        confd_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "jmx_yamls"))
        JMXFetch.init(confd_path, {'dogstatsd_port': STATSD_PORT}, get_logging_config(), 15)

    def tearDown(self):
        self.server.stop()
        self.reporter.finished = True
        JMXFetch.stop()

    def testCustomJMXMetric(self):
        raise SkipTest('Requires JMX be setup')
        count = 0
        while self.reporter.metrics is None:
            time.sleep(1)
            count += 1
            if count > 20:
                raise Exception("No metrics were received in 20 seconds")

        metrics = self.reporter.metrics

        self.assertTrue(isinstance(metrics, list))
        self.assertTrue(len(metrics) > 0)
        self.assertTrue(len([t for t in metrics if "cassandra.db." in t[
                        'metric'] and "instance:cassandra_instance" in t['dimensions']]) > 40, metrics)
コード例 #2
0
    def setUp(self):
        aggregator = MetricsAggregator("test_host")
        self.server = Server(aggregator, "localhost", STATSD_PORT)
        self.reporter = DummyReporter(aggregator)

        self.t1 = threading.Thread(target=self.server.start)
        self.t1.start()

        confd_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "jmx_yamls"))
        JMXFetch.init(confd_path, {'dogstatsd_port': STATSD_PORT}, get_logging_config(), 15)
コード例 #3
0
class JMXTestCase(unittest.TestCase):
    def setUp(self):
        aggregator = MetricsAggregator("test_host")
        self.server = Server(aggregator, "localhost", STATSD_PORT)
        self.reporter = DummyReporter(aggregator)

        self.t1 = threading.Thread(target=self.server.start)
        self.t1.start()

        confd_path = os.path.realpath(
            os.path.join(os.path.abspath(__file__), "..", "jmx_yamls"))
        JMXFetch.init(confd_path, {'dogstatsd_port': STATSD_PORT},
                      get_logging_config(), 15)

    def tearDown(self):
        self.server.stop()
        self.reporter.finished = True
        JMXFetch.stop()

    def testCustomJMXMetric(self):
        raise SkipTest('Requires running JMX')
        count = 0
        while self.reporter.metrics is None:
            time.sleep(1)
            count += 1
            if count > 20:
                raise Exception("No metrics were received in 20 seconds")

        metrics = self.reporter.metrics

        self.assertTrue(isinstance(metrics, list))
        self.assertTrue(len(metrics) > 0)
        self.assertEqual(
            len([
                t for t in metrics if t['metric'] == "my.metric.buf"
                and "instance:jmx_instance1" in t['dimensions']
            ]), 2, metrics)
        self.assertTrue(
            len([
                t for t in metrics if 'type:ThreadPool' in t['dimensions']
                and "instance:jmx_instance1" in t['dimensions']
                and "jmx.catalina" in t['metric']
            ]) > 8, metrics)
        self.assertTrue(
            len([
                t for t in metrics if "jvm." in t['metric']
                and "instance:jmx_instance1" in t['dimensions']
            ]) == 7, metrics)
コード例 #4
0
    def setUp(self):
        aggregator = MetricsAggregator("test_host")
        self.server = Server(aggregator, "localhost", STATSD_PORT)
        self.reporter = DummyReporter(aggregator)

        self.t1 = threading.Thread(target=self.server.start)
        self.t1.start()

        confd_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "jmx_yamls"))
        JMXFetch.init(confd_path, {'dogstatsd_port': STATSD_PORT}, get_logging_config(), 15)
コード例 #5
0
ファイル: test_tomcat.py プロジェクト: ghessler/mon-agent
class JMXTestCase(unittest.TestCase):

    def setUp(self):
        aggregator = MetricsAggregator("test_host")
        self.server = Server(aggregator, "localhost", STATSD_PORT)
        pid_file = PidFile('dogstatsd')
        self.reporter = DummyReporter(aggregator)

        self.t1 = threading.Thread(target=self.server.start)
        self.t1.start()

        confd_path = os.path.realpath(os.path.join(os.path.abspath(__file__), "..", "jmx_yamls"))
        JMXFetch.init(confd_path, {'dogstatsd_port': STATSD_PORT}, get_logging_config(), 15)

    def tearDown(self):
        self.server.stop()
        self.reporter.finished = True
        JMXFetch.stop()

    def testTomcatMetrics(self):
        raise SkipTest('Requires working JMX')
        count = 0
        while self.reporter.metrics is None:
            time.sleep(1)
            count += 1
            if count > 20:
                raise Exception("No metrics were received in 20 seconds")

        metrics = self.reporter.metrics

        self.assertTrue(isinstance(metrics, list))
        self.assertTrue(len(metrics) > 0)
        self.assertEquals(len([t for t in metrics if t[
                          'metric'] == "tomcat.threads.busy" and "instance:tomcat_instance" in t['dimensions']]), 2, metrics)
        self.assertEquals(len([t for t in metrics if t[
                          'metric'] == "tomcat.bytes_sent" and "instance:tomcat_instance" in t['dimensions']]), 0, metrics)
        self.assertTrue(len([t for t in metrics if "jvm." in t['metric']
                             and "instance:tomcat_instance" in t['dimensions']]) > 4, metrics)