コード例 #1
0
    def test_server_agent(self):
        obj = Monitoring()
        obj.engine = EngineEmul()
        obj.parameters.merge({
            "server-agent": [{
                "address": "127.0.0.1:4444",
                "logging": "True",
                "metrics": ["cpu", "disks"]
            }, {
                "address": "10.0.0.1",
                "metrics": ["something1", "something2"]
            }]
        })

        listener = LoggingMonListener()
        obj.add_listener(listener)

        widget = obj.get_widget()
        obj.add_listener(widget)

        crit_conf = BetterDict.from_dict({
            "condition": ">",
            "threshold": 5,
            "subject": "127.0.0.1:4444/cpu"
        })
        criteria = MonitoringCriteria(crit_conf, obj)
        obj.add_listener(criteria)

        obj.client_classes = {'server-agent': ServerAgentClientEmul}

        obj.prepare()
        obj.startup()

        for i in range(1, 10):
            obj.clients[0].socket.recv_data += b("%s\t%s\t\n" % (i, i * 10))
            obj.check()
            ROOT_LOGGER.debug("Criteria state: %s", criteria)
            time.sleep(obj.engine.check_interval)

        obj.shutdown()
        obj.post_process()

        self.assertEquals(b("test\ninterval:1\nmetrics:cpu\tdisks\nexit\n"),
                          obj.clients[0].socket.sent_data)

        self.assertIsNotNone(obj.clients[0].logs_file)
        with open(obj.clients[0].logs_file) as serveragent_logs:
            logs_reader = csv.reader(serveragent_logs)
            logs_reader = list(logs_reader)
        self.assertEquals(['ts', 'cpu', 'disks'], logs_reader[0])
        for i in range(1, 10):
            self.assertEquals([str(i), str(i * 10)], logs_reader[i][1:])
コード例 #2
0
ファイル: test_JTLReader.py プロジェクト: zferenczik/taurus
    def test_stdev_performance(self):
        start = time.time()
        self.configure(RESOURCES_DIR + "jmeter/jtl/slow-stdev.jtl")
        res = list(self.obj.datapoints(final_pass=True))
        lst_json = to_json(res)

        self.assertNotIn('"perc": {},', lst_json)

        elapsed = time.time() - start
        ROOT_LOGGER.debug("Elapsed/per datapoint: %s / %s", elapsed, elapsed / len(res))
        # self.assertLess(elapsed, len(res))  # less than 1 datapoint per sec is a no-go
        exp = [0.53060066889723,
               0.39251356581014,
               0.388405157629,
               0.38927586980868,
               0.30511697736531,
               0.21160424043633,
               0.07339064994943]
        self.assertEqual(exp, [round(x[DataPoint.CURRENT][''][KPISet.STDEV_RESP_TIME], 14) for x in res])
コード例 #3
0
 def monitoring_data(self, data):
     ROOT_LOGGER.debug("Data: %s", data)