示例#1
0
    def testSolrMetrics(self):
        metrics_check = Solr(logging.getLogger())
        agentConfig = {
            'solr_jmx_instance_1': 'localhost:3000:first_instance',
            'solr_jmx_instance_2': 'dummyurl:4444:fake_url',
            'solr_jmx_instance_3': 'monitorRole:solr@localhost:3001:second_instance_with_auth',
            'version': '0.1',
            'api_key': 'toto'
        }

        jmx_prefix = "-Dcom.sun.management.jmxremote"

        
        first_instance = None
        second_instance = None
       
        first_instance = "%s.port=3000 %s.authenticate=false -Djetty.port=8980" % (jmx_prefix, jmx_prefix)
        second_instance = "%s.port=3001 %s.authenticate=true -Djetty.port=8984 %s.password.file=/tmp/apache-solr-3/example/jmxremote.password %s.access.file=/tmp/apache-solr-3/example/jmxremote.access" % (jmx_prefix, jmx_prefix, jmx_prefix, jmx_prefix)
        
        first_instance = self.start_solr(first_instance, 8983)
        second_instance = self.start_solr(second_instance, 8984)
        
        
        r = metrics_check.check(agentConfig)

        if metrics_check.jmx._jmx is not None:
            metrics_check.jmx._jmx.terminate(force=True)
        
        if first_instance:
            kill_subprocess(first_instance)
        if second_instance:
            kill_subprocess(second_instance)
        self.assertTrue(type(r) == type([]))
        self.assertTrue(len(r) > 0)
        self.assertEquals(len([t for t in r if t[3].get('device_name') == "solr" and t[0] == "jvm.thread_count"]), 2, r)
示例#2
0
    def testJavaMetric(self):
        raise SkipTest("Test is not working properly on travis")
        metrics_check = Jvm(logging.getLogger())
        agentConfig = {
            'java_jmx_instance_1': 'localhost:8090',
            'java_jmx_instance_2': 'dummyhost:9999:dummy',
            'java_jmx_instance_3': 'localhost:2222:second_instance',
            'version': '0.1',
            'api_key': 'toto'
        }

        # Starting tomcat
        tomcat6 = '/tmp/apache-tomcat-6/bin'
        self.start_tomcat(tomcat6, 8080)

        # Starting solr
        jmx_prefix = "-Dcom.sun.management.jmxremote"
        first_instance = "%s.port=2222 %s.authenticate=false -Djetty.port=8380" % (jmx_prefix, jmx_prefix)
        first_instance = self.start_solr(first_instance, 8983)

        r = metrics_check.check(agentConfig)

        if metrics_check.jmx._jmx is not None:
            metrics_check.jmx._jmx.terminate(force=True)

        if first_instance:
            kill_subprocess(first_instance)

        self.stop_tomcat(tomcat6)

        self.assertTrue(type(r) == type([]))
        self.assertTrue(len(r) > 0)
        self.assertEquals(len([t for t in r if t[0] == "jvm.thread_count"]), 2, r)
 def tearDown(self):
     if self.process is not None:
         kill_subprocess(self.process)
     del self.cfg
示例#4
0
 def tearDown(self):
     if self.process is not None:
         kill_subprocess(self.process)
     del self.cfg
示例#5
0
        for instance in config['instances']:
            try:
                start = time.time()
                metrics_check.check(instance)
                timers_second_check.append(time.time() - start)
            except Exception,e:
                print e
                continue

        self.assertEquals(len([t for t in timers_first_check if t > 10]), 0, timers_first_check)
        self.assertEquals(len([t for t in timers_second_check if t > 2]), 0, timers_second_check)

        self.stop_tomcat(tomcat6)
        metrics_check.kill_jmx_connectors()
        if first_instance:
            kill_subprocess(first_instance)

    def testTomcatMetrics(self):
        raise SkipTest()
        agentConfig = {
            'tomcat_jmx_instance_1': 'localhost:8090:first_instance',
            'tomcat_jmx_instance_2': 'dummyurl:4444:fake_url',
            'tomcat_jmx_instance_3': 'monitorRole:tomcat@localhost:8091:second_instance_with_auth',
            'version': '0.1',
            'api_key': 'toto'
        }

        config = JmxCheck.parse_agent_config(agentConfig, 'tomcat')
        config['init_config'] = TOMCAT_CONFIG
        metrics_check = load_check('tomcat', config, agentConfig)